1
1
mirror of https://github.com/github/semantic.git synced 2024-12-11 08:45:48 +03:00

Define a type family to constrain every element of a list of types.

This commit is contained in:
Rob Rix 2017-05-31 15:22:32 -04:00
parent 6c16b15a13
commit f9173c06b7

View File

@ -1,4 +1,4 @@
{-# LANGUAGE DataKinds, GADTs, KindSignatures, MultiParamTypeClasses, TypeOperators #-}
{-# LANGUAGE ConstraintKinds, DataKinds, GADTs, KindSignatures, MultiParamTypeClasses, TypeFamilies, TypeOperators #-}
module Data.Record where
import Data.Functor.Listable
@ -30,6 +30,10 @@ class HasField (fields :: [*]) (field :: *) where
getField :: Record fields -> field
setField :: Record fields -> field -> Record fields
type family ConstrainAll (toConstraint :: * -> Constraint) (fs :: [*]) :: Constraint where
ConstrainAll toConstraint (f ': fs) = (toConstraint f, ConstrainAll toConstraint fs)
ConstrainAll _ '[] = ()
-- Instances