Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Type Family for Type Class Methods

This could be synthesised

type family   Methods (cls :: Type -> Constraint) (a :: Type) = (res :: [Pair Symbol Type]) | res -> a
type instance Methods A a = '["a" :- a]
type instance Methods B b = '["b" :- (b -> b)]
type instance Methods C c = '["c" :- (c -> Int), "b" :- (c -> c), "a" :- c]

data Pair a b = a :- b
class A a where
  a :: a

class B b where
  b :: b -> b

class (A c, B c) => C c where
  c :: c -> Int
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment