Created
January 15, 2019 17:23
-
-
Save antaranyan/304d7b2aefa35f3a14e745e5abeeb267 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| module Main where | |
| import Prelude | |
| import Data.Tuple | |
| import Control.Monad.Eff.Console (log) | |
| import TryPureScript (render, withConsole) | |
| data Currency | |
| = BTC | |
| | USD | |
| showCurrencyImpl :: Currency -> String | |
| showCurrencyImpl BTC = "btc" | |
| showCurrencyImpl USD = "usd" | |
| instance showCurrency :: Show Currency where | |
| show = showCurrencyImpl | |
| data CurrencyPair a b = CurrencyPair Currency Currency | |
| showCurrencyPairImpl :: (CurrencyPair Currency Currency) -> String | |
| showCurrencyPairImpl (CurrencyPair base quote) = | |
| show base <> "-" <> show quote | |
| instance showCurrencyPair :: Show (CurrencyPair Currency Currency) where | |
| show = showCurrencyPairImpl | |
| symbol :: CurrencyPair Currency Currency | |
| symbol = CurrencyPair BTC USD | |
| main = render =<< withConsole do | |
| log $ show symbol |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment