Release polysemy 0.5.0.0

This commit is contained in:
Sandy Maguire 2019-06-26 00:29:26 -04:00
parent 33a6d95dab
commit a2e39776ce
10 changed files with 50 additions and 26 deletions

View File

@ -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)

View File

@ -1,5 +1,5 @@
name: polysemy
version: 0.4.0.0
version: 0.5.0.0
github: "isovector/polysemy"
license: BSD3
author: "Sandy Maguire"

View File

@ -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 <https://github.com/isovector/polysemy#readme>
category: Language

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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)