I have two variables,
let x = 3
let y = 4
And I have a bunch of operators in the form of Plus, Minus, Lt, Gt, Gte, etc.
data Operator = Plus | Minus | Divide | Gt | Lt ....
I am trying to write a function that takes in an Operator type and returns the actual operator. Like:
returnOperator :: Operator -> (Int->Int->a)
returnOperator op = case op of
Plus -> (+)
Minus -> (-)
Gt -> (>)
...etc
So I can do:
let output_op = returnOperator (Plus)
let z = x `output_op` y
z = 7
As an example. However, my returnOperator function as written gives an error:
Couldn't match type ‘a’ with ‘Int’
‘a’ is a rigid type variable bound by
the type signature for:
returnOp :: forall a. Operator -> Int -> Int -> a
Any suggestions on how to fix this issue?