[Haskell-cafe] Problems with Language.Haskell.Interpreter and errors

Martin Hofmann martin.hofmann at uni-bamberg.de
Tue Sep 29 07:56:32 EDT 2009


The API of Language.Haskell.Interpreter says, that 'runInterpreter'

runInterpreter :: (MonadCatchIO m, Functor m) =>
	InterpreterT m a -> 
	m (Either InterpreterError a)

returns 'Left' in case of errors and 'GhcExceptions from the underlying
GHC API are caught and rethrown as this'.

What kind of errors do a generate here, why are they not caught by
runInterpreter and how can I catch them? I assumed to get a 'Left
InterpreterError' from the first and an error in MonadCatchIO in the

> :m +Language.Haskell.Interpreter
> let estr1 = "let lst [a] = a; lst _ = error \"foo\" in lst []"
> let estr1 = "let lst [a] = a; in lst []"
> runInterpreter (setImportsQ [("Prelude", Nothing)] >> eval estr1 )
Right "*** Exception: foo
> runInterpreter ( eval estr2)
Right "*** Exception: <interactive>:1:101-111: Non-exhaustive patterns in function lst

Thanks a lot

More information about the Haskell-Cafe mailing list