Skip to content

Instantly share code, notes, and snippets.

@coreyhaines
Last active July 8, 2017 18:49
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 coreyhaines/5f2a8d15de99ce91adbb10ac855172b1 to your computer and use it in GitHub Desktop.
Save coreyhaines/5f2a8d15de99ce91adbb10ac855172b1 to your computer and use it in GitHub Desktop.
The Id type I like
type Id
= Id Int
idIs : Id -> { a | id : Id } -> Bool
idIs thisId =
idFieldIs .id thisId
idFieldIs : (a -> Id) -> Id -> a -> Bool
idFieldIs idField thisId =
idField >> (==) thisId
idValue : Id -> Int
idValue (Id id) =
id
idDecoder : Json.Decode.Decoder Id
idDecoder =
Json.Decode.map Id Json.Decode.int
idsDecoder : Decoder (List Id)
idsDecoder =
Json.Decode.list idDecoder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment