-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.hs
34 lines (30 loc) · 893 Bytes
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Ixl (parseIxl)
import System.Console.Readline (readline, addHistory)
import System.Posix (queryTerminal)
makeRepl :: (String -> IO ()) -> String -> IO ()
makeRepl interp prompt = do
line <- readline prompt
case line of
Nothing -> putStrLn ""
Just str -> do
addHistory str
interp str
makeRepl interp prompt
repl :: String -> IO ()
repl = makeRepl $ \input -> do
case parseIxl "(repl)" input of
Left error -> print error
Right tree -> print tree -- evalIxl tree >>= print
-- runInput = do
-- c <- getContents
-- case parseIxl "(stdin)" c of
-- Left e -> do putStrLn "Error parsing input:"
-- print e
-- Right r -> do
-- print r
-- return ()
main = repl ".> "
-- isatty <- queryTerminal 0
-- case isatty of
-- True -> repl ".> "
-- False -> runInput