-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.hs
35 lines (27 loc) · 998 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
module Main where
import System.IO
import Control.Applicative
import Control.Monad.Trans.Reader
import qualified Data.Map as Map
import Parser
import TypeInferencer
import Interpreter
import Ast
main :: IO ()
main = withFile
"test/lambda.js"
ReadMode
(\handle -> do
source <- hGetContents handle
-- putStrLn $ show $ jsparse source
putStrLn $ interpreter source
)
-- Some glue code
interpreter :: String -> String
interpreter source = case jsparse source of
Right ts -> (case interp ts of Right s -> s
Left e -> e)
Left error -> show error
where interp t = do ty <- typeInference t
let result = interpreate t
return $ show result ++ " : " ++ show ty