shithub: MicroHs

ref: 5f1eafa05adeb65e2cd1f6db83d9cbd88c2cb0d9
dir: /tests/Newtype.hs/

View raw version
module Newtype(main) where
import Prelude

newtype N = N Int
newtype M a = M a

f :: N -> Int
f (N x) = x

g :: M (Int, Int) -> M Int
g (M (x, y)) = M x

showM :: forall a . (a -> String) -> M a -> String
showM sh (M x) = "(M " ++ sh x ++ ")"

main :: IO ()
main = do
  putStrLn $ show [f (N 1), f (N 2)]
  putStrLn $ showM show (g (M (3,4)))