@@ -121,28 +121,25 @@ flush = Rules $ do
121121
122122
123123--------------------------------------------------------------------------------
124−match :: Pattern -> Rules () -> Rules ()
125−match pattern rules = do
124+matchInternal :: Pattern -> Rules [Identifier] -> Rules () -> Rules ()
125+matchInternal pattern getIDs rules = do
126126 tellPattern pattern
127127 flush
128− ids <- getMatches pattern
128+ ids <- getIDs
129129 tellResources ids
130130 Rules $ local (setMatches ids) $ unRules $ rules >> flush
131131 where
132132 setMatches ids env = env {rulesMatches = ids}
133133
134+--------------------------------------------------------------------------------
135+match :: Pattern -> Rules () -> Rules ()
136+match pattern = matchInternal pattern $ getMatches pattern
137+
134138
135139--------------------------------------------------------------------------------
136140matchMetadata :: Pattern -> (Metadata -> Bool) -> Rules () -> Rules ()
137−matchMetadata pattern metadataPred rules = do
138− tellPattern pattern
139− flush
140− idsAndMetadata <- getAllMetadata pattern
141− let ids = map fst . filter (metadataPred . snd) $ idsAndMetadata
142− tellResources ids
143− Rules $ local (setMatches ids) $ unRules $ rules >> flush
144− where
145− setMatches ids env = env {rulesMatches = ids}
141+matchMetadata pattern metadataPred = matchInternal pattern $
142+ map fst . filter (metadataPred . snd) <$> getAllMetadata pattern
146143
147144
148145--------------------------------------------------------------------------------