From 107077c493884d33ecef23be37d61e589077a4c7 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 21 Jul 2016 17:26:03 -0400 Subject: [PATCH] Add a maybeGetField function over Records. --- src/Data/Record.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Data/Record.hs b/src/Data/Record.hs index 15aa0ccf4..e5babffcc 100644 --- a/src/Data/Record.hs +++ b/src/Data/Record.hs @@ -19,6 +19,10 @@ infixr 0 .: (.:) :: Typeable h => h -> Record t -> Record (h ': t) (.:) = RCons +maybeGetField :: Typeable field => Record fields -> Maybe field +maybeGetField (RCons h t) = cast h <|> maybeGetField t +maybeGetField RNil = Nothing + -- Classes