Skip to content

Instantly share code, notes, and snippets.

@pasberth
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pasberth/c991e4ffb37b9878ee26 to your computer and use it in GitHub Desktop.
Save pasberth/c991e4ffb37b9878ee26 to your computer and use it in GitHub Desktop.
-- ok
main :: IO ()
main = do
let x = Nothing
case x of
Just 0 -> return 0
Nothing -> return 1
case x of
Just "a" -> return 2
Nothing -> return 3
return ()
-- b.hs:5:10:
-- No instance for (Num [Char]) arising from the literal ‘0’
-- In the pattern: 0
-- In the pattern: Just 0
-- In a case alternative: Just 0 -> return 0
main :: IO ()
main = do
x <- return Nothing
case x of
Just 0 -> return 0
Nothing -> return 1
case x of
Just "a" -> return 2
Nothing -> return 3
return ()
{-# LANGUAGE Rank2Types #-}
-- ok
f :: (forall a. Maybe a) -> IO ()
f x = do
case x of
Just 0 -> return 0
Nothing -> return 1
case x of
Just "a" -> return 2
Nothing -> return 3
return ()
main :: IO ()
main = f Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment