by exceptione · 2y ago · 0 comments
Sometimes you really want to make sure someone is not going to introduce billion dollar bugs, by making the type different from the underlying representation. In Haskell that would be sth like
newtype Temperature = Int
At other times, you just want to document in stead of forcing semantics. A contrived example: type AgeMin = Int
type AgeMax = Int
isAdmissible :: AgeMin -> AgeMax -> Bool
isAdmissible :: Int -> Int -> Bool // less clear val is_admissible : min_age:int -> max_age:int -> boolAlso, if you later decide that an Age should not be int, but a string, you wont miss it in refactoring whereas in your example you don't have that facility.