-
-
Save AnthonySuper/a51be1414a9f63305fdcc9ec334f6299 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
data Person | |
= Person | |
{ firstName :: String | |
, lastName :: String | |
, idCode :: String | |
} | |
-- | Problem 1: screw up what field is which: | |
serializer | |
= Person | |
<$> objectKey "firstName" lastName | |
<*> objectKey "lastName" firstName | |
<*> objectKey "idCode" idCode | |
-- | Problem 2: non-bidirectional fmap | |
-- | |
-- This isn't "completely wrong" but it does break the expectation that `toJSON . fromJSON = id` | |
-- | |
-- ...Which isn't true in the library in general but it's explicitly not true you know | |
serializer | |
= Person | |
<$> objectKey "firstName" firstName | |
<*> fmap convertSpacesToDashesForBusinessLogicReasons (objectKey "lastName" lastName) | |
<*> objectKey "idCode" idCode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment