I believe this comes from the usual practice of writing
f :: Type1 -> ... -> Typen -> Result f x1 ... xn = someResult
where we have exactly n function arrows in type and exactly n arguments on the left side of the equation. This simplifies the comparison of types and formal parameters.
If Result is a type alias for a function, we can write
f :: Type1 -> ... -> Typen -> Result f x1 ... xn y = something
or
f :: Type1 -> ... -> Typen -> Result f x1 ... xn = \y -> something
The latter follows the convention above: n arrows, n variables on the left. In addition, on the right side, we have something like Result , which simplifies the definition. The first one is not instead, and you can skip the extra argument when reading code quickly.
In addition, this style simplifies converting Result to newtype instead of a type alias:
newtype Result = R (... -> ...) f :: Type1 -> ... -> Typen -> Result f x1 ... xn = R $ \y -> something
The published item :: Parser Char code is an instance of this style when n=0 .
source share