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:
parent
6c16b15a13
commit
f9173c06b7
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user