Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the checkpointCallStack from MonadUnliftIO module #14

Merged
merged 4 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
cabal: ["3.4"]
cabal: ["3.6"]
ghc: ["8.6.5", "8.8.4", "8.10.7", "9.0.2", "9.2.2"]
env:
CONFIG: "--enable-tests"
Expand All @@ -25,15 +25,15 @@ jobs:
cabal-version: ${{ matrix.cabal }}
- run: cabal v2-update
- run: cabal v2-freeze $CONFIG
- uses: actions/cache@v2
with:
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
${{ runner.os }}-${{ matrix.ghc }}-
# - uses: actions/cache@v2
# with:
# path: |
# ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
# dist-newstyle
# key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
# restore-keys: |
# ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
# ${{ runner.os }}-${{ matrix.ghc }}-
- run: cabal v2-build --disable-optimization -j $CONFIG
- run: cabal v2-test --disable-optimization -j $CONFIG
- run: cabal v2-haddock -j $CONFIG
Expand Down
8 changes: 6 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog for located-exception
# Changelog for `annotated-exception`

## Unreleased changes
## 0.2.0.2

- [#14](https://github.com/parsonsmatt/annotated-exception/pull/14)
- Define `Control.Exception.Annotated.UnliftIO.checkpointCallStack` without
re-exporting the `MonadCatch` variant. Sigh.

## 0.2.0.1

Expand Down
2 changes: 1 addition & 1 deletion annotated-exception.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: annotated-exception
version: 0.2.0.1
version: 0.2.0.2
synopsis: Exceptions, with checkpoints and context.
description: Please see the README on Github at <https://github.com/parsonsmatt/annotated-exception#readme>
category: Control
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: annotated-exception
version: 0.2.0.1
version: 0.2.0.2
github: "parsonsmatt/annotated-exception"
license: BSD3
author: "Matt Parsons"
Expand Down
33 changes: 23 additions & 10 deletions src/Control/Exception/Annotated/UnliftIO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ module Control.Exception.Annotated.UnliftIO
, MonadUnliftIO(..)
) where

import Control.Exception.Annotated hiding
( catch
, catches
, checkpoint
, checkpointCallStackWith
, checkpointMany
, throw
, throwWithCallStack
, try
, tryAnnotated
import Control.Exception.Annotated
( AnnotatedException(..)
, Annotation(..)
, CallStackAnnotation(..)
, Exception(..)
, Handler(..)
, addCallStackToException
, annotatedExceptionCallStack
, check
, exceptionWithCallStack
, hide
)
import qualified Control.Exception.Annotated as Catch
import qualified Control.Exception.Safe as Safe
Expand Down Expand Up @@ -77,6 +78,18 @@ checkpoint :: forall m a. (MonadUnliftIO m, HasCallStack) => Annotation -> m a -
checkpoint ann action = withRunInIO $ \runInIO ->
liftIO $ withFrozenCallStack (Catch.checkpoint ann) (runInIO action)

-- | Like 'Catch.checkpointCallStack', but uses 'MonadUnliftIO' instead of
-- 'Control.Monad.Catch.MonadCatch'.
--
-- @since 0.2.0.2
checkpointCallStack
:: forall m a. (MonadUnliftIO m, HasCallStack)
=> m a
-> m a
checkpointCallStack action =
withRunInIO $ \runInIO ->
withFrozenCallStack Catch.checkpointCallStack (runInIO action)

-- | Like 'Catch.checkpointMany', but uses 'MonadUnliftIO' instead of
-- 'Control.Monad.Catch.MonadCatch'.
--
Expand Down
2 changes: 2 additions & 0 deletions test/Control/Exception/Annotated/UnliftIOSpec.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# language RecordWildCards, StrictData, RankNTypes #-}

module Control.Exception.Annotated.UnliftIOSpec where

import Test.Hspec
Expand Down