I have a typeclass that uses functional dependency and example instance:
class (KnownSymbol name) => MyClass name result | name -> result
instance MyClass "something" Int
How can I reuse this and get a type-level function GetType so that GetType "something" returns Int?
My unsuccessful attempt was pretty naive:
class CanGetType a b | a -> b where
type GetType a
instance (MyClass name result) => CanGetType name result where
type GetType name = result
which fails:
The RHS of an associated type declaration mentions out-of-scope variable ‘a’
All such variables must be bound on the LHS