<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments for Caleb Case</title>
	<atom:link href="http://calebcase.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://calebcase.com</link>
	<description></description>
	<lastBuildDate>Sat, 04 Dec 2010 18:26:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>Comment on Ornery Types and Their Associated Grammars by calebcase</title>
		<link>http://calebcase.com/2010/12/02/ornery-types-and-their-associated-grammars/#comment-4</link>
		<dc:creator><![CDATA[calebcase]]></dc:creator>
		<pubDate>Sat, 04 Dec 2010 18:26:27 +0000</pubDate>
		<guid isPermaLink="false">http://calebcase.com/?p=40#comment-4</guid>
		<description><![CDATA[Yet another solution to add to the mix:

{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE GADTs #-}

data A
data B
data C
data D

data L

data AST t where
        A :: AST A
        B :: AST B
        C :: [AST B] -&gt; AST C
        D :: [AST L] -&gt; AST D
        L :: AST t -&gt; AST L

I didn&#039;t think it was possible, but apparently a GADT &#039;forall&#039; can be unpacked (as opposed to the existential which could not). Which makes this possible:

tostr :: AST L -&gt; [Char]
tostr (L A) = &quot;A&quot;
tostr (L B) = &quot;B&quot;
tostr (L _) = &quot;C or D&quot;

&gt; map tostr $ [L A, L B, L A, L $ C [B, B]]
[&quot;A&quot;,&quot;B&quot;,&quot;A&quot;,&quot;C or D&quot;]

Inspired by this post about attribute grammars: http://pseudo.fixme.fi/~opqdonut/blog/Attribute_Grammars__GADTs_and_MonadFix__part_2_.html]]></description>
		<content:encoded><![CDATA[<p>Yet another solution to add to the mix:</p>
<p>{-# LANGUAGE EmptyDataDecls #-}<br />
{-# LANGUAGE GADTs #-}</p>
<p>data A<br />
data B<br />
data C<br />
data D</p>
<p>data L</p>
<p>data AST t where<br />
        A :: AST A<br />
        B :: AST B<br />
        C :: [AST B] -&gt; AST C<br />
        D :: [AST L] -&gt; AST D<br />
        L :: AST t -&gt; AST L</p>
<p>I didn&#8217;t think it was possible, but apparently a GADT &#8216;forall&#8217; can be unpacked (as opposed to the existential which could not). Which makes this possible:</p>
<p>tostr :: AST L -&gt; [Char]<br />
tostr (L A) = &#8220;A&#8221;<br />
tostr (L B) = &#8220;B&#8221;<br />
tostr (L _) = &#8220;C or D&#8221;</p>
<p>&gt; map tostr $ [L A, L B, L A, L $ C [B, B]]<br />
["A","B","A","C or D"]</p>
<p>Inspired by this post about attribute grammars: <a href="http://pseudo.fixme.fi/~opqdonut/blog/Attribute_Grammars__GADTs_and_MonadFix__part_2_.html" rel="nofollow">http://pseudo.fixme.fi/~opqdonut/blog/Attribute_Grammars__GADTs_and_MonadFix__part_2_.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Ornery Types and Their Associated Grammars by calebcase</title>
		<link>http://calebcase.com/2010/12/02/ornery-types-and-their-associated-grammars/#comment-3</link>
		<dc:creator><![CDATA[calebcase]]></dc:creator>
		<pubDate>Sat, 04 Dec 2010 17:35:16 +0000</pubDate>
		<guid isPermaLink="false">http://calebcase.com/?p=40#comment-3</guid>
		<description><![CDATA[Trying and failing ;o] That solution is ok, but as the grammar&#039;s complexity increases more boilerplate L* constructors will be needed (and continues to get worse the more collection types you need).]]></description>
		<content:encoded><![CDATA[<p>Trying and failing ;o] That solution is ok, but as the grammar&#8217;s complexity increases more boilerplate L* constructors will be needed (and continues to get worse the more collection types you need).</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Ornery Types and Their Associated Grammars by Luke</title>
		<link>http://calebcase.com/2010/12/02/ornery-types-and-their-associated-grammars/#comment-2</link>
		<dc:creator><![CDATA[Luke]]></dc:creator>
		<pubDate>Fri, 03 Dec 2010 01:46:52 +0000</pubDate>
		<guid isPermaLink="false">http://calebcase.com/?p=40#comment-2</guid>
		<description><![CDATA[I liked your final solution before you started trying to get all magical:

type A = A
type B = B
type C = C [B]
type D = D [L]
type L = LA A &#124; LB B &#124; LC C &#124; LD D

I find this solution to very directly and elegantly model the problem description, not ugly at all.]]></description>
		<content:encoded><![CDATA[<p>I liked your final solution before you started trying to get all magical:</p>
<p>type A = A<br />
type B = B<br />
type C = C [B]<br />
type D = D [L]<br />
type L = LA A | LB B | LC C | LD D</p>
<p>I find this solution to very directly and elegantly model the problem description, not ugly at all.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

