-
-
Save DUznanski/13169c437eae9de3d795ab844b8ce744 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:\.....\SpaceAge.hs:14:10: error: | |
* No instance for (Ord Planet) arising from a use of `fromList' | |
* In the expression: | |
fromList | |
[(Mercury, 0.2408467), (Venus, 0.61519726), (Earth, 1), | |
(Mars, 1.8808158), ....] | |
In an equation for `orbits': | |
orbits | |
= fromList | |
[(Mercury, 0.2408467), (Venus, 0.61519726), (Earth, 1), ....] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SpaceAge (Planet(..), ageOn) where | |
import Data.Map.Strict as Map | |
data Planet = Mercury | |
| Venus | |
| Earth | |
| Mars | |
| Jupiter | |
| Saturn | |
| Uranus | |
| Neptune | |
orbits :: Map Planet Float | |
orbits = fromList [(Mercury, 0.2408467), (Venus, 0.61519726), (Earth, 1), (Mars, 1.8808158), (Jupiter, 11.862615), (Saturn, 29.447498), (Uranus, 84.016846), (Neptune, 164.79132)] | |
ageOn :: Planet -> Float -> Float | |
ageOn planet seconds = seconds / (31557600 * orbits ! planet) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment