I have the following code:
data Instruction = Assignment (Int->Int->Int) Int Int
This allows me to create a method like this:
foo :: Assignment -> Int
foo (Assignment func a b) = (func a b) + 100
which can be used like this:
foo (Assignment (+) 5 6) --outputs 111
Or
foo (Assignment (*) 5 5) --outputs 125
Now I want to create a "show" for the Assignment. This is what I got so far:
instance Show Instruction where
show (Assignment f a b) = show a ++ " " ++ show f ++ " " ++ show b --compile time error
What I want is if I did "show (Assignment (*) 5 8)" the output would be "5 * 8"
However the problem is that you cannot do "show f".
Note: please leave reliance on other libraries to a minimum or none.