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

[ control, library, mit ] [ Propose Tags ]


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS]
Change log
Dependencies base (>=4.7 && <5), freer-simple (>=1.1 && <1.2) [details]
License MIT
Copyright 2018 Ben Weitzman, Co-Star Astrology
Author Ben Weitzman
Category Control
Source repo head: git clone
Uploaded by benweitzman at 2018-11-12T01:18:03Z
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 647 total (2 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-

[back to package description]


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