[Haskell-cafe] Mysterious fact

Andrew Coppin andrewcoppin at btinternet.com
Mon Nov 1 18:28:03 EDT 2010


The other day, I accidentally came up with this:

|{-# LANGUAGE RankNTypes #-}

type  Either  x y=  forall r.  (x ->  r) ->  (y ->  r) ->  r

left :: x ->  Either  x y
left x f g=  f x

right :: y ->  Either  x y
right y f g=  g y

|

This is one example; it seems that just about any algebraic type can be 
encoded this way. I presume that somebody else has thought of this 
before. Does it have a name?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20101101/1433ecc3/attachment.html


More information about the Haskell-Cafe mailing list