never executed always true always false
1 {-# LANGUAGE QuasiQuotes #-}
2
3 module Conjure.Rules.Vertical.MSet.ExplicitWithRepetition where
4
5 import Conjure.Rules.Import
6
7
8 rule_Comprehension :: Rule
9 rule_Comprehension = "mset-comprehension{ExplicitWithRepetition}" `namedRule` theRule where
10 theRule (Comprehension body gensOrConds) = do
11 (gocBefore, (pat, s), gocAfter) <- matchFirst gensOrConds $ \ goc -> case goc of
12 Generator (GenInExpr pat@Single{} s) -> return (pat, s)
13 _ -> na "rule_Comprehension"
14 TypeMSet{} <- typeOf s
15 MSet_ExplicitWithRepetition <- representationOf s
16 [flag, values] <- downX1 s
17 DomainMatrix index _ <- domainOf values
18 let upd val old = lambdaToFunction pat old val
19 return
20 ( "Vertical rule for mset-comprehension, ExplicitWithRepetition representation"
21 , do
22 (jPat, j) <- quantifiedVar
23 let val = [essence| &values[&j] |]
24 return $ Comprehension (upd val body)
25 $ gocBefore
26 ++ [ Generator (GenDomainNoRepr jPat index)
27 , Condition [essence| &j <= &flag |]
28 ]
29 ++ transformBi (upd val) gocAfter
30 )
31 theRule _ = na "rule_Comprehension"