|
|
|
|
|
by asQuirreL
3631 days ago
|
|
The article seems to advocate type synonyms like the following: type Case = String -> String
-- ...
type Announcer = String -> IO String
I would argue that these are actually much worse than not having type synonyms at all.(String -> String) functions could do anything to your query parameter and text, the type is too coarse, and the inhabitants too opaque for us to reason about them easily. Naming the type suggests the problem is solved without actually having solved it. It is like finding a hole in the ground, and covering it with leaves, so you don't have to look at it anymore. You are literally making a trap for the next person to come this way. In an ideal world you would be able to use refinements to say that you want any (f :: String -> String) such that `toUpper . f = toUpper` but without such facilities, I think I may just settle for: newtype Case = CaseSensitive Bool
Sometimes, your type really does only have two inhabitants. |
|
Also, sometimes types you thought only had two inhabitants get a third one added later, which this facilitates.