Skip to content

Instantly share code, notes, and snippets.

@reinh
Last active August 29, 2015 14:03
Show Gist options
  • Save reinh/ea7afa7187139e64820d to your computer and use it in GitHub Desktop.
Save reinh/ea7afa7187139e64820d to your computer and use it in GitHub Desktop.
data Thing = Thing
{ _foo :: Int
, _bar :: String }
buildFoo :: Other -> Thing
buildfoo = Thing <$> buildFoo
<*> buildBar
where buildFoo :: Other -> Int
buildFoo = undefined
buildBar :: Other -> String
buildBar = undefined
buildThingThatMightError :: Other -> Either String Thing
buildThingThatMightError = undefined -- ?????
where buildFoo :: Other -> Either String Int
buildFoo = undefined
buildBar :: Other -> Either String String
buildBar = undefined
-- Switch to Either applicative like this
buildThingThatMightError' other = Thing <$> buildFoo other
<*> buildBar other
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment