Last active
May 23, 2020 16:25
-
-
Save SimonAlling/00e728961c3f3f8cbb9daa32cc1d8b20 to your computer and use it in GitHub Desktop.
Haskell RebindableSyntax example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RebindableSyntax #-} | |
import Prelude hiding ((>>)) | |
data Config = Config { depth :: Int, width :: Int } | |
printInfo :: Config -> IO () | |
printInfo config = mapM_ putStrLn $ do | |
"************** INFORMATION **************" | |
"Welcome to the Hydraulic Press Channel." | |
"Here is your configuration:" | |
"" | |
" depth: " ++ show (depth config) | |
" width: " ++ show (width config) | |
"" | |
"*****************************************" | |
[] where (>>) = (:) | |
main :: IO () | |
main = printInfo defaultConfig | |
defaultConfig :: Config | |
defaultConfig = Config { depth = 5, width = 10 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try it out: