Skip to content

Instantly share code, notes, and snippets.

@bas080
Created March 22, 2019 18:01
Show Gist options
  • Save bas080/7628dcfd8082b837f303bc9607fbe3bc to your computer and use it in GitHub Desktop.
Save bas080/7628dcfd8082b837f303bc9607fbe3bc to your computer and use it in GitHub Desktop.
#!/usr/bin/env stack
-- stack --resolver lts-6.25 script
import Data.Ratio
type Currency = (String, Ratio Integer)
type Value = (Currency, Ratio Integer)
convert :: Value -> Currency -> Value
convert ((_, a), amount) (currency, b) = ((currency, b), (amount * a) * b)
main = do
print (convert (("EUR", 1.2), 1000) ("USD", 1))
print (convert (("USD", 1), 1000) ("EUR", 1.2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment