I'm actually new to Haskell. I've written this code for Queue, but the last line always face this syntax error .
Syntax error in input (unexpected '=').
I really can't figure out what's wrong :(
module Queue where
data Queue a = Q[a] deriving Show
class QDS q a where
pop :: q a -> (a, q a)
push :: q a -> a -> q a
lengthQS :: q a -> Int
isEmpty :: q a -> Bool
instance QDS Queue a where
pop (Q (x:xs)) = (x, (Q xs))
push (Q x) a = (Q (x ++ [a]))
lengthQS (Q x) = length x
isEmpty q = lengthQS q == 0 -- This line fails
FlexibleInstancesandMultiParamTypeClasses, which, for future reference, is helpful to include when you post code. Is it possible you used a tab instead of spaces somewhere?Queue?