Skip to content

Instantly share code, notes, and snippets.

@eamelink
Created May 15, 2015 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eamelink/0aa02b1a94130f270027 to your computer and use it in GitHub Desktop.
Save eamelink/0aa02b1a94130f270027 to your computer and use it in GitHub Desktop.
module Main where
import qualified Debug.Trace as T
import Control.Alt
import Control.Monad.Aff
import Control.Monad.Eff
import Control.Monad.Eff.Exception
import Control.Monad.Error.Class
import Data.Either
main :: forall e. Eff (trace :: T.Trace | e) Unit
main = launchAff $ do
(throwError (error "Foo!")) `catchError` (const $ trace "bork!")
trace :: forall e a. (Show a) => a -> Aff (trace :: T.Trace | e) a
trace a = do
liftEff' $ T.trace (show a)
return a
{-
Output:
Compiling Main
Error in module Main:
Error in value declaration main:
Error at src/Main.purs line 3, column 1 - line 4, column 1:
No instance found for Control.Monad.Error.Class.MonadError u48 (Control.Monad.Aff.Aff (trace :: Debug.Trace.Trace | e27))
See https://github.com/purescript/purescript/wiki/Error-Code-NoInstanceFound for more information, or to contribute content related to this error.
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment