<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-style-span" style="font-size: 13px; border-collapse: collapse; "><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">data Stack a   = EmptyStk | Stk a (Stack a)</font></span></blockquote>
<div><br></div>I find it amusing that the book defined a type that is exactly isomorphic to the standard list (EmptyStk === [] and Stk === (:)). I guess it&#39;s just for clarity?<br><br><div class="gmail_quote">On Thu, Feb 4, 2010 at 12:29 PM, Casey Hawthorne <span dir="ltr">&lt;<a href="mailto:caseyh@istar.ca">caseyh@istar.ca</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Thu, 4 Feb 2010 09:07:28 -0800 (PST), you wrote:<br>
<br>
&gt;Can&#39;t find a Stack datatype on Hoogle? Where should I look?<br>
&gt;<br>
&gt;Michael<br>
&gt;<br>
<br>
<br>
</div>From &quot;Algorithms: a functional programming approach&quot;<br>
Second edition<br>
Fethi Rabhi<br>
Guy Lapalme<br>
<br>
<br>
data Stack a                    = EmptyStk<br>
                                                                        | Stk a (Stack a)<br>
<br>
push x s                                        = Stk x s<br>
<br>
pop EmptyStk                    = error &quot;pop from an empty stack&quot;<br>
pop (Stk _ s)           = s<br>
<br>
top EmptyStk                    = error &quot;top from an empty stack&quot;<br>
top (Stk x _)           = x<br>
<br>
emptyStack                              = EmptyStk<br>
<br>
stackEmpty EmptyStk = True<br>
stackEmpty _                            = False<br>
<br>
<br>
<br>
<br>
newtype Stack a         = Stk [a]<br>
<br>
push x (Stk xs)         = Stk (x:xs)<br>
<br>
pop (Stk [])                    = error &quot;pop from an empty stack&quot;<br>
pop (Stk (_:xs))        = Stk xs<br>
<br>
top (Stk [])                    = error &quot;top from an empty stack&quot;<br>
top (Stk (x:_))         = x<br>
<br>
emptyStack                              = Stk []<br>
<br>
stackEmpty (Stk []) = True<br>
stackEmpty (Stk _ ) = False<br>
<br>
<br>
--<br>
Regards,<br>
<font color="#888888">Casey<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>