Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Haskell (GHC) extension for partial type synonym instances?

Using the extension TypeSynonymInstances it is possible to write an instance like that:

instances MyClass String where ...

Using newtype it is possible to declare an instance like that:

newtype Kleisli m a b = Kleisli (a -> m b)

instance MyClass (Kleisli m) where ...

I now that it is not possible to do the following:

type Kleisli m a b = a -> m b

instance MyClass (Kleisli m) where ...

Now is there an extension that allows me to do so? If not, what problems prohibit such an extension?

like image 714
scravy Avatar asked Mar 26 '14 15:03

scravy


1 Answers

Haskell doesn't allow partially applied type synonyms ever since deciding equality between a type and a partially applied type synonym is equivalent to deciding whether two functions are equal. This is undecidable in general.

Recall that type synonyms are type level functions (that happen to be parametric in their arguments).

This is why it's generally encouraged to rely on partial application as much as possible in the definition of a type synonym. Though this doesn't seem possible in your case.

like image 119
Daniel Gratzer Avatar answered Sep 19 '22 01:09

Daniel Gratzer