Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- instance Enum MyDataType where
- fromEnum = fromJust . flip lookup table
- toEnum = fromJust . flip lookup (map swap table)
- table = [(Foo, 0), (Bar, 1), (Baz, 2)]
- =============================
- instance Enum MyDataType where
- fromEnum Foo = 0
- fromEnum Bar = 1
- fromEnum Bax = 2
- toEnum 0 = Foo
- toEnum 1 = Bar
- toEnum 2 = Baz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement