Skip to content

Instantly share code, notes, and snippets.

@dariooddenino
Created February 19, 2019 16:04
Show Gist options
  • Save dariooddenino/5eaf9c7426e18e5277c1a5ad05a64dbd to your computer and use it in GitHub Desktop.
Save dariooddenino/5eaf9c7426e18e5277c1a5ad05a64dbd to your computer and use it in GitHub Desktop.
type MyRecord = { foo :: String, bar :: Instant }
decodeinsomeway :: Int -> Either String Instant
decodeinsomeway i = eitherturnintintoinstantornot i
decodeMyRecord :: Json -> Either String MyRecord
decodeMyRecord json = do
tempRecord <- decodeJson json -- this is decoded as { foo :: String, bar :: Int }
newField <- decodeinsomeway tempRecord.bar
pure $ tempRecord { bar = newField }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment