type Dog = Dog String
dogName1 dog =
case dog of
Dog name ->
name
dogName2 (Dog name) ->
name
dogName1
and dogName2
are equivalent. Note that this only works for ADTs that have a single constructor.
type alias Pet =
{ name: String
, weight: Float
}
render : Pet -> String
render ({name, weight} as pet) =
(findPetEmoji pet) ++ " " ++ name ++ " weighs " ++ (toString weight)
findPetEmoji : Pet -> String
findPetEmoji pet =
Debug.crash "Implementation TBD"
Here we deconstruct a record and also get a reference to the undeconstructed record.