[Haskell-beginners] Checking if a Stack is Empty

Brandon Allbery allbery.b at gmail.com
Tue Mar 12 15:57:51 CET 2013

On Tue, Mar 12, 2013 at 10:48 AM, doaltan <doaltan at yahoo.co.uk> wrote:

> I have this stack data structure :
> data Stack = Empty | Element Char Stack deriving Show
> I want to check if it is equal to "Empty"
> When I try something like this :
> "a = Empty" or "a = (Empty)" in a haskell file and then write this on ghci
> : "a = Empty"

Have you studied any Haskell tutorials yet? Usually you want to use a
pattern match, not an equality test; if you must for some reason use an
equality test, you need an Eq instance (as the error message tells you).

brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130312/3dfc4d67/attachment-0001.htm>

More information about the Beginners mailing list