Skip to content

Instantly share code, notes, and snippets.

@lumie1337
Last active October 4, 2019 01:52
Show Gist options
  • Save lumie1337/16688d6c1c5f4b741760f1a37a25d242 to your computer and use it in GitHub Desktop.
Save lumie1337/16688d6c1c5f4b741760f1a37a25d242 to your computer and use it in GitHub Desktop.
{-# LANGUAGE LambdaCase #-}
data Planet = Earth | Mercury | Venus | Mars | Jupiter | Saturn | Uranus | Neptune
deriving (Eq)
ageOn :: Planet -> Float -> Float
ageOn = flip (/) . (earthSecondsPerYear *) . earthSecondsFor
where
earthSecondsPerYear = 31557600
earthSeconds =
\case Earth -> 1
Mercury -> 0.2408467
Venus -> 0.61519726
Mars -> 1.8808158
Jupiter -> 11.862615
Saturn -> 29.447498
Uranus -> 84.016846
Neptune -> 164.79132
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment