Skip to content

Instantly share code, notes, and snippets.

@pierric
Created March 26, 2017 15:06
Show Gist options
  • Save pierric/92bd8a2fbcb4bf606c08e8f0f46a52df to your computer and use it in GitHub Desktop.
Save pierric/92bd8a2fbcb4bf606c08e8f0f46a52df to your computer and use it in GitHub Desktop.
Convert a list of constraints to one
{-# LANGUAGE ConstraintKinds, DataKinds, TypeOperators, TypeFamilies #-}
import GHC.Exts
type A a = Num a ': Eq a ': Ord a ': '[]
type family ListOfConstraints (a :: [Constraint]) :: Constraint where
ListOfConstraints '[] = ()
ListOfConstraints (c ': cs) = (c, ListOfConstraints cs)
f :: ListOfConstraints (A a) => a -> a -> a
f x y = max x y * 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment