-dePArrComp (BindStmt p e _ _ : qs) body pa cea =
- dsLookupGlobalId filterPName `thenDs` \filterP ->
- dsLookupGlobalId crossMapPName `thenDs` \crossMapP ->
- dsLExpr e `thenDs` \ce ->
- let ety'cea = parrElemType cea
- ety'ce = parrElemType ce
- false = Var falseDataConId
- true = Var trueDataConId
- in
- newSysLocalDs ety'ce `thenDs` \v ->
- matchSimply (Var v) (StmtCtxt PArrComp) p true false `thenDs` \pred ->
- let cef | isIrrefutableHsPat p = ce
- | otherwise = mkApps (Var filterP) [Type ety'ce, mkLams [v] pred, ce]
- in
- mkLambda ety'cea pa cef `thenDs` \(clam,
- _ ) ->
- let ety'cef = ety'ce -- filter doesn't change the element type
- pa' = mkLHsPatTup [pa, p]
- in
- dePArrComp qs body pa' (mkApps (Var crossMapP)
- [Type ety'cea, Type ety'cef, cea, clam])
+dePArrComp (BindStmt p e _ _ : qs) body pa cea = do
+ filterP <- dsLookupGlobalId filterPName
+ crossMapP <- dsLookupGlobalId crossMapPName
+ ce <- dsLExpr e
+ let ety'cea = parrElemType cea
+ ety'ce = parrElemType ce
+ false = Var falseDataConId
+ true = Var trueDataConId
+ v <- newSysLocalDs ety'ce
+ pred <- matchSimply (Var v) (StmtCtxt PArrComp) p true false
+ let cef | isIrrefutableHsPat p = ce
+ | otherwise = mkApps (Var filterP) [Type ety'ce, mkLams [v] pred, ce]
+ (clam, _) <- mkLambda ety'cea pa cef
+ let ety'cef = ety'ce -- filter doesn't change the element type
+ pa' = mkLHsPatTup [pa, p]
+
+ dePArrComp qs body pa' (mkApps (Var crossMapP)
+ [Type ety'cea, Type ety'cef, cea, clam])