giml-compiler-0.1.0.0: A Giml->JavaScript compiler
Safe HaskellNone
LanguageHaskell2010

Language.Giml.Compiler.REPL

Description

REPL for Giml

Synopsis

Run

runRepl :: Maybe FilePath -> IO () Source #

Run a REPL, optionally load a source file

replWithHandler :: InputT Repl () Source #

Runs the repl while handling interrupts (Ctrl-C)

repl :: InputT Repl () Source #

Read & process loop

Utils

Types

data ReplState Source #

Instances

Instances details
Show ReplState Source # 
Instance details

Defined in Language.Giml.Compiler.REPL

Repl command and processing

loadFile :: MonadReader Env m => MonadIO m => FilePath -> m () Source #

Load a source file into environment

replCommands :: [(String, String -> InputT Repl ())] Source #

Repl commands (start with :)

printTypeOfExpr :: MonadReader Env m => MonadIO m => String -> m () Source #

Print the type of an expression command

processInput :: MonadReader Env m => MonadIO m => String -> m () Source #

Process user input (read expressions, evaluate and print)

Handle Repl State

getCurrentText :: MonadReader Env m => MonadIO m => m (Maybe Text) Source #

If a user is in the middle of writing multiline input, This will return Just text-until-now.

putCurrentText :: MonadReader Env m => MonadIO m => Maybe Text -> m () Source #

Set the input the user might be in the middle of writing (multiline input)

getLoggerInfo :: MonadReader Env m => MonadIO m => FilePath -> m (LogAction IO LogMsg) Source #

Get the currently defined definitions in the environment

getFile :: MonadReader Env m => MonadIO m => m (ParsedFile InputAnn) Source #

Get the currently defined definitions in the environment

putFile :: MonadReader Env m => MonadIO m => ParsedFile InputAnn -> m () Source #

Put the currently defined definitions in the environment

Parsed File manipulation

overridedef :: Definition InputAnn -> [Definition InputAnn] -> [Definition InputAnn] Source #

Add a definition or override an existing definition

joinIOForMain :: File Ann -> File Ann Source #

join the expression that needs to be printed if it's an IO expression

mkProgram :: Expr InputAnn -> [Definition InputAnn] -> ParsedFile InputAnn Source #

create a program from an expression and definitions

extractType :: File Ann -> Maybe Type Source #

Extract the type of the expression in the REPL. This should generally always work.

instType :: Type -> Type Source #

Replace type variables with lower numbered type variables

renameMainVars :: Data a => a -> a Source #

We want to preserve the main of a loaded file in case the user want to call it. This function will change "main" to "_main" in all expressions.

renameMainDef :: [Definition InputAnn] -> [Definition InputAnn] Source #

We want to preserve the main of a loaded file in case the user want to call it This function will change the name of the definition "main" to "_main".

Settings