Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- A type class with a single instance
- class C a where
- c :: a -> a
- instance D a => C a where
- c = d
- -- Asking for the type of c will give me a function with the constraint D a:
- $ :t c
- > D a => a -> a
- -- However, I want the type to be C a => a -> a
- -- One way to solve this is by adding another instance that should never match
- data Bottom
- instance C Bottom where
- c = undefined
- -- Now the type will have the correct constraint
- $ :t c
- > C a => a -> a
- -- Is there another way of solving this?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement