<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Looks a lot like Church encoding to me:</div><div><br></div><div><a href="http://en.wikipedia.org/wiki/Church_encoding">http://en.wikipedia.org/wiki/Church_encoding</a></div><div><br></div><div>It was first discovered by the guy who invented lambda calculus :p</div><div><br></div><div>- jeremy</div><br><div><div>On Nov 1, 2010, at 5:28 PM, Andrew Coppin wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"> <div bgcolor="#ffffff" text="#000000">    The other day, I accidentally came up with this:<br>    <br>    <pre class="sourceCode haskell"><code><span class="ot">{-# LANGUAGE RankNTypes #-}</span>

<span class="kw">type</span> <span class="dt">Either</span> x y <span class="fu">=</span> forall r<span class="fu">.</span> (x -&gt; r) -&gt; (y -&gt; r) -&gt; r

left :: x -&gt; <span class="dt">Either</span> x y
left x f g <span class="fu">=</span> f x

right :: y -&gt; <span class="dt">Either</span> x y
right y f g <span class="fu">=</span> g y

</code></pre>    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?<br>    <br>  </div>  _______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>http://www.haskell.org/mailman/listinfo/haskell-cafe<br></blockquote></div><br></body></html>