haskell - “Illegal type synonym family application in instance” with functional dependency -


i have multi-parameter typeclass functional dependency:

class multi b | -> b 

i have simple, non-injective type synonym family:

type family fam 

i want write instance of multi uses fam in second parameter, this:

instance multi (maybe a) (fam a) 

however, instance not accepted. ghc complains following error message:

error:   • illegal type synonym family application in instance: fam   • in instance declaration ‘multi (maybe a) (fam a)’ 

fortunately, there workaround. can perform usual trick moving type out of instance head , equality constraint:

instance (b ~ fam a) => multi (maybe a) b 

this instance accepted! however, got thinking, , started wonder why transformation not applied all instances of multi. after all, doesn’t functional dependency imply there can 1 b per a, anyway? in situation, seems there no reason ghc should reject first instance.

i found ghc trac ticket #3485, describes similar situation, typeclass did not involve functional dependency, ticket (rightfully) closed invalid. in situation, however, think functional dependency avoids problem described in ticket. there i’m overlooking, or oversight/missing feature in ghc?


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -