on master help sign in
Making IO lazy means we need to force an evaluation for anything to happen at all...
22b2879Edwin Brady
lib/io.idr+2−2
@@ -15,8 +15,8 @@ io_return x = prim__IO x
15-- This may seem pointless, but we can use it to force an
15-- This may seem pointless, but we can use it to force an
16-- evaluation of main that Epic wouldn't otherwise do...
16-- evaluation of main that Epic wouldn't otherwise do...
17
17
18−-- run__IO : IO () -> IO ()
18+run__IO : IO () -> IO ()
19−-- run__IO (prim__IO v) = prim__IO v
19+run__IO v = io_bind v (\v' => io_return v')
20
20
21data FTy = FInt | FFloat | FChar | FString | FPtr | FUnit
21data FTy = FInt | FFloat | FChar | FString | FPtr | FUnit
22
22
src/Idris/REPL.hs+10−3
@@ -181,15 +181,22 @@ process TTShell = do ist <- get
181 shst' <- lift $ runShell shst
181 shst' <- lift $ runShell shst
182 return ()
182 return ()
183process Execute = do (m, _) <- elabVal toplevel False
183process Execute = do (m, _) <- elabVal toplevel False
184+ (PApp fc
185+ (PRef fc (UN "run__IO"))
186+ [pexp $ PRef fc (NS (UN "main") ["main"])])
184− (PRef (FC "main" 0) (NS (UN "main") ["main"]))
187+-- (PRef (FC "main" 0) (NS (UN "main") ["main"]))
185 (tmpn, tmph) <- liftIO tempfile
188 (tmpn, tmph) <- liftIO tempfile
186 liftIO $ hClose tmph
189 liftIO $ hClose tmph
187 compile tmpn m
190 compile tmpn m
188 liftIO $ system tmpn
191 liftIO $ system tmpn
189 return ()
192 return ()
193+ where fc = FC "main" 0
190−process (Compile f) = do (m, _) <- elabVal toplevel False
194+process (Compile f) = do (m, _) <- elabVal toplevel False
195+ (PApp fc
196+ (PRef fc (UN "run__IO"))
191− (PRef (FC "main" 0) (NS (UN "main") ["main"]))
197+ [pexp $ PRef fc (NS (UN "main") ["main"])])
192 compile f m
198 compile f m
199+ where fc = FC "main" 0
193process (LogLvl i) = setLogLevel i
200process (LogLvl i) = setLogLevel i
194process Metavars = do ist <- get
201process Metavars = do ist <- get
195 let mvs = idris_metavars ist \\ primDefs
202 let mvs = idris_metavars ist \\ primDefs
test/test006/test006.idr+1−1
@@ -18,7 +18,7 @@ natToBin k with (parity k)
18 natToBin (S (j + j)) | odd = True :: natToBin j
18 natToBin (S (j + j)) | odd = True :: natToBin j
19
19
20main : IO ()
20main : IO ()
21−main = print (natToBin 42)
21+main = do print (natToBin 42)
22
22
23---------- Proofs ----------
23---------- Proofs ----------
24
24