Proposal: unify constant functors

Andreas Abel andreas.abel at
Fri May 4 16:44:23 CEST 2012

As I see, we have run in a discussion about identifiers and whether to 
abbreviate.  While in math every defined symbol should have at most 3 
letters, in information technology one tends to spell out names because 
there is such an abundant amount of concepts.  [And, of course, because 
typing on a keyboard is much faster than handwriting on a chalkboard.]

I think libraries, and in particular standard libraries should prefer to 
spell out identifiers, unless the abbreviation has secured its status 
due to a long tradition already.

I do not see that for 'Const'.

P.S.: I'd prefer to use Const for my own, internal/throw-away data 
types, this is why I talked about "import conflicts" in my previous message.

P.P.S.:  All of discussion would be superfluous if import statements had 
a renaming option like in Agda.

   open import Data.Functor.Constant renaming (Constant to K)

Maybe that could be a feature of future Haskell as well?

On 04.05.12 2:12 AM, wren ng thornton wrote:
> On 5/3/12 7:18 PM, Henning Thielemann wrote:
>> On Thu, 3 May 2012, wren ng thornton wrote:
>>> I think that Const/Constant should be in base because it's such a
>>> primitive thing and used all over the place. Other than that, I was
>>> mainly aiming for minimal breakage in resolving the duplication.
>> I just wanted to ask, where you need it. I have never used it. How can I
>> improve my code with it?
> Again, it's primitive for generic programming with polynomial types. I
> often use it to lift types of kind * into types of kind *->* which is
> frequently necessary for generic programming. The code I was working on
> when I noticed the duplication uses it to instantiate a rank-2
> quantifier in order to get rid of an existential type.
>> Independent from this question I am concerned with putting so much into
>> 'base'. 'transformers' can be updated independent from the compiler, and
>> 'base' cannot. Thus for me, 'Constant' in 'transformers' has the right
>> name (understandable to the casual user) in the right place.
> Since transformers is in the Haskell Platform, it doesn't especially
> matter to me. But this is the sort of thing that belongs in an extended
> prelude, much like Data.List and other modules from before the era of
> hierarchical module names. The code for the constant functor isn't
> liable to change by much, the only reason for it to change would be to
> add new instances for new classes in base (since other classes could
> provide the instance when defining the class itself), so the fact that
> it's in a boot library isn't much of a burden. Whether GHC actually uses
> it internally may settle the matter, however.
> Even the casual user will recognize Const as a capitalized version of
> the const function from the Prelude.

Andreas Abel  <><      Du bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.abel at

More information about the Libraries mailing list