Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.Tuple
- import Data.Maybe
- import Data.List
- data MyDataType = Foo
- | Bar
- | Baz
- deriving (Enum,Eq,Show)
- instance Enum MyDataType where
- fromEnum = fromJust . flip lookup table
- toEnum = fromJust . flip lookup (map swap table)
- table = [(Foo, 0), (Bar, 1), (Baz, 2)]
- $ ghc loo.hs
- [1 of 1] Compiling Main ( loo.hs, loo.o )
- loo.hs:8:10: error: parse error on input ‘(’
- |
- 8 | deriving (Enum,Eq,Show)
- | ^
Advertisement
Add Comment
Please, Sign In to add comment