When loading the following module I get the error:
No instance for (Eq Planet) arising from a use of ‘==’ • In the expression: planet == Mercury In a stmt of a pattern guard for an equation for ‘ageOn’:
How can I check whether planet equals a certain planet?
module SpaceAge (Planet(..), ageOn) where
data Planet = Mercury
| Venus
| Earth
| Mars
| Jupiter
| Saturn
| Uranus
| Neptune
mercury :: Float
mercury = 0.2408467
venus :: Float
venus = 0.61519726
earth :: Float
earth = 1.0
mars :: Float
mars = 1.8808158
jupiter :: Float
jupiter = 11.862615
saturn :: Float
saturn = 29.447498
uranus :: Float
uranus = 84.016846
neptune :: Float
neptune = 164.79132
ageOn :: Planet -> Float -> Float
ageOn planet seconds
| planet == Mercury = seconds * mercury
| planet == Venus = seconds * venus
| planet == Earth = seconds * earth
| planet == Mars = seconds * mars
| planet == Jupiter = seconds * jupiter
| planet == Saturn = seconds * saturn
| planet == Uranus = seconds * uranus
| planet == Neptune = seconds * neptune