module Main where

newtype USD = USD Int deriving (Show)
newtype EUR = EUR Int deriving (Show)

class Currency a where
  p :: a -> a -> a

instance Currency USD where
  p (USD a) (USD b) = USD $ a + b

instance Currency EUR where
  p (EUR a) (EUR b) = EUR $ a + b

main :: IO ()
main = do
  print $ (USD 12) `p` (USD 11)
  print $ (EUR 1) `p` (EUR 2)
  -- Does not compile: print $ (EUR 1) `p` (USD 2)
  -- Does not compile: print $ (USD 11) `p` 12