From dbb3426a4ece9ca6ed398d016a5c0090a2e51c30 Mon Sep 17 00:00:00 2001 From: PHO Date: Fri, 29 May 2009 13:03:53 +0900 Subject: [PATCH] Replaced FunctionalZone with DynamicZone. --- Network/DNS/Named/Zone.hs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Network/DNS/Named/Zone.hs b/Network/DNS/Named/Zone.hs index 302fe66..bada0d0 100644 --- a/Network/DNS/Named/Zone.hs +++ b/Network/DNS/Named/Zone.hs @@ -5,7 +5,7 @@ module Network.DNS.Named.Zone , Zone(zoneName) , SomeZone(..) , ExternalZone(..) - , FunctionalZone(..) + , DynamicZone(..) , StaticZone(..) , fromRecords , isInZone @@ -42,9 +42,6 @@ instance ZoneFinder (DomainMap (IO SomeZone)) where Just getZone -> liftM Just getZone Nothing -> return Nothing -instance ZoneFinder (DomainName -> Maybe SomeZone) where - findZone = (return .) - instance ZoneFinder (DomainName -> IO (Maybe SomeZone)) where findZone = id @@ -81,16 +78,15 @@ instance Zone ExternalZone where getRecordsForName = ezRecordsForName -data FunctionalZone - = FunctionalZone { - fzName :: !DomainName - , fzRecordNames :: ![DomainName] - , fzRecordsForName :: !(DomainName -> [SomeRR]) +data DynamicZone + = DynamicZone { + dzName :: !DomainName + , dzRecords :: !(IO (Map DomainName [SomeRR])) } -instance Zone FunctionalZone where - zoneName = fzName - getRecordNames = return . fzRecordNames - getRecordsForName = (return .) . fzRecordsForName +instance Zone DynamicZone where + zoneName = dzName + getRecordNames = liftM M.keys . dzRecords + getRecordsForName = flip (fmap . (fromMaybe [] .) . M.lookup) . dzRecords data StaticZone -- 2.40.0