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

[ control, library, mit ] [ Propose Tags ]

Please see the README on Gitlab at https://gitlab.com/costar-astrology/freer-simple-contrib/tree/master/freer-simple-catching


[Skip to Readme]
Versions [faq] 0.1.0.0
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), freer-simple (==1.1.*) [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 Mon Nov 12 01:18:03 UTC 2018
Distributions NixOS:0.1.0.0
Downloads 149 total (12 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2018-11-12 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


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