Partially applied type constructors in instance declarations
I have a type constructor
type SimpleFcn α m = m α -> m α
and I want to use it in a class where it will be further parameterized later. Namely,
instance A (SimpleFcn α)
In my situation, any functions in the class A开发者_如何学C
would be parametric in argument m
.
class A β where f :: Monad m => β m
instance A (SimpleFcn α) where f x = x
What is an appropriate workaround for this situation?
It is not possible to partitially apply type synonyms, as they are just a way to shorten your code and not real type-level lambdas. You can try to use a newtype
instead.
精彩评论