I have a list of commands ([Command]
) which looks like [forward 15, left 20, right 10]
.
I want to add forward 15
to [Command]
whenever I see a forward 15
command. I used elem
and ==
to compare whether the element is forward 15
or not but it gives me No instance for (Eq Command) arising
error.
Also, in another function, I want to add [left 15, forward 15, forward 15, right 15, right 15, forward 15, forward 15, left 15]
to [Command]
whenever I see 4 consecutive forward 15
commands.
Thus my question is how to compare functions, because forward
is a function and I can't compare it using elem
or ==
.
Command
is defined as a type
, not as a data
, hence I can't use deriving Eq
.
type Command = Funcs -> (Picture, Funcs)
data Funcs = Funcs {pen :: Bool, angle :: Float, point :: Point, penColor :: Color} deriving (Eq, Show)
forward :: Float -> Command
forward x = ....