This is how I have define my Stack type. There could be better ways, but as of now lets stick for this one.
data Stack' v = Stack' [v] Int deriving (Show)
So something like push' will look like this
push' :: (Ord v) => Stack' v -> v -> Stack' v
push' (Stack' l m) a = if m <= length l then Stack' l m else Stack' (l ++ [a]) m
But I am not able to define functor for this. My this attempt is failing saying that "Parse error in pattern: v"
instance Functor Stack' where
fmap f (v l) = (map f v) (l)
Can someone help me in defining the functor?