From a2e39776ce35e5e96730d0730a38f764420626df Mon Sep 17 00:00:00 2001 From: Sandy Maguire Date: Wed, 26 Jun 2019 00:29:26 -0400 Subject: [PATCH] Release polysemy 0.5.0.0 --- ChangeLog.md | 32 +++++++++++++++++++++++-------- package.yaml | 2 +- polysemy.cabal | 4 ++-- src/Polysemy.hs | 4 ++++ src/Polysemy/Async.hs | 12 +++++++----- src/Polysemy/Internal/Forklift.hs | 9 +++++---- src/Polysemy/Internal/Kind.hs | 4 ++-- src/Polysemy/Internal/Union.hs | 2 +- src/Polysemy/Resource.hs | 5 +++-- src/Polysemy/Trace.hs | 2 +- 10 files changed, 50 insertions(+), 26 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 0dc097d..3eb373d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,29 @@ # Changelog for polysemy +## 0.5.0.0 (2019-06-26) + +### Breaking Changes + +- Removed the internal `Effect` machinery + +### New Effects and Interpretations + +- New effect; `Async`, for describing asynchronous computations +- New interpretation for `Resource`: `runResourceBase`, which can lower + `Resource` effects without giving a lowering natural transformation +- New interpretation for `Trace`: `runTraceAsList` +- New combinator: `withLowerToIO`, which is capable of transforming + `IO`-invariant functions as effects. + +### Other Changes + +- Lots of hard work on the package and CI infrastructure to make it green on + GHC 8.4.4 (thanks to @jkachmar) +- Changed the order of the types for `runMonadicInput` to be more helpful + (thanks to @tempname11) +- Improved the error machinery to be more selective about when it runs +- Factored out the TH into a common library for third-party consumers + ## 0.4.0.0 (2019-06-12) ### Breaking Changes @@ -84,11 +108,3 @@ ## Unreleased changes -- Lots of hard work on the package and CI infrastructure to make it green on - GHC 8.4.4 (thanks to @jkachmar) -- runResourceBase -- runTraceAsList -- New effect: Async -- Changed the order of the types for `runMonadicInput` to be more helpful - (thanks to @tempname11) - diff --git a/package.yaml b/package.yaml index 68015e8..ab90f77 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: polysemy -version: 0.4.0.0 +version: 0.5.0.0 github: "isovector/polysemy" license: BSD3 author: "Sandy Maguire" diff --git a/polysemy.cabal b/polysemy.cabal index d96b748..4ba1015 100644 --- a/polysemy.cabal +++ b/polysemy.cabal @@ -4,10 +4,10 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 89bd1eac9f4b2121d6cd6394446982b43db63e8ba7c5ccd8e295dae66fd20969 +-- hash: 022b4ccf6d38c802d8cbfa8835a7e832c23eba47ccf428861ac5016b7ad596d8 name: polysemy -version: 0.4.0.0 +version: 0.5.0.0 synopsis: Higher-order, low-boilerplate, zero-cost free monads. description: Please see the README on GitHub at category: Language diff --git a/src/Polysemy.hs b/src/Polysemy.hs index acc74c1..f249b51 100644 --- a/src/Polysemy.hs +++ b/src/Polysemy.hs @@ -89,6 +89,9 @@ module Polysemy , reinterpret2H , reinterpret3H + -- * Combinators for Interpreting Directly to IO + , withLowerToIO + -- * Kind Synonyms , Effect , EffectRow @@ -118,6 +121,7 @@ module Polysemy import Polysemy.Internal import Polysemy.Internal.Combinators +import Polysemy.Internal.Forklift import Polysemy.Internal.Kind import Polysemy.Internal.TH.Effect import Polysemy.Internal.Tactics diff --git a/src/Polysemy/Async.hs b/src/Polysemy/Async.hs index 390b791..495dd8c 100644 --- a/src/Polysemy/Async.hs +++ b/src/Polysemy/Async.hs @@ -15,14 +15,16 @@ module Polysemy.Async import qualified Control.Concurrent.Async as A import Polysemy -import Polysemy.Internal.Forklift ------------------------------------------------------------------------------ --- | +-- | An effect for spawning asynchronous computations. -- --- TODO(sandy): @since +-- The 'Maybe' returned by 'async' is due to the fact that we can't be sure an +-- 'Polysemy.Error.Error' effect didn't fail locally. +-- +-- @since 0.5.0.0 data Async m a where Async :: m a -> Async m (A.Async (Maybe a)) Await :: A.Async a -> Async m a @@ -37,7 +39,7 @@ makeSem ''Async -- Notably, this means that 'Polysemy.State.State' effects will be consistent -- in the presence of 'Async'. -- --- TODO(sandy): @since +-- @since 0.5.0.0 runAsync :: LastMember (Lift IO) r => Sem (Async ': r) a @@ -68,7 +70,7 @@ runAsync_b = runAsync -- | Run an 'Async' effect via in terms of 'A.async'. -- -- --- TODO(sandy): @since +-- @since 0.5.0.0 runAsyncInIO :: Member (Lift IO) r => (forall x. Sem r x -> IO x) diff --git a/src/Polysemy/Internal/Forklift.hs b/src/Polysemy/Internal/Forklift.hs index 59a9efe..d5439a6 100644 --- a/src/Polysemy/Internal/Forklift.hs +++ b/src/Polysemy/Internal/Forklift.hs @@ -2,13 +2,14 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} +{-# OPTIONS_HADDOCK not-home #-} + module Polysemy.Internal.Forklift where import qualified Control.Concurrent.Async as A import Control.Concurrent.Chan.Unagi import Control.Concurrent.MVar import Control.Monad -import Polysemy import Polysemy.Internal import Polysemy.Internal.Union @@ -16,7 +17,7 @@ import Polysemy.Internal.Union ------------------------------------------------------------------------------ -- | A promise for interpreting an effect of the union @r@ in another thread. -- --- TODO(sandy): @since +-- @since 0.5.0.0 data Forklift r = forall a. Forklift { responseMVar :: MVar (Sem '[Lift IO] a) , request :: Union r (Sem r) a @@ -27,7 +28,7 @@ data Forklift r = forall a. Forklift -- | A strategy for automatically interpreting an entire stack of effects by -- just shipping them off to some other interpretation context. -- --- TODO(sandy): @since +-- @since 0.5.0.0 runViaForklift :: LastMember (Lift IO) r => InChan (Forklift r) @@ -58,7 +59,7 @@ runViaForklift_b = runViaForklift -- -- This function creates a thread, and so should be compiled with @-threaded@. -- --- TODO(sandy): @since +-- @since 0.5.0.0 withLowerToIO :: LastMember (Lift IO) r => ((forall x. Sem r x -> IO x) -> IO () -> IO a) diff --git a/src/Polysemy/Internal/Kind.hs b/src/Polysemy/Internal/Kind.hs index fe22a76..358f820 100644 --- a/src/Polysemy/Internal/Kind.hs +++ b/src/Polysemy/Internal/Kind.hs @@ -5,12 +5,12 @@ import Data.Kind ------------------------------------------------------------------------------ -- | The kind of effects. -- --- TODO(sandy): @since +-- @since 0.5.0.0 type Effect = (Type -> Type) -> Type -> Type ------------------------------------------------------------------------------ -- | The kind of effect rows. -- --- TODO(sandy): @since +-- @since 0.5.0.0 type EffectRow = [Effect] diff --git a/src/Polysemy/Internal/Union.hs b/src/Polysemy/Internal/Union.hs index 61e6bf6..4ae2f21 100644 --- a/src/Polysemy/Internal/Union.hs +++ b/src/Polysemy/Internal/Union.hs @@ -245,7 +245,7 @@ decompCoerce (Union p a) = ------------------------------------------------------------------------------ -- | A proof that @end@ is the last effect in the row. -- --- TODO(sandy): @since +-- @since 0.5.0.0 class MemberNoError end r => LastMember end r | r -> end where decompLast :: Union r m a diff --git a/src/Polysemy/Resource.hs b/src/Polysemy/Resource.hs index 9c6fd69..a589ec1 100644 --- a/src/Polysemy/Resource.hs +++ b/src/Polysemy/Resource.hs @@ -18,7 +18,6 @@ module Polysemy.Resource import qualified Control.Exception as X import Polysemy -import Polysemy.Internal.Forklift ------------------------------------------------------------------------------ @@ -163,7 +162,9 @@ runResource = interpretH $ \case -- explicitly at the main thread. If this is not safe enough for your use-case, -- use 'runResourceInIO' instead. -- --- TODO(sandy): @since version +-- This function creates a thread, and so should be compiled with @-threaded@. +-- +-- @since 0.5.0.0 runResourceBase :: forall r a . LastMember (Lift IO) r diff --git a/src/Polysemy/Trace.hs b/src/Polysemy/Trace.hs index aa70975..abe8c5a 100644 --- a/src/Polysemy/Trace.hs +++ b/src/Polysemy/Trace.hs @@ -59,7 +59,7 @@ runTraceAsOutput = interpret $ \case ------------------------------------------------------------------------------ -- | Get the result of a 'Trace' effect as a list of 'String's. -- --- TODO(sandy): @since +-- @since 0.5.0.0 runTraceAsList :: Sem (Trace ': r) a -> Sem r ([String], a)