[Haskell-cafe] Investigating single-letter type variables

Will Yager will.yager at gmail.com
Fri Aug 11 01:08:53 UTC 2017


Without actually addressing the question, here are some rules of thumb I use for identifying and choosing type variables:

a - whatever. Usually return type, thing inside functor, etc. If you need more than one, you can use b/c. 

m - usually monad, sometimes just applicative. Can use n if you need more. 

s - state or state token

f - usually functor or more. Can use t if you need more. 

e - error 

i - Index 

r/o - "Result" or "Output" with no real consistency on typeclass constraints.

k/v - Key/Value

w - result monoid

These are by no means particularly hard and fast rules, but they're the first things I jump to when I see a type variable. I do try to use more descriptive names if I don't think it will be fairly obvious from context. 

--Will

> On Aug 10, 2017, at 4:29 PM, Jeffrey Brown <jeffbrown.the at gmail.com> wrote:
> 
> 
>     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.
> 


More information about the Haskell-Cafe mailing list