@@ -92,7 +92,8 @@ literals = mkPattern' match'
93 match (App ss (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [x]) [y])
93 match (App ss (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [x]) [y])
94 | fnMod == dictMod
94 | fnMod == dictMod
95− , dictMod == C.dataEq || dictMod == C.dataSemiring || dictMod == C.dataRing || dictMod == C.dataEuclideanRing
95+ , dictMod == C.dataEq || dictMod == C.dataSemiring || dictMod == C.dataRing ||
96+ dictMod == C.dataEuclideanRing || dictMod == C.dataHeytingAlgebra
96 , Just op <- renderOp fn
97 , Just op <- renderOp fn
97 , Just t <- unboxType dict
98 , Just t <- unboxType dict
98 = mconcat <$> sequence
99 = mconcat <$> sequence
@@ -109,6 +110,15 @@ literals = mkPattern' match'
109 [ return $ emit "-"
110 [ return $ emit "-"
110 , return $ emit $ unbox' t n
111 , return $ emit $ unbox' t n
113+ match (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [n])
115+ , dictMod == C.dataHeytingAlgebra
116+ , fn == properToCpp C.not
117+ , Just t <- unboxType dict
118+ = mconcat <$> sequence
120+ , return $ emit $ unbox' t n
112 match (App _ val args) = mconcat <$> sequence
122 match (App _ val args) = mconcat <$> sequence
113 [ prettyPrintCpp' val
123 [ prettyPrintCpp' val
114 , return $ emit "("
124 , return $ emit "("
@@ -326,7 +336,7 @@ prettyStatements sts = do
326 indentString <- currentIndent
336 indentString <- currentIndent
327 return $ intercalate (emit "\n") $ map ((<> emit ";") . (indentString <>)) cpps
337 return $ intercalate (emit "\n") $ map ((<> emit ";") . (indentString <>)) cpps
329−-- | Generate a pretty-printed string representing a collection of Objective-C expressions at the same indentation level
339+-- | Generate a pretty-printed string representing a collection of C++ expressions at the same indentation level
330prettyPrintCppWithSourceMaps :: [AST] -> (Text, [SMap])
340prettyPrintCppWithSourceMaps :: [AST] -> (Text, [SMap])
331prettyPrintCppWithSourceMaps cpp =
341prettyPrintCppWithSourceMaps cpp =
332 let StrPos (_, s, mp) = (fromMaybe (internalError "Incomplete pattern") . flip evalStateT (PrinterState 0) . prettyStatements) cpp
342 let StrPos (_, s, mp) = (fromMaybe (internalError "Incomplete pattern") . flip evalStateT (PrinterState 0) . prettyStatements) cpp
@@ -335,7 +345,7 @@ prettyPrintCppWithSourceMaps cpp =
335prettyPrintCpp :: [AST] -> Text
345prettyPrintCpp :: [AST] -> Text
336prettyPrintCpp = maybe (internalError "Incomplete pattern") runPlainString . flip evalStateT (PrinterState 0) . prettyStatements
346prettyPrintCpp = maybe (internalError "Incomplete pattern") runPlainString . flip evalStateT (PrinterState 0) . prettyStatements
338−-- | Generate an indented, pretty-printed string representing a Objective-C expression
348+-- | Generate an indented, pretty-printed string representing a C++ expression
339prettyPrintCpp' :: (Emit gen) => AST -> StateT PrinterState Maybe gen
349prettyPrintCpp' :: (Emit gen) => AST -> StateT PrinterState Maybe gen
340prettyPrintCpp' = A.runKleisli $ runPattern matchValue
350prettyPrintCpp' = A.runKleisli $ runPattern matchValue
@@ -409,6 +419,8 @@ unboxType t
409 t == C.ringNumber ||
419 t == C.ringNumber ||
410 t == C.euclideanRingNumber
420 t == C.euclideanRingNumber
411 = Just float
421 = Just float
422+ | t == C.heytingAlgebraBoolean
412 | otherwise = Nothing
424 | otherwise = Nothing
414renderOp :: Text -> Maybe Text
426renderOp :: Text -> Maybe Text
@@ -419,6 +431,8 @@ renderOp op
419 | op == C.sub = Just " - "
431 | op == C.sub = Just " - "
420 | op == C.mul = Just " * "
432 | op == C.mul = Just " * "
421 | op == C.div = Just " / "
433 | op == C.div = Just " / "
434+ | op == C.conj = Just " && "
435+ | op == C.disj = Just "|| "
422 | otherwise = Nothing
436 | otherwise = Nothing
424interfaceSource :: Text -> [(Text,Bool)] -> [Ident] -> Text
438interfaceSource :: Text -> [(Text,Bool)] -> [Ident] -> Text