Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Before I go back to ML out of frustration

Name: Anonymous 2010-02-28 4:31

Does anyone why this HASKAL code won't compile?


data Stack a = MkStack a (Stack a) | Null

push :: a -> Stack a -> Stack a
push a stack = MkStack a stack

pop :: Stack a -> Stack a
pop Null = Null
pop (MkStack a stacks) = stacks

instance Eq (Stack a) where 
  Null == Null = True
  Null == (MkStack _1 _2) = False
  (MkStack _1 _2) == Null = False
  (MkStack x xs) == (MkStack y ys) = (x == y) && (xs == ys)


gives me


\home\anus\haskal\peyote-joints.hs:14:38:
    Could not deduce (Eq a) from the context (Eq (Stack a))
      arising from a use of `==' at C:\stack.hs:14:38-43
    Possible fix: add (Eq a) to the context of the instance declaration
    In the first argument of `(&&)', namely `(x == y)'
    In the expression: (x == y) && (xs == ys)
    In the definition of `==':
        (MkStack x xs) == (MkStack y ys) = (x == y) && (xs == ys)


I don't see any other opportunity to "clear it up" using extra annotations or whatnot, so...

Name: Need advice! 2010-03-01 15:21

I just finished HS last year with top grades. I didn't enter University/College.

I'm hoping of getting a coding job somewhere. Something with OOp/Functional programming. I have the knowledge but and the skill but not the experience. I want to avoid 4 years of University/College if possible. Also I mostly self teach so any courses are just for the certifications.

What do?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List