GHC API: monad and error handling