Skip to content

Instantly share code, notes, and snippets.

@krdlab
Created March 3, 2012 06:55
Show Gist options
  • Save krdlab/1964772 to your computer and use it in GitHub Desktop.
Save krdlab/1964772 to your computer and use it in GitHub Desktop.
type definition by 'data' and 'newtype'
data Hoge = Hoge { get :: Int }
foo :: Hoge -> String
foo (Hoge _) = "foo!"
foo undefined
-- "*** Exception: Prelude.undefined
newtype Hoge = Hoge { get :: Int }
foo :: Hoge -> String
foo (Hoge _) = "foo!"
foo undefined
-- "foo!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment