[Haskell-cafe] Re: Re: nested maybes

Yitzchak Gale gale at sefer.org
Wed Feb 7 18:44:17 EST 2007

Mikael Johansson wrote:
>>>  A way to categorify elements of objects in a
>>> cartesian closed category (such as that that
>>> sufficiently restricted Haskell takes place in)
>>>  are to view entities of type A as maps () -> A.

Dan Weston wrote:
>> This rather inconveniently clashes with the fact that
>> A and () -> A are two distinct types in Haskell.

Not really. It's just that in the terminology of category
theory, there is no direct way to talk about "elements"
of an object. In general, objects do not need
to be sets, so there is no notion of an "element".

In our case, where the objects - Haskell types - happen
to be sets, we get our hands on "elements" of an object by
using the trick of taking elements of the set of morphisms
from () to the type.

With functions, we have the opposite situation. Functions
are first-class in Haskell. So for each function of type
A -> B there are two representations in the category:
as an "element" of the object A->B, and as an element
of the set of morphisms from A to B.

>> I take it by your argument that curried and uncurried
>> functions, being isomorphic, are represented by the
>> same object in your category?

No. (A,B)->C and A->B->C are two different types, so
they are two different objects in the category. The two
objects are isomorphic via curry and uncurry.


More information about the Haskell-Cafe mailing list