Created
November 9, 2012 14:00
-
-
Save robstewart57/4045780 to your computer and use it in GitHub Desktop.
newtype vs data in haskll
This file contains 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
Prelude> data D = D Int | |
Prelude> let f (D i) = "ok" | |
Prelude> f undefined | |
"*** Exception: Prelude.undefined | |
Prelude> newtype D = D Int | |
Prelude> let f (D i) = "ok" | |
Prelude> f undefined | |
"ok" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just ran in to the same issue and got the same result as you ... took forever to figure out what the issue was. Thanks for posting this.
I found this link from this StackOverflow comment.