Skip to content

Instantly share code, notes, and snippets.

@stevenfontanella
Created January 4, 2021 01:55
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 stevenfontanella/8ff3c45db26c6de58c0ee891bcfeda4c to your computer and use it in GitHub Desktop.
Save stevenfontanella/8ff3c45db26c6de58c0ee891bcfeda4c to your computer and use it in GitHub Desktop.
either1 :: IO (Either String Int)
either1 = undefined
either2 :: IO (Either String Int)
either2 = undefined
main1 :: IO Int
main1 = do
-- to be clear I do not want MonadFail here
-- i.e. I don't want to use
-- Right a <- either1
a <- fromRight <$> either1
b <- fromRight <$> either2
pure (a + b)
{-
• Couldn't match type ‘Either a0 (Either String Int)
-> Either String Int’
with ‘Int’
Expected type: IO Int
Actual type: IO
(Either a0 (Either String Int) -> Either String Int)
• In a stmt of a 'do' block: pure (a + b)
In the expression:
do a <- fromRight <$> either1
b <- fromRight <$> either2
pure (a + b)
In an equation for ‘main1’:
main1
= do a <- fromRight <$> either1
b <- fromRight <$> either2
pure (a + b)
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment