
The following probably captures community practice:
a) If the type is truly arbitrary, such that there is no meaningful info to
add beyond the positions it occurs in the type, then give it an arbitrary
name, like 'a', 'b', or 'c'.
b) If there is a convention associated with a type or class that occurs in
the type signature, to which the type variable is a parameter, then use
that (usually one-letter) name.
c) Otherwise, use a longer name.
You seem to be making the case that (b) is confusing. You may be right,
and I have no particular desire to defend the current practice. But if
you're wondering where one would be expected to find the meaning, that's
it: find the primary type (or class) to which it's a parameter, and there
is usually a convention set forth there.
On Thu, Aug 10, 2017 at 3:29 PM, Jeffrey Brown
Haskellers tend to use uninformative single-letter type variables. A case in point:
Megaparsec> :i ParsecT
type role ParsecT nominal nominal representational representational newtype ParsecT e s (m :: * -> *) a ...
I've gotten used to the conventions that "a" stands for anything and "m" stands for monad -- but without digging into the code it wasn't initially obvious to me whether "s" stood for stream or state.
Single-letter type variables don't seem to always be the standard, though:
Megaparsec> :i between between :: Applicative m => m open -> m close -> m a -> m a -- Defined in ‘Control.Applicative.Combinators’
My questions are: (1) Are the brevity gains worth the confusion costs? (2) If I'm looking at a new library for the first time and trying to figure out what a type variable stands for, is there a canonical way to do it? Flailing through documentation at random? Unifying types by hand?
-- Jeff Brown | Jeffrey Benjamin Brown Website https://msu.edu/~brown202/ | Facebook https://www.facebook.com/mejeff.younotjeff | LinkedIn https://www.linkedin.com/in/jeffreybenjaminbrown(spammy, so I often miss messages here) | Github https://github.com/jeffreybenjaminbrown
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.