Skip to content

Instantly share code, notes, and snippets.

@Icelandjack
Created May 27, 2017 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Icelandjack/853dd60e7164b7b6233c45a990767df6 to your computer and use it in GitHub Desktop.
Save Icelandjack/853dd60e7164b7b6233c45a990767df6 to your computer and use it in GitHub Desktop.
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