Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Stack implementation (Uneeb Adeel Agha)


----------------------------------------------------------------------

Message: 1
Date: Sat, 10 Sep 2016 21:07:48 +0000
From: Uneeb Adeel Agha <uneeb.a...@gmail.com>
To: beginners@haskell.org
Subject: [Haskell-beginners] Stack implementation
Message-ID: <cb003da7-ffde-9f39-7237-49eb0f9dc...@mixmax.com>
Content-Type: text/plain; charset="utf-8"

Hi,
I'm very, very new to Haskell. I am trying to understand the following error,
but I'm having a hard time wrapping my head around the whole type system.

Stack
 
                  module Stack (Stack(..)) where    import Prelude hiding 
(head, tail)    class Stack s where        empty :: s a        isEmpty :: s a 
-> Bool        cons :: s a -> a -> s a        head :: s a -> a        tail :: s 
a -> s a    data ListStack a = LS [a] deriving (Show)    instance Stack 
ListStack where        empty = LS []        isEmpty (LS s) = null s        cons 
(LS s) x = LS(x:s)        head(LS(x:_)) = x        tail(LS(x:xs)) = LS xs
                

Not using Mixmax yet?
 


The problem is that when I load this code in the interpreter and write>emptyI
get the following error
<interactive>:108:1:    No instance for (Show (s0 a0)) arising from a use of
‘print’    The type variables ‘s0’, ‘a0’ are ambiguous
I mean when I write "LS []" it works just fine. But something is wrong with
empty.

Thanks,
Uneeb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160910/3570674b/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 99, Issue 4
****************************************

Reply via email to