'Can't determine "output" type of functional dependency [purescript]

Consider the following class which uses functional dependencies to mimic a type family over Symbols:

class F :: Symbol -> Type -> Constraint
class F k v | k -> v

instance F "Int" Int
else instance F "String" String

So, I expect that I can write

test :: forall t. F "Int" t => t
test = 1 :: Int

Since the quantified type t will be determined to be Int by its functional dependency on "Int" from the class definition's specification that k -> v.

But instead I get this type error:

Could not match type

    Int

  with type

    t0


while checking that type Int
  is at least as general as type t0
while checking that expression 1
  has type t0
in value declaration test

where t0 is a rigid type variable

Why isn't the type variable determined to be Int?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source