Make it less less-than-fantastic.
Chris Pressey
5 years ago
27 | 27 |
showResults results =
|
28 | 28 |
(foldl (\a x -> x ++ "\n" ++ a) "" (map (showResult) results))
|
29 | 29 |
showResult (Right result) = show result
|
30 | |
showResult (Left result) = "ERROR: " ++ (show result)
|
|
30 |
showResult (Left result) = "uncaught exception: " ++ (show result)
|
10 | 10 |
collect ((List [Symbol "display", expr]):rest) env reactors results =
|
11 | 11 |
let
|
12 | 12 |
result = case eval (IEnv catchException) env expr id of
|
13 | |
e@(List [(Symbol "uncaught-exception"), expr]) -> Left e
|
|
13 |
-- TODO This is less than fantastic. Should we have a dedicated error Expr?
|
|
14 |
e@(List [(Symbol "uncaught-exception"), expr]) -> Left expr
|
14 | 15 |
other -> Right other
|
15 | 16 |
in
|
16 | 17 |
collect rest env reactors (result:results)
|
4 | 4 |
import System.Environment
|
5 | 5 |
import System.Exit
|
6 | 6 |
|
7 | |
import Language.Robin.Expr
|
8 | 7 |
import Language.Robin.Env (mergeEnvs)
|
9 | 8 |
import Language.Robin.Parser (parseRobin)
|
10 | 9 |
import Language.Robin.Intrinsics (robinIntrinsics)
|
|
53 | 52 |
writeResults ((Right result):results) = do
|
54 | 53 |
putStrLn $ show result
|
55 | 54 |
writeResults results
|
56 | |
writeResults ((Left (List [(Symbol "uncaught-exception"), expr])):results) =
|
|
55 |
writeResults ((Left expr):results) =
|
57 | 56 |
error $ "uncaught exception: " ++ show expr
|
58 | |
writeResults ((Left expr):results) =
|
59 | |
error $ show expr
|
60 | 57 |
|
61 | 58 |
|
62 | 59 |
runReactors [] showEvents = return ()
|