Skip to content

Instantly share code, notes, and snippets.

@SimonAlling
Last active May 23, 2020 16:25
Show Gist options
  • Save SimonAlling/00e728961c3f3f8cbb9daa32cc1d8b20 to your computer and use it in GitHub Desktop.
Save SimonAlling/00e728961c3f3f8cbb9daa32cc1d8b20 to your computer and use it in GitHub Desktop.
Haskell RebindableSyntax example
{-# 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 }
@SimonAlling
Copy link
Author

Try it out:

$ runhaskell RebindableSyntax.hs

@dpwiz
Copy link

dpwiz commented Apr 14, 2019

Yeah, but...

@tripulse
Copy link

Hydraulic Press? You're stuck in 2016, literally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment