Skip to content

Instantly share code, notes, and snippets.

@DUznanski
Created April 23, 2017 02:13
Show Gist options
  • Save DUznanski/13169c437eae9de3d795ab844b8ce744 to your computer and use it in GitHub Desktop.
Save DUznanski/13169c437eae9de3d795ab844b8ce744 to your computer and use it in GitHub Desktop.
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), ....]
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