summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-03-22 04:28:47 -0400
committerJoe Crayne <joe@jerkface.net>2019-03-22 04:28:47 -0400
commit7bb298c12edc219c40c16db31a40dba9db4702fc (patch)
treef68570665fc763c17c527f3259c077c38c815cc1
parentb54c31e0cdd832859c14b0c307df3cc39baa2511 (diff)
Use return () as default statement.
-rw-r--r--monkeypatch.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/monkeypatch.hs b/monkeypatch.hs
index 95cf709..10f868f 100644
--- a/monkeypatch.hs
+++ b/monkeypatch.hs
@@ -160,8 +160,8 @@ cvarName :: CExpression a -> Maybe String
160cvarName (CVar (C.Ident n _ _) _) = Just n 160cvarName (CVar (C.Ident n _ _) _) = Just n
161cvarName _ = Nothing 161cvarName _ = Nothing
162 162
163hsopUnit :: HS.Exp () 163retUnit :: HS.Exp ()
164hsopUnit = HS.Con () (Special () (UnitCon ())) 164retUnit = App () (hsvar "return") $ HS.Con () (Special () (UnitCon ()))
165 165
166 166
167infixOp :: HS.Exp () -> String -> HS.Exp () -> HS.Exp () 167infixOp :: HS.Exp () -> String -> HS.Exp () -> HS.Exp ()
@@ -300,7 +300,7 @@ grokExpression fe (CStatExpr (CCompound idents xs _) _) = do
300 [CBlockStmt (CExpr mexp ni)] -> Just $ CBlockStmt (CReturn mexp ni) 300 [CBlockStmt (CExpr mexp ni)] -> Just $ CBlockStmt (CReturn mexp ni)
301 _ -> Just (head y) -- Nothing FIXME 301 _ -> Just (head y) -- Nothing FIXME
302 gs <- mapM (grokStatement fe) (reverse $ y' : ys) 302 gs <- mapM (grokStatement fe) (reverse $ y' : ys)
303 let s0 = foldr applyComputation (Computation Map.empty Map.empty (App () (hsvar "return") hsopUnit)) gs 303 let s0 = foldr applyComputation (Computation Map.empty Map.empty retUnit) gs
304 s1 = fmap (\xp -> Paren () xp) s0 304 s1 = fmap (\xp -> Paren () xp) s0
305 hv = uniqIdentifier "ret" (compFree s1) 305 hv = uniqIdentifier "ret" (compFree s1)
306 k = uniqIdentifier "go" (compFree s1) 306 k = uniqIdentifier "go" (compFree s1)
@@ -628,7 +628,7 @@ transpile o fname incs (CTranslUnit edecls _) = do
628 else do 628 else do
629 let mhask = do 629 let mhask = do
630 xs <- mapM (grokStatement fe) bdy 630 xs <- mapM (grokStatement fe) bdy
631 return $ foldr applyComputation (Computation Map.empty Map.empty hsopUnit) xs 631 return $ foldr applyComputation (Computation Map.empty Map.empty retUnit) xs
632 case mhask of 632 case mhask of
633 Just hask -> do printHeader 633 Just hask -> do printHeader
634 mapM_ (putStrLn . (" "++)) $ lines $ HS.prettyPrint $ comp hask 634 mapM_ (putStrLn . (" "++)) $ lines $ HS.prettyPrint $ comp hask