Created
March 22, 2019 18:01
-
-
Save bas080/7628dcfd8082b837f303bc9607fbe3bc 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
#!/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