diff options
author | Joe Crayne <joe@jerkface.net> | 2019-03-22 04:28:47 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-03-22 04:28:47 -0400 |
commit | 7bb298c12edc219c40c16db31a40dba9db4702fc (patch) | |
tree | f68570665fc763c17c527f3259c077c38c815cc1 /monkeypatch.hs | |
parent | b54c31e0cdd832859c14b0c307df3cc39baa2511 (diff) |
Use return () as default statement.
Diffstat (limited to 'monkeypatch.hs')
-rw-r--r-- | monkeypatch.hs | 8 |
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 | |||
160 | cvarName (CVar (C.Ident n _ _) _) = Just n | 160 | cvarName (CVar (C.Ident n _ _) _) = Just n |
161 | cvarName _ = Nothing | 161 | cvarName _ = Nothing |
162 | 162 | ||
163 | hsopUnit :: HS.Exp () | 163 | retUnit :: HS.Exp () |
164 | hsopUnit = HS.Con () (Special () (UnitCon ())) | 164 | retUnit = App () (hsvar "return") $ HS.Con () (Special () (UnitCon ())) |
165 | 165 | ||
166 | 166 | ||
167 | infixOp :: HS.Exp () -> String -> HS.Exp () -> HS.Exp () | 167 | infixOp :: 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 |