I'm attempting to define an evaluator for the language E and to be quite frank I'm completely at a loss for how to fix all the errors I keep getting with how the eval type is defined. I've spent several hours now reading up on interpreters, monads and trying to find something similar to give me a basis but I've turned up nothing. This is homework so naturally no straight out answers please. My big problems right now are the fact that there are no instance declarations for Num E or Integral E and when I've tried using fromInt and fromNum to fix this I'm met with additional errors. I've also tried changing the definitions to all sorts of different ways, the main problem with those being that Int doesn't match the type of E. I feel like I'm missing something pretty basic but I haven't been able to narrow it down at all. I'll be happy to answer any other questions if I wasn't clear on any particular points. If there are any sources that would be good additional information I'd really appreciate links.
data E = IntLit Int
| BoolLit Bool
| Plus E E
| Minus E E
| Multiplies E E
| Divides E E
| Equals E E
deriving (Eq, Show)
eval :: E -> E
--eval = undefined
eval (IntLit a) = IntLit a
eval (BoolLit a) = BoolLit a
eval (Plus a b) = eval a + eval b
eval (Minus a b) = eval a - eval b
eval (Multiplies a b) = eval a * eval b
eval (Divides a b) = eval a `div` eval b
eval (Equals a b) = BoolLit(a == b)