[Haskell-cafe] lifting restrictions on defining instances

porges at porg.es porges at porg.es
Fri Jul 17 23:08:04 EDT 2009


[Ack, missed the reply-all button...]

This was part of my motivation behind the 'removing polymorphism from Functor' thing... to select a different parameter we'd essentially need type-level lambdas... I'll use 'Λ' (capital lambda) for it:

  instance Functor (Λ a. X a b) where
      fmap f (X a b) = X (f a) b

We don't have these [1], but we *do* have type families, which are kind of like type-level lambdas turned 'inside out' (at least to my eyes), so my idea was to separate this out:

  type family Point :: *
  type instance Point (X a b) = a

  class Functor f where
      fmap :: (Point f -> Point f) -> f -> f

Here I began to run into problems which are a bit irrelevant to this discussion :)

[1]: I'm not sure of the exact connection, but see, e.g. Oleg's construction of computation at the type level (http://okmij.org/ftp/Haskell/TypeLC.lhs), wherein he notes the "primary role of type application rather than that of abstraction".

- George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 908 bytes
Desc: OpenPGP digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090717/e22b84fd/signature.bin


More information about the Haskell-Cafe mailing list