mirror of
https://github.com/github/semantic.git
synced 2024-12-23 14:54:16 +03:00
Add a function to update cons records.
This commit is contained in:
parent
590509aaf8
commit
318d001512
@ -1,4 +1,4 @@
|
||||
{-# LANGUAGE DataKinds, GADTs, KindSignatures, MultiParamTypeClasses, TypeOperators #-}
|
||||
{-# LANGUAGE DataKinds, GADTs, KindSignatures, MultiParamTypeClasses, ScopedTypeVariables, TypeOperators #-}
|
||||
module Data.Record where
|
||||
|
||||
import GHC.Show
|
||||
@ -23,6 +23,11 @@ maybeGetField :: Typeable field => Record fields -> Maybe field
|
||||
maybeGetField (RCons h t) = cast h <|> maybeGetField t
|
||||
maybeGetField RNil = Nothing
|
||||
|
||||
updateRCons :: forall h t field. (Typeable h, Typeable field) => Record (h ': t) -> field -> Record (h ': t)
|
||||
updateRCons (RCons h t) a = case eqT :: Maybe (h :~: field) of
|
||||
Just Refl -> RCons a t
|
||||
Nothing -> RCons h (updateField t a)
|
||||
|
||||
|
||||
-- Classes
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user