@@ -94,70 +94,12 @@ literals = mkPattern' match'
9494 , return $ emit ty
9595 , return $ emit ")"
9696 ]
97− -- match (App _ (StringLiteral _ u) [arg@Var{}])
98− -- | Just ty <- decodeString u = mconcat <$> sequence
99− -- [ prettyPrintIL' arg
100− -- , return $ emit ".("
101− -- , return $ emit ty
102− -- , return $ emit ")"
103− -- ]
104− -- match (App _ (StringLiteral _ u) [arg])
105− -- | Just ty <- decodeString u = mconcat <$> sequence
106− -- [ return $ emit "("
107− -- , prettyPrintIL' arg
108− -- , return $ emit ")"
109− -- , return $ emit ".("
110− -- , return $ emit ty
111− -- , return $ emit ")"
112− -- ]
11397 match (App _ (Var _ fn) [arg]) | fn == arrayLengthFn = mconcat <$> sequence
11498 [ return $ emit arrayLengthFn
11599 , return $ emit "("
116100 , prettyPrintIL' arg
117101 , return $ emit ")"
118102 ]
119− -- match (App _ (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [x]) [y])
120− -- | fnMod == dictMod
121− -- , dictMod == C.dataEq || dictMod == C.dataOrd
122− -- , Just op <- renderOp fn
123− -- , Just t <- unboxType dict
124− -- = mconcat <$> sequence
125− -- [ return $ emit $ unbox' t x
126− -- , return $ emit op
127− -- , return $ emit $ unbox' t y
128− -- ]
129− -- match (App _ (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [x]) [y])
130− -- | not (isLiteral x) && not (isLiteral y)
131− -- , fnMod == dictMod
132− -- , dictMod == C.dataSemiring || dictMod == C.dataRing ||
133− -- dictMod == C.dataEuclideanRing || dictMod == C.dataHeytingAlgebra
134− -- , Just op <- renderOp fn
135− -- , Just t <- unboxType dict
136− -- = mconcat <$> sequence
137− -- [ return $ emit $ unbox' t x
138− -- , return $ emit op
139− -- , return $ emit $ unbox' t y
140− -- ]
141− -- match (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [n])
142− -- | fnMod == dictMod
143− -- , dictMod == C.dataRing
144− -- , fn == C.negate
145− -- , Just t <- unboxType dict
146− -- = mconcat <$> sequence
147− -- [ return $ emit "-("
148− -- , return $ emit $ unbox' t n
149− -- , return $ emit ")"
150− -- ]
151− -- match (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [n])
152− -- | fnMod == dictMod
153− -- , dictMod == C.dataHeytingAlgebra
154− -- , fn == properToIL C.not
155− -- , Just t <- unboxType dict
156− -- = mconcat <$> sequence
157− -- [ return $ emit "!("
158− -- , return $ emit $ unbox' t n
159− -- , return $ emit ")"
160− -- ]
161103 match app@(App{})
162104 | (val, args) <- unApp app []
163105 , length args > 1
@@ -275,55 +217,6 @@ literals = mkPattern' match'
275217 , prettyPrintIL' thens
276218 , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintIL') elses
277219 ]
278−
279−
280− -- match (IfElse _ (Binary _ EqualTo cond (BooleanLiteral Nothing True)) thens elses)
281− -- | (App _ (App _ (App _ (Indexer _ (Var _ _) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [x]) [y]) <- cond
282− -- , fnMod == dictMod
283− -- , dictMod == C.dataEq || dictMod == C.dataOrd
284− -- , Just _ <- unboxTypeInt dict
285− -- = mconcat <$> sequence
286− -- [ return $ emit "if "
287− -- , prettyPrintIL' cond
288− -- , return $ emit " "
289− -- , prettyPrintIL' thens
290− -- , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintIL') elses
291− -- ]
292− -- match (IfElse _ (Binary _ EqualTo cond (BooleanLiteral Nothing True)) thens elses) = mconcat <$> sequence
293− -- [ return $ emit "if "
294− -- , prettyPrintIL' (tyAssert cond C.heytingAlgebraBoolean)
295− -- , return $ emit " "
296− -- , prettyPrintIL' thens
297− -- , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintIL') elses
298− -- ]
299− -- match (IfElse _ (Binary _ EqualTo cond (BooleanLiteral Nothing False)) thens elses) = mconcat <$> sequence
300− -- [ return $ emit "if !("
301− -- , prettyPrintIL' (tyAssert cond C.heytingAlgebraBoolean)
302− -- , return $ emit ") "
303− -- , prettyPrintIL' thens
304− -- , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintIL') elses
305− -- ]
306− -- match (IfElse _ (Binary _ EqualTo x y@(NumericLiteral _ n)) thens elses) = mconcat <$> sequence
307− -- [ return $ emit "if "
308− -- , return $ emit $ unbox' t x
309− -- , return $ emit $ " == "
310− -- , prettyPrintIL' y
311− -- , return $ emit " "
312− -- , prettyPrintIL' thens
313− -- , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintIL') elses
314− -- ]
315− -- where
316− -- t | Left _ <- n = int
317− -- | Right _ <- n = float
318− -- match (IfElse _ (Binary _ EqualTo a b@StringLiteral{}) thens elses) = mconcat <$> sequence
319− -- [ return $ emit "if "
320− -- , return $ emit $ unbox' string a
321− -- , return $ emit $ " == "
322− -- , prettyPrintIL' b
323− -- , return $ emit " "
324− -- , prettyPrintIL' thens
325− -- , maybe (return mempty) (fmap (emit " else " <>) . prettyPrintIL') elses
326− -- ]
327220 match (IfElse _ cond thens elses) = mconcat <$> sequence
328221 [ return $ emit "if "
329222 , prettyPrintIL' cond