Copyright | (C) 2013-2016 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- class Handleable e (m :: * -> *) (h :: * -> *) | h -> e m where
- data HandlingException = HandlingException
Documentation
class Handleable e (m :: * -> *) (h :: * -> *) | h -> e m where Source #
Both
exceptions
and
Control.Exception
provide a
Handler
type.
This lets us write combinators to build handlers that are agnostic about the choice of which of these they use.
handler :: Typeable a => Getting ( First a) e a -> (a -> m r) -> h r Source #
This builds a
Handler
for just the targets of a given
Prism
(or any
Getter
, really).
catches
... [handler
_AssertionFailed
(s ->$
"Assertion Failed\n"++
s) ,handler
_ErrorCall
(s ->$
"Error\n"++
s) ]
This works ith both the
Handler
type provided by
Control.Exception
:
handler
::Getter
SomeException
a -> (a ->IO
r) ->Handler
rhandler
::Fold
SomeException
a -> (a ->IO
r) ->Handler
rhandler
::Prism'
SomeException
a -> (a ->IO
r) ->Handler
rhandler
::Lens'
SomeException
a -> (a ->IO
r) ->Handler
rhandler
::Traversal'
SomeException
a -> (a ->IO
r) ->Handler
r
and with the
Handler
type provided by
Control.Monad.Catch
:
handler
::Getter
SomeException
a -> (a -> m r) ->Handler
m rhandler
::Fold
SomeException
a -> (a -> m r) ->Handler
m rhandler
::Prism'
SomeException
a -> (a -> m r) ->Handler
m rhandler
::Lens'
SomeException
a -> (a -> m r) ->Handler
m rhandler
::Traversal'
SomeException
a -> (a -> m r) ->Handler
m r
and with the
Handler
type provided by
Control.Monad.Error.Lens
:
handler
::Getter
e a -> (a -> m r) ->Handler
e m rhandler
::Fold
e a -> (a -> m r) ->Handler
e m rhandler
::Prism'
e a -> (a -> m r) ->Handler
e m rhandler
::Lens'
e a -> (a -> m r) ->Handler
e m rhandler
::Traversal'
e a -> (a -> m r) ->Handler
e m r
handler_ :: Typeable a => Getting ( First a) e a -> m r -> h r Source #
This builds a
Handler
for just the targets of a given
Prism
(or any
Getter
, really).
that ignores its input and just recovers with the stated monadic action.
catches
... [handler_
_NonTermination
(return
"looped") ,handler_
_StackOverflow
(return
"overflow") ]
This works with the
Handler
type provided by
Control.Exception
:
handler_
::Getter
SomeException
a ->IO
r ->Handler
rhandler_
::Fold
SomeException
a ->IO
r ->Handler
rhandler_
::Prism'
SomeException
a ->IO
r ->Handler
rhandler_
::Lens'
SomeException
a ->IO
r ->Handler
rhandler_
::Traversal'
SomeException
a ->IO
r ->Handler
r
and with the
Handler
type provided by
Control.Monad.Catch
:
handler_
::Getter
SomeException
a -> m r ->Handler
m rhandler_
::Fold
SomeException
a -> m r ->Handler
m rhandler_
::Prism'
SomeException
a -> m r ->Handler
m rhandler_
::Lens'
SomeException
a -> m r ->Handler
m rhandler_
::Traversal'
SomeException
a -> m r ->Handler
m r
and with the
Handler
type provided by
Control.Monad.Error.Lens
:
handler_
::Getter
e a -> m r ->Handler
e m rhandler_
::Fold
e a -> m r ->Handler
e m rhandler_
::Prism'
e a -> m r ->Handler
e m rhandler_
::Lens'
e a -> m r ->Handler
e m rhandler_
::Traversal'
e a -> m r ->Handler
e m r
Instances
Handleable SomeException IO Handler Source # | |
Typeable m => Handleable SomeException m ( Handler m) Source # | |
Handleable e m ( Handler e m) Source # | |
data HandlingException Source #