[Haskell-cafe] Stack ADT?
michael rice
nowgate at yahoo.com
Thu Feb 4 12:27:23 EST 2010
I was looking here: http://www.haskell.org/haskellwiki/Abstract_data_type
I haven't done much with modules so I'm guessing what you've provided is the guts of StackImpl, to hide the implementation?
Thanks,
Michael
--- On Thu, 2/4/10, Sebastian Fischer <sebf at informatik.uni-kiel.de> wrote:
From: Sebastian Fischer <sebf at informatik.uni-kiel.de>
Subject: Re: [Haskell-cafe] Stack ADT?
To: "haskell-cafe Cafe" <haskell-cafe at haskell.org>
Date: Thursday, February 4, 2010, 12:16 PM
On Feb 4, 2010, at 6:07 PM, michael rice wrote:
> Can't find a Stack datatype on Hoogle? Where should I look?
Could not find one on Hackage either. Probably because its so easy to handcraft your own:
newtype Stack a = Stack [a]
emptyStack = Stack []
isEmptyStack (Stack xs) = null xs
push x (Stack xs) = Stack (x:xs)
pop (Stack (_:xs)) = Stack xs
top (Stack (x:_)) = x
I saw such stacks in Haskell only for educational purposes. Usually, people seem to use lists directly.
Sebastian
--Underestimating the novelty of the future is a time-honored tradition.
(D.G.)
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100204/885cfc14/attachment.html
More information about the Haskell-Cafe
mailing list