Created
March 26, 2017 15:06
-
-
Save pierric/92bd8a2fbcb4bf606c08e8f0f46a52df to your computer and use it in GitHub Desktop.
Convert a list of constraints to one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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