Skip to content

Instantly share code, notes, and snippets.

@coreyhaines coreyhaines/Id.elm
Last active Jul 8, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.