effect-handlers-0.1.0.0

Safe HaskellNone
LanguageHaskell2010

Control.Effects.Free.Exception

Synopsis

Documentation

This module provides a simple exception throwind effect with a single operation throw and two ready-made handlers

newtype Exception m a

The functor representing the exception. You shouldn't need to create this manually, just use throw.

Constructors

Exception m 

Instances

Functor (Exception m) 
Typeable (* -> * -> *) Exception 

throw :: (Member (Exception a) r, Typeable a) => a -> Eff r b

Throw an exception. The only requirement is that exception be typeable.

exceptionHandler :: Handler (Exception m) r a (Either m a)

This handler converts an program that might throw an exception into a program that returns either its result or the exception.

defValueExceptionHandler :: a -> Handler (Exception m) r a a

This function generates a handler that upon a throw short-circuts the computation and returns the default value instead.