| mueval-0.7.1: Safely evaluate Haskell expressions | Source code | Contents | Index

Mueval.Interpreter

Synopsis

interpreter :: Bool -> Bool -> Maybe [ModuleName] -> String -> String -> Interpreter (String, String, String)
interpreterSession :: Bool -> Bool -> Bool -> Maybe [ModuleName] -> String -> String -> IO ()
mvload :: FilePath -> IO ()
sayIO :: String -> IO ()
printInterpreterError :: InterpreterError -> IO ()
exceptionMsg :: String
render :: MonadIO m => Int -> String -> m (String, Bool)

data Stream

= Cons Char (IO Stream)
| Exception (IO Stream)
| End

toStream :: String -> IO Stream

Documentation

interpreter :: Bool -> Bool -> Maybe [ModuleName] -> String -> String -> Interpreter (String, String, String) | Source

The actual calling of Hint functionality. The heart of this just calls `eval`, but we do so much more - we disable Haskell extensions, hide all packages, make sure one cannot call unimported functions, typecheck, set resource limits for this thread, and do some error handling.

interpreterSession | Source

:: Bool | Whether to print inferred type
-> Bool | Whether to use GHC extensions
-> Bool | Whether to use rlimits
-> Maybe [ModuleName] | A list of modules we wish to be visible
-> String | A local file from which to grab definitions; an empty string is treated as no file.
-> String | The string to be interpreted as a Haskell expression
-> IO () | No real result, since we print no matter the result.
Wrapper around `interpreter`; supplies a fresh GHC API session and error-handling. The arguments are largely passed on, and the results lightly parsed.

mvload :: FilePath -> IO () | Source

sayIO :: String -> IO () | Source

Print the String (presumably the result of interpreting something), but only print the first 1024 characters to avoid flooding. Lambdabot has a similar limit.

printInterpreterError :: InterpreterError -> IO () | Source

Oh no, something has gone wrong. If it's a compilation error pretty print the first 1024 chars of it and throw an ExitException otherwise rethrow the exception in String form.

exceptionMsg :: String | Source

render | Source

:: MonadIO m |
=> Int | max number of characters to include
-> String | input
-> m (String, Bool) | ( output, `True` if we found an exception )
Renders the input String including its exceptions using `exceptionMsg`

data Stream | Source

Constructors

Cons Char (IO Stream) |
Exception (IO Stream) |
End |

toStream :: String -> IO Stream | Source

Produced by Haddock version 2.4.2