freer-simple-catching: Checked runtime exceptions with freer-simple

[ control, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), freer-simple (>=1.1 && <1.2) [details]
License MIT
Copyright 2018 Ben Weitzman, Co-Star Astrology
Author Ben Weitzman
Maintainer ben@costarastrology.com
Category Control
Source repo head: git clone https://gitlab.com/costar-astrology/freer-simple-contrib/tree/master/freer-simple-catching
Uploaded by benweitzman at 2018-11-12T01:18:03Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 667 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-11-12 [all 1 reports]

Readme for freer-simple-catching-0.1.0.0

[back to package description]

freer-catching

This is library for working with exceptions that are thrown during interpreation of free monad effects, at call time.

How to use

This library exposes one effect:

catching :: forall e f a r
          . (Exception e, Member (Catching f e) r)
         => Eff '[f] a
         -> Eff r (Either e a)

We take an effectful function over one effect f and we turn it into an effectful computation of a new effect which denotes that we have an obligation to catch exceptions when we interpret this effect.

We can then discharge this obligation by interpretting the effect f and and any Catching effects built on f by interpretting them both at the same time:

runCatching :: forall e r v f
             . (Member IO r, Member IO (f ': r))
            => (forall a q . Member IO q => Eff (f ': q) a -> Eff q a)
            -> Eff (Catching f e : f : r) v
            -> Eff r v

We can also interpret a Catching f e effect by way of another effect g:

runCatching2 :: forall e r v f g
             . (Member IO r, Member IO (f : r), Member IO (f : g : r))
            => (forall a q. Member g q => Eff (f : q) a -> Eff q a)
            -> (forall a q. Member IO q => Eff (g : q) a -> Eff q a)
            -> Eff (Catching f e : f : g : r) v
            -> Eff r v