Proposal: unify constant functors
wren ng thornton
wren at freegeek.org
Fri May 4 01:46:12 CEST 2012
On 5/3/12 7:23 PM, Henning Thielemann wrote:
>
> On Thu, 3 May 2012, wren ng thornton wrote:
>
>> Indeed. I'm fine with Const (we don't call the value-level function k,
>> afterall), but Constant is just too much. Ditto for the excessively
>> lengthy naming of the identity functor. For things this basic and this
>> widely used, all that verbosity gives me flashbacks to coding in Java.
>
> It's not all bad in imperative languages ...
There's a difference between imperative programming in general, and Java
programming in particular ;)
> Do you really use "Identity" everywhere? I use it only implicitly as
> part of transformers:State monads and friends.
Everywhere would be an exaggeration, but I do use it rather frequently.
It helps reduce boilerplate when you want both pure and
monadic/functorial (i.e., *->*) versions of things and don't care too
much about performance. It's the monad of choice when instantiating
rank-2 quantifiers. It's a primitive of generic programming with
polynomial types, as Conor mentioned. etc.
> Identity's meaning is immediately clear. 'Ident' or 'Id' could also be
> 'identifier'.
>
> 'Const' could also mean 'constructor'.
>
> I also prefer 'Integer' to \mathbb{Z} and 'Rational' to \mathbb{Q}.
Should we rename 'id' to 'identity' and 'const' to 'constant' then? The
purported confusion is exactly the same since there must be values to
inhabit your identity and constructor types. If anything, you're only
making an argument for K and I in lieu of Const and Id.
I'm fine with Integer, in virtue of the fact that it's unbounded and we
have Int for the bounded version, so the lengthiness of the name
actually conveys valuable information. Rational is in a similar position
in virtue of the Ratio type it's an alias for. In mathematics I refer to
those types often enough that having the names \mathbb{N}, \mathbb{Z},
\mathbb{Q}, \mathbb{R}, \mathbb{C},... is extremely helpful for brevity
and clarity. In programming, I use them infrequently enough (compared to
other types) that little would be gained by such brevity.
--
Live well,
~wren
More information about the Libraries
mailing list