@@ -39,7 +39,7 @@ import qualified Paths_purescript as Paths
39import qualified System.IO.UTF8 as U (readFile)
39import qualified System.IO.UTF8 as U (readFile)
40import qualified Text.Parsec as Parsec (Parsec, eof)
40import qualified Text.Parsec as Parsec (Parsec, eof)
42−data PSCI = PSCI [P.ProperName] [P.Module] [P.DoNotationElement]
42+data PSCI = PSCI [P.ProperName] [P.Module] [P.Value -> P.Value]
44-- State helpers
44-- State helpers
45inputTToState :: InputT IO a -> StateT PSCI (InputT IO) a
45inputTToState :: InputT IO a -> StateT PSCI (InputT IO) a
@@ -54,7 +54,7 @@ updateImports name (PSCI i m b) = PSCI (i ++ [P.ProperName name]) m b
54updateModules :: [P.Module] -> PSCI -> PSCI
54updateModules :: [P.Module] -> PSCI -> PSCI
55updateModules modules (PSCI i m b) = PSCI i (m ++ modules) b
55updateModules modules (PSCI i m b) = PSCI i (m ++ modules) b
57−updateBinders :: P.DoNotationElement -> PSCI -> PSCI
57+updateBinders :: (P.Value -> P.Value) -> PSCI -> PSCI
58updateBinders name (PSCI i m b) = PSCI i m (b ++ [name])
58updateBinders name (PSCI i m b) = PSCI i m (b ++ [name])
60-- File helpers
60-- File helpers
@@ -121,18 +121,15 @@ completion ms = completeWord Nothing " \t\n\r" findCompletions
121options :: P.Options
121options :: P.Options
122options = P.Options True False True (Just "Main") True "PS" []
122options = P.Options True False True (Just "Main") True "PS" []
124−createTemporaryModule :: [P.ProperName] -> [P.DoNotationElement] -> P.Value -> P.Module
124+createTemporaryModule :: [P.ProperName] -> [P.Value -> P.Value] -> P.Value -> P.Module
125createTemporaryModule imports binders value =
125createTemporaryModule imports binders value =
127 moduleName = P.ModuleName [P.ProperName "Main"]
127 moduleName = P.ModuleName [P.ProperName "Main"]
128 importDecl m = P.ImportDeclaration m Nothing
128 importDecl m = P.ImportDeclaration m Nothing
129 traceModule = P.ModuleName [P.ProperName "Trace"]
129 traceModule = P.ModuleName [P.ProperName "Trace"]
130 trace = P.Var (P.Qualified (Just traceModule) (P.Ident "print"))
130 trace = P.Var (P.Qualified (Just traceModule) (P.Ident "print"))
131+ value' = foldr ($) value binders
131− mainDecl = P.ValueDeclaration (P.Ident "main") [] Nothing
132+ mainDecl = P.ValueDeclaration (P.Ident "main") [] Nothing (P.App trace value')
133− [ P.DoNotationBind (P.VarBinder (P.Ident "it")) value
134− , P.DoNotationValue (P.App trace (P.Var (P.Qualified Nothing (P.Ident "it"))) )
137 P.Module moduleName $ map (importDecl . P.ModuleName . return) imports ++ [mainDecl]
134 P.Module moduleName $ map (importDecl . P.ModuleName . return) imports ++ [mainDecl]
@@ -150,12 +147,9 @@ handleDeclaration value (PSCI imports loadedModules binders) = do
150 Nothing -> outputStrLn "Couldn't find node.js"
147 Nothing -> outputStrLn "Couldn't find node.js"
152-- Parser helpers
149-- Parser helpers
153−parseDoNotationLet :: Parsec.Parsec String P.ParseState P.DoNotationElement
150+parseDoNotationLet :: Parsec.Parsec String P.ParseState (P.Value -> P.Value)
154−parseDoNotationLet = P.DoNotationLet <$> (P.reserved "let" *> P.indented *> P.parseBinder)
151+parseDoNotationLet = P.Let <$> (P.reserved "let" *> P.indented *> P.parseBinder)
155− <*> (P.indented *> P.reservedOp "=" *> P.parseValue)
152+ <*> (P.indented *> P.reservedOp "=" *> P.parseValue)
157−parseDoNotationBind :: Parsec.Parsec String P.ParseState P.DoNotationElement
158−parseDoNotationBind = P.DoNotationBind <$> P.parseBinder <*> (P.indented *> P.reservedOp "<-" *> P.parseValue)
160parseExpression :: Parsec.Parsec String P.ParseState P.Value
154parseExpression :: Parsec.Parsec String P.ParseState P.Value
161parseExpression = P.whiteSpace *> P.parseValue <* Parsec.eof
155parseExpression = P.whiteSpace *> P.parseValue <* Parsec.eof