Last active
August 29, 2015 14:19
-
-
Save owickstrom/4d92faec8d38db95e800 to your computer and use it in GitHub Desktop.
Purescript Eq instance
This file contains hidden or 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
| module Main where | |
| import Debug.Trace | |
| data T = A | B Number | |
| instance eqT :: Eq T where | |
| A == A = true | |
| (B v1) == (B v2) = v1 == v2 | |
| _ == _ = false | |
| t1 /= t2 == not (t1 == t2) | |
| main = print $ [A, B 123] == [A, B 123] |
This file contains hidden or 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
| "Eq.purs" (line 6, column 3): | |
| unexpected UName "A" | |
| expecting no indentation or end of input |
Yes, the compiler doesn't support infix pattern matches right now.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not exactly sure why, but this seem to work better