git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix operator (inlined) rendering
36086b7Andy Arvanitis
src/CodeGen/Cpp/Printer.hs+10−8
@@ -107,10 +107,11 @@ literals = mkPattern' match'
107 match (App ss (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [x]) [y])
107 match (App ss (App _ (App _ (Indexer _ (Var _ fn) (Var _ fnMod)) [Indexer _ (Var _ dict) (Var _ dictMod)]) [x]) [y])
108 | fnMod == dictMod
108 | fnMod == dictMod
109 , dictMod == C.dataEq || dictMod == C.dataSemiring || dictMod == C.dataRing || dictMod == C.dataEuclideanRing
109 , dictMod == C.dataEq || dictMod == C.dataSemiring || dictMod == C.dataRing || dictMod == C.dataEuclideanRing
110+ , Just op <- renderOp fn
110 , Just t <- unboxType dict
111 , Just t <- unboxType dict
111 = mconcat <$> sequence
112 = mconcat <$> sequence
112 [ return $ emit $ unbox t x
113 [ return $ emit $ unbox t x
113− , return $ emit $ renderOp fn
114+ , return $ emit op
114 , return $ emit $ unbox t y
115 , return $ emit $ unbox t y
115 ]
116 ]
116 match (App _ val args) = mconcat <$> sequence
117 match (App _ val args) = mconcat <$> sequence
@@ -419,14 +420,15 @@ unboxType t
419 = Just float
420 = Just float
420 | otherwise = Nothing
421 | otherwise = Nothing
421
422
422−renderOp :: Text -> Text
423+renderOp :: Text -> Maybe Text
423renderOp op
424renderOp op
424− | op == C.eq = " == "
425+ | op == C.eq = Just " == "
426+ | op == C.notEq = Just " != "
425− | op == C.add = " + "
427+ | op == C.add = Just " + "
426− | op == C.sub = " - "
428+ | op == C.sub = Just " - "
427− | op == C.mul = " * "
429+ | op == C.mul = Just " * "
428− | op == C.div = " / "
430+ | op == C.div = Just " / "
429− | otherwise = error $ "Unknown operator " <> T.unpack op
431+ | otherwise = Nothing
430
432
431interfaceSource :: Text -> [Ident] -> [Ident] -> Text
433interfaceSource :: Text -> [Ident] -> [Ident] -> Text
432interfaceSource mn exports foreigns =
434interfaceSource mn exports foreigns =