git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix operator (inlined) rendering
commit36086b749e24e0e2a74256b6e39b030a305f1b70 authorAndy Arvanitis <andyarvanitis@gmail.com> dateSun 12 Aug 2018, 13:38 (8 years ago) parente257dfb
1 file changed+10−8
src/CodeGen/Cpp/Printer.hs+10−8
src/CodeGen/Cpp/Printer.hs+10−8
@@ -107,10 +107,11 @@ literals = mkPattern' match'
107107 match (App ss (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [x]) [y])
108108 | fnMod == dictMod
109109 , dictMod == C.dataEq || dictMod == C.dataSemiring || dictMod == C.dataRing || dictMod == C.dataEuclideanRing
110+ , Just op <- renderOp fn
110111 , Just t <- unboxType dict
111112 = mconcat <$> sequence
112113 [ return $ emit $ unbox t x
113− , return $ emit $ renderOp fn
114+ , return $ emit op
114115 , return $ emit $ unbox t y
115116 ]
116117 match (App _ val args) = mconcat <$> sequence
@@ -419,14 +420,15 @@ unboxType t
419420 = Just float
420421 | otherwise = Nothing
421422
422−renderOp :: Text -> Text
423+renderOp :: Text -> Maybe Text
423424renderOp op
424− | op == C.eq = " == "
425− | op == C.add = " + "
426− | op == C.sub = " - "
427− | op == C.mul = " * "
428− | op == C.div = " / "
429− | otherwise = error $ "Unknown operator " <> T.unpack op
425+ | op == C.eq = Just " == "
426+ | op == C.notEq = Just " != "
427+ | op == C.add = Just " + "
428+ | op == C.sub = Just " - "
429+ | op == C.mul = Just " * "
430+ | op == C.div = Just " / "
431+ | otherwise = Nothing
430432
431433interfaceSource :: Text -> [Ident] -> [Ident] -> Text
432434interfaceSource mn exports foreigns =