Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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?

like image 574
gatoatigrado Avatar asked Dec 05 '25 01:12

gatoatigrado


1 Answers

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.

like image 98
fuz Avatar answered Dec 06 '25 16:12

fuz