2 | import public Idrall.Expr
3 | import public Idrall.Value
4 | import public Idrall.Error
7 | import Idrall.ParserNew
8 | import Idrall.Resolve
9 | import public Idrall.IOEither
12 | import System.Directory
18 | parseWith : String -> Either String (Expr ImportStatement, Int)
19 | parseWith = Idrall.ParserNew.parseExprNew
22 | exprFromString : String -> IOEither Error (Expr Void)
23 | exprFromString x = do
24 | x' <- mapErr (ParseError initFC) (liftEither (parseWith x))
25 | resolve [] Nothing (fst x')
28 | resolveFromString : Maybe FilePath -> String -> IOEither Error (Expr Void)
29 | resolveFromString path x = do
30 | x' <- mapErr (ParseError initFC) (liftEither (parseWith x))
31 | resolve [] path (fst x')
34 | roundTripEval : String -> IOEither Error Value
35 | roundTripEval x = do
36 | x' <- exprFromString x
37 | liftEither (eval Empty x')
40 | roundTripCheckEval : String -> IOEither Error Value
41 | roundTripCheckEval x = do
42 | x' <- exprFromString x
43 | _ <- liftEither (infer initCxt x')
44 | liftEither (eval Empty x')
46 | evalQuote : Expr Void -> Either Error (Expr Void)
53 | roundTripEvalQuote : String -> IOEither Error (Expr Void)
54 | roundTripEvalQuote x = do
55 | xE <- exprFromString x
56 | liftEither (evalQuote xE)
59 | roundTripCheckEvalQuote : String -> IOEither Error (Expr Void)
60 | roundTripCheckEvalQuote x = do
61 | xV <- roundTripCheckEval x
62 | xE <- liftEither (quote [] xV)
66 | roundTripEvalQuoteConv : String -> String -> IOEither Error ()
67 | roundTripEvalQuoteConv x y = do
68 | xE <- exprFromString x
69 | xNf <- liftEither (evalQuote xE)
70 | yE <- exprFromString y
71 | yNf <- liftEither (evalQuote yE)
72 | _ <- liftEither $
conv Empty !(liftEither $
eval Empty xNf) !(liftEither $
eval Empty yNf)
76 | roundTripSynth : String -> IOEither Error (Expr Void, Value)
77 | roundTripSynth x = do
78 | x' <- exprFromString x
79 | liftEither (infer initCxt x')
82 | roundTripSynthEvalQuote : String -> IOEither Error (Expr Void)
83 | roundTripSynthEvalQuote x = do
84 | x' <- exprFromString x
85 | _ <- liftEither (infer initCxt x')
86 | liftEither (evalQuote x')
89 | roundTripCheck : String -> String -> IOEither Error ()
90 | roundTripCheck x y = do
91 | x' <- exprFromString x
92 | y' <- roundTripEval y
93 | _ <- liftEither (check initCxt x' y')
97 | roundTripConv : String -> String -> IOEither Error ()
98 | roundTripConv x y = do
99 | do x' <- roundTripEval x
100 | y' <- roundTripEval y
101 | _ <- liftEither $
conv Empty x' y'
105 | valueFromString : String -> IOEither Error Value
106 | valueFromString x = do
107 | _ <- roundTripSynth x
111 | showIOEither : Show a => Show b => IOEither a b -> IO String
112 | showIOEither (MkIOEither x) =
115 | (Left l) => pure $
"Error: " ++ show l
116 | (Right r) => pure $
"Success: " ++ show r
119 | doStuff : Show a => Show b => (String -> IOEither a b) -> String -> IO ()
121 | putStrLn !(showIOEither (f x))