Skip to content

Instantly share code, notes, and snippets.

@AnthonySuper
Created October 21, 2021 00:10
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 AnthonySuper/a51be1414a9f63305fdcc9ec334f6299 to your computer and use it in GitHub Desktop.
Save AnthonySuper/a51be1414a9f63305fdcc9ec334f6299 to your computer and use it in GitHub Desktop.
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