Skip to content

Instantly share code, notes, and snippets.

@antaranyan
Created January 15, 2019 17:23
Show Gist options
  • Select an option

  • Save antaranyan/304d7b2aefa35f3a14e745e5abeeb267 to your computer and use it in GitHub Desktop.

Select an option

Save antaranyan/304d7b2aefa35f3a14e745e5abeeb267 to your computer and use it in GitHub Desktop.
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