Skip to content

Commit 9eb8875

Browse files
committed
fix lazy io stuff
1 parent 8705a83 commit 9eb8875

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

src/LambdaBox/Env.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ instance Pretty (GlobalDecl t) where
164164
hang "mutual inductive(s):" 2 $
165165
vsep $ map pretty indBodies
166166

167+
TypeAliasDecl _ -> "type alias:"
168+
167169
instance Pretty (GlobalEnv t) where
168170
pretty (GlobalEnv env) =
169171
vsep $ flip map (reverse env) \(kn, d) ->

src/Main.hs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{-# LANGUAGE DeriveGeneric, DeriveAnyClass, NamedFieldPuns, OverloadedStrings #-}
2-
{-# LANGUAGE GADTs #-}
2+
{-# LANGUAGE GADTs, BangPatterns #-}
33
-- | The agda2lambox Agda backend
44
module Main (main) where
55

@@ -41,7 +41,7 @@ main :: IO ()
4141
main = runAgda [agda2lambox]
4242

4343
data Output = RocqOutput | AstOutput
44-
deriving (Generic, NFData)
44+
deriving (Eq, Show, Generic, NFData)
4545

4646
-- | Backend options.
4747
data Options = forall t. Options
@@ -91,7 +91,7 @@ agda2lambox = Backend backend
9191
"Write output files to DIR. (default: project root)"
9292
, Option ['t'] ["typed"] (NoArg typedOpt)
9393
"Compile to typed λ□ environments."
94-
, Option ['c'] ["rocq"] (NoArg typedOpt)
94+
, Option ['c'] ["rocq"] (NoArg rocqOpt)
9595
"Output a Rocq file."
9696
]
9797
, isEnabled = \ _ -> True
@@ -120,31 +120,28 @@ writeModule
120120
-> TCM ModuleRes
121121
writeModule opts menv NotMain _ _ = pure ()
122122
writeModule Options{..} menv IsMain m defs = do
123-
programs <- filterM hasPragma defs
124123
outDir <- flip fromMaybe optOutDir <$> compileDir
125-
126-
defs' <- filterOutWhere defs
127-
128-
env <- compile optTarget $ reverse defs'
124+
defs' <- filterOutWhere defs
125+
env <- compile optTarget $ reverse defs'
126+
programs <- filterM hasPragma defs'
129127

130128
liftIO $ createDirectoryIfMissing True outDir
131129

132130
let fileName = (outDir </>) . moduleNameToFileName m
133131
coqMod = CoqModule env (map qnameToKName programs)
134132

133+
135134
liftIO do
136135
putStrLn $ "Writing " <> fileName ".txt"
137-
138-
pp coqMod <> "\n"
139-
& writeFile (fileName ".txt")
140-
141-
case optOutput of
142-
RocqOutput -> do
143-
putStrLn $ "Writing " <> fileName ".v"
144-
prettyCoq optTarget coqMod <> "\n"
145-
& writeFile (fileName ".v")
146-
147-
AstOutput -> do
148-
putStrLn $ "Writing " <> fileName ".ast"
149-
prettySexp optTarget coqMod <> "\n"
150-
& LText.writeFile (fileName ".ast")
136+
pp coqMod <> "\n" & writeFile (fileName ".txt")
137+
138+
liftIO $ case optOutput of
139+
RocqOutput -> do
140+
putStrLn $ "Writing " <> fileName ".v"
141+
prettyCoq optTarget coqMod <> "\n"
142+
& writeFile (fileName ".v")
143+
144+
AstOutput -> do
145+
putStrLn $ "Writing " <> fileName ".ast"
146+
prettySexp optTarget coqMod <> "\n"
147+
& LText.writeFile (fileName ".ast")

0 commit comments

Comments
 (0)