I’m just starting to learn haskell. I have custom class
class MyClass a where
doSomething :: a -> ()
Can I write a data with polymorphic callback in constructor?
data MyData = MyConstructor {
callback :: (MyClass m) => m -> () -- error
}
I want to make constraint for function argument.
In short, Yes you can by using
Rank2TypesorRankNTypespragma.As your data type is existentially quantified. It is actually
for which you require higher rank extension.