type aliases and Id

Ravi Nanavati ravi at bluespec.com
Mon Mar 19 15:26:20 EDT 2007

On 3/19/07, Ian Lynagh <igloo at earth.li> wrote:
> I'd really like to be able to define an eta-reduced Id; I see two
> possibilities:
> * Allow "type Id =" (I prefer this to "type Id" as I think we are more
>   likely to want to use the latter syntax for something else later on).
> * Implementations should eta-reduce all type synonyms as much as
>   possible, e.g.
>       type T a b c d = X a b Int c d
>   is equivalent to
>       type T a b     = X a b Int
>   and
>       type Id a = a
>   is equivalent to a type that cannot be expressed directly.
> Any opinions?

A third possibility is to have "Id" be a special primitive type constructor
of kind * -> * that implementations handle internally. If you wanted to give
it different name you could use an eta-reduced type synonym for that, of

That's the approach I took when I needed an identity type function in the
Bluespec compiler, and that worked out reasonably well. Part of the reason
that worked out, though, is that we already had a normalization point during
typechecking where certain special type constructors (related to numeric
types) were cleaned out, so adding Id just extended that a little.

I don't know whether adding such a constructor would be an equally simple
change for Haskell implementations. And there's the separate argument that
requiring eta-reduction of all type synonyms might be an interesting new
feature in its own right (since I think you can say other new things beyond
type Id a = a).

 - Ravi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-prime/attachments/20070319/f7d39f82/attachment.htm

More information about the Haskell-prime mailing list