Created
August 13, 2017 16:24
-
-
Save deque-blog/487e7fddc6289892ac975e45e94cff73 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
add :: Money -> Money -> Maybe Money | |
add m1 m2 = | |
if currency m1 != currency m2 -- If the two currencies are different | |
then Nothing -- * Return an empty result | |
else Just $ Money { -- * Else return a new Money instance | |
amount = amount m1 + amount m2, -- which is the sum of the two inputs | |
currency = currency m1 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment