Created
February 19, 2019 16:04
-
-
Save dariooddenino/5eaf9c7426e18e5277c1a5ad05a64dbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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