on master help sign in
[Issue 3774] Have :exec print the value of IO _ expressions
commit788f9608a79c6387f4a5f61c2a0321eba7306cae authorJonas De Vuyst <jdv@foobar.be> dateSun 14 May 2017, 15:30 (9 years ago) parent0d541dd
1 file changed+5−2
src/Idris/Elab/Value.hs+5−2
src/Idris/Elab/Value.hs+5−2
@@ -123,13 +123,16 @@ elabDocTerms info str = do typechecked <- Traversable.mapM decorate str
123123 else Checked tm
124124 | otherwise = Unchecked
125125
126−-- | Try running the term directly (as IO ()), then printing it as an Integer
127−-- (as a default numeric tye), then printing it as any Showable thing
126+-- | Try running the term directly (as IO ()) or with >>= printLn appended
127+-- (for other IO _), then printing it as an Integer (as a default numeric
128+-- type), then printing it as any Showable thing
128129elabExec :: FC -> PTerm -> PTerm
129130elabExec fc tm = runtm (PAlternative [] FirstSuccess
130131 [printtm (PApp fc (PRef fc [] (sUN "the"))
131132 [pexp (PConstant NoFC (AType (ATInt ITBig))), pexp tm]),
132133 tm,
134+ PApp fc (PRef fc [] (sUN ">>="))
135+ [pexp tm, pexp (PRef fc [] (sUN "printLn"))],
133136 printtm tm
134137 ])
135138 where