on master help sign in
[Issue 3774] Have :exec print the value of IO _ expressions
788f960Jonas De Vuyst
src/Idris/Elab/Value.hs+5−2
@@ -123,13 +123,16 @@ elabDocTerms info str = do typechecked <- Traversable.mapM decorate str
123 else Checked tm
123 else Checked tm
124 | otherwise = Unchecked
124 | otherwise = Unchecked
125
125
126−-- | Try running the term directly (as IO ()), then printing it as an Integer
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
127−-- (as a default numeric tye), then printing it as any Showable thing
128+-- type), then printing it as any Showable thing
128elabExec :: FC -> PTerm -> PTerm
129elabExec :: FC -> PTerm -> PTerm
129elabExec fc tm = runtm (PAlternative [] FirstSuccess
130elabExec fc tm = runtm (PAlternative [] FirstSuccess
130 [printtm (PApp fc (PRef fc [] (sUN "the"))
131 [printtm (PApp fc (PRef fc [] (sUN "the"))
131 [pexp (PConstant NoFC (AType (ATInt ITBig))), pexp tm]),
132 [pexp (PConstant NoFC (AType (ATInt ITBig))), pexp tm]),
132 tm,
133 tm,
134+ PApp fc (PRef fc [] (sUN ">>="))
135+ [pexp tm, pexp (PRef fc [] (sUN "printLn"))],
133 printtm tm
136 printtm tm
134 ])
137 ])
135 where
138 where