I want to change all literals.
data Expressions a = ListExpression String[Expressions a]
| BinaryExpression String (Expressions a) (Expressions a)
| UnaryExpression String(Expressions a)
| Variables Variable
| Literals a
deriving Eq
Now i want to have all Literals changed to b, if the literals in c equals b.
So example:
changeData 20 30 (Literals 100) = (Literals 100)
changeData 20 30 (Literals 20) = (Literals 30)
The expression itself should not be changed.
changeData :: (Eq a) => a -> a -> Expressions a -> Expressions a
changeData a b c
I dont understand how to access it. I thought something like this:
fmap (Literals b == Literals a) (\x -> if x == True = a else b)
I thought like: Literals b == Literals a for each Expression. If true, then change to a, otherwise to b.
But like I wrote it down, its not working and I cant figure my mistake out.
Am im fundamentally missunderstanding something?