<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: GADTs in Haskell 98</title>
	<atom:link href="http://martijn.van.steenbergen.nl/journal/2009/11/12/gadts-in-haskell-98/feed/" rel="self" type="application/rss+xml" />
	<link>http://martijn.van.steenbergen.nl/journal/2009/11/12/gadts-in-haskell-98/</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Mon, 13 May 2013 18:02:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
	<item>
		<title>By: Bob Atkey</title>
		<link>http://martijn.van.steenbergen.nl/journal/2009/11/12/gadts-in-haskell-98/#comment-329</link>
		<dc:creator>Bob Atkey</dc:creator>
		<pubDate>Fri, 13 Nov 2009 12:28:15 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=447#comment-329</guid>
		<description>Unfortunately, not all GADTs can be expressed faithfully in this way, due to &quot;leakage&quot; between the types used for representation and the type parameters in the constructors. An example is given in Section 4 of the paper &quot;Unembedding domain-specific languages&quot; (available from my home page), where we called them &quot;exotically typed terms&quot;. The example in the paper involves Higher-Order Abstract Syntax, but it still happens when you have no negative occurrences of the type variable: a simple example is a GADT for representing typed S and K combinators with application. The problem seems to occur when there is a type parameter inside a GADT term that does not appear on the outside of the term.

Fortunately, all is not lost (if you allow yourself Haskell98 + Rank-2 polymorphism + existential types). One can still represent the Equality GADT as a type class (with single method refl :: f a a), and then use Neil Ghani and Patty Johann&#039;s decomposition of GADTs into normal algebraic datatypes plus the equality GADT. Oleg did this in OCaml in a post to the OCaml mailing list. A disadvantage of this approach is that you have to apply the type equalities by hand.</description>
		<content:encoded><![CDATA[<p>Unfortunately, not all GADTs can be expressed faithfully in this way, due to &#8220;leakage&#8221; between the types used for representation and the type parameters in the constructors. An example is given in Section 4 of the paper &#8220;Unembedding domain-specific languages&#8221; (available from my home page), where we called them &#8220;exotically typed terms&#8221;. The example in the paper involves Higher-Order Abstract Syntax, but it still happens when you have no negative occurrences of the type variable: a simple example is a GADT for representing typed S and K combinators with application. The problem seems to occur when there is a type parameter inside a GADT term that does not appear on the outside of the term.</p>
<p>Fortunately, all is not lost (if you allow yourself Haskell98 + Rank-2 polymorphism + existential types). One can still represent the Equality GADT as a type class (with single method refl :: f a a), and then use Neil Ghani and Patty Johann&#8217;s decomposition of GADTs into normal algebraic datatypes plus the equality GADT. Oleg did this in OCaml in a post to the OCaml mailing list. A disadvantage of this approach is that you have to apply the type equalities by hand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chung-chieh Shan</title>
		<link>http://martijn.van.steenbergen.nl/journal/2009/11/12/gadts-in-haskell-98/#comment-328</link>
		<dc:creator>Chung-chieh Shan</dc:creator>
		<pubDate>Fri, 13 Nov 2009 08:45:36 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=447#comment-328</guid>
		<description>Jacques Carette and Oleg Kiselyov and I wrote up some more things that one can do (and have been done) in this way: &lt;a href=&quot;http://www.cs.rutgers.edu/~ccshan/tagless/jfp.pdf&quot; rel=&quot;nofollow&quot;&gt;&quot;Finally
tagless, partially evaluated: Tagless staged interpreters for simpler
typed languages.&quot; Journal of Functional Programming 19(5):509-543.&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Jacques Carette and Oleg Kiselyov and I wrote up some more things that one can do (and have been done) in this way: <a href="http://www.cs.rutgers.edu/~ccshan/tagless/jfp.pdf" rel="nofollow">&#8220;Finally<br />
tagless, partially evaluated: Tagless staged interpreters for simpler<br />
typed languages.&#8221; Journal of Functional Programming 19(5):509-543.</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brent Yorgey</title>
		<link>http://martijn.van.steenbergen.nl/journal/2009/11/12/gadts-in-haskell-98/#comment-327</link>
		<dc:creator>Brent Yorgey</dc:creator>
		<pubDate>Thu, 12 Nov 2009 17:58:08 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=447#comment-327</guid>
		<description>Aha, I never realized you could encode GADTs as type classes like this!  Simple once you see it.  Thanks for sharing!</description>
		<content:encoded><![CDATA[<p>Aha, I never realized you could encode GADTs as type classes like this!  Simple once you see it.  Thanks for sharing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jj</title>
		<link>http://martijn.van.steenbergen.nl/journal/2009/11/12/gadts-in-haskell-98/#comment-326</link>
		<dc:creator>jj</dc:creator>
		<pubDate>Thu, 12 Nov 2009 14:08:10 +0000</pubDate>
		<guid isPermaLink="false">http://martijn.van.steenbergen.nl/journal/?p=447#comment-326</guid>
		<description>What I like about GADTs is not what they let us do, but what they stop us from doing. The standard GADT example you show makes it impossible to produce an ill-typed Term (not term, Term) without using error or naughty recursion. Using the type class TermC, you have to either give up pattern matching or type safety.</description>
		<content:encoded><![CDATA[<p>What I like about GADTs is not what they let us do, but what they stop us from doing. The standard GADT example you show makes it impossible to produce an ill-typed Term (not term, Term) without using error or naughty recursion. Using the type class TermC, you have to either give up pattern matching or type safety.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
