开发者

Partially applied type constructors in instance declarations

开发者 https://www.devze.com 2023-03-31 14:33 出处:网络
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,

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消