Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- === (Correct) Examples ===
- Examples are in the form:
- {{{#!hs
- implicitParenthesis -- New syntax
- explicitParenthesis -- Old syntax
- }}}
- Call {{{idM :: Monad m => m a -> m a}}} as {{{idM :: IO String -> IO String}}}.
- {{{#!hs
- idM do
- putStrLn "What's my name?"
- getLine
- idM (do { putStrLn "What's my name?"; getLine; })
- }}}
- Create function {{{whatsMyName :: Maybe String -> String}}}.
- {{{#!hs
- whatsMyName x = id case x of
- Just name = "My name is " ++ name
- Nothing = "What's my name?"
- whatsMyName x = id (case x of { Just name = "My name is " ++ name; Nothing = "What's my name?"; })
- }}}
- Another example using {{{let}}} and {{{if-then-else}}}.
- {{{#!hs
- main = putStrLn
- (++)
- "I've been tryna work it out... The square root of 69 is 8 something, right? "
- let
- eight_something = 8.306623862918075
- in if sqrt 69 == eight_something
- then "Yeah"
- else "Oh na na"
- main = putStrLn ((++) "I've been tryna work it out... The square root of 69 is 8 something, right? " (let eight_something = 8.306623862918075 in (if sqrt 69 == eight_something then "Yeah" else "Oh na na"))
- }}}
- === Incorrect examples ===
- {{{#!hs
- f do
- putStrLn "This won't work..."
- True
- f (do { putStrLn "This won't work..."; True; })
- }}}
- {{{#!hs
- f
- do
- putStrLn "This won't work..."
- True -- Indented by extra space
- f (do { putStrLn "This won't work..."; True; })
- }}}
Add Comment
Please, Sign In to add comment