mirror of
https://github.com/github/semantic.git
synced 2025-01-06 06:46:07 +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
|
module Data.Record where
|
||||||
|
|
||||||
import Data.Functor.Listable
|
import Data.Functor.Listable
|
||||||
@ -30,6 +30,10 @@ class HasField (fields :: [*]) (field :: *) where
|
|||||||
getField :: Record fields -> field
|
getField :: Record fields -> field
|
||||||
setField :: Record fields -> field -> Record fields
|
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
|
-- Instances
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user