polysemy 1.8.0.0 → 1.9.0.0
raw patch · 44 files changed
+446/−141 lines, 44 filesdep ~doctestPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: doctest
API changes (from Hackage documentation)
- Polysemy.Internal.CustomErrors: infixl 5 <>
- Polysemy.Internal.CustomErrors: infixr 4 %
- Polysemy.Internal.CustomErrors: type family (%) (t :: k1) (b :: k2) :: ErrorMessage
- Polysemy.Internal.CustomErrors.Redefined: data AnythingOfAnyKind
- Polysemy.Internal.Index: instance forall a (index :: GHC.Types.Nat) (head :: [a]) (tail :: [a]) (oldTail :: [a]) (full :: [a]) (insertedTail :: [a]) (inserted :: [a]) (e :: a). (Polysemy.Internal.Index.InsertAtIndex index head tail oldTail full insertedTail, inserted GHC.Types.~ (e : insertedTail)) => Polysemy.Internal.Index.InsertAtIndex index head (e : tail) oldTail full inserted
- Polysemy.Internal.Index: instance forall k (index :: GHC.Types.Nat) (oldTail :: [k]) (head :: [k]) (full :: [k]) (tail :: [k]) (inserted :: [k]). (TypeError ...) => Polysemy.Internal.Index.InsertAtIndex index head tail oldTail full inserted
- Polysemy.Internal.Index: instance forall k (inserted :: [k]) (index :: GHC.Types.Nat) (head :: [k]) (oldTail :: [k]) (full :: [k]). (inserted GHC.Types.~ '[]) => Polysemy.Internal.Index.InsertAtIndex index head oldTail oldTail full inserted
- Polysemy.Internal.Index: type InsertAtFailure index soughtTail head full = "insertAt: Failed to insert effects at index " <> 'ShowType index % "There is a mismatch between what's been determined as the head and tail between the newly inserted effects," <> " and the actual desired return type." % "Determined head before inserted effects:" % "\t" <> 'ShowType head % "Determined tail after the inserted effects:" % "\t" <> 'ShowType soughtTail % "Actual desired return type:" % "\t" <> 'ShowType full % "Make sure that the index provided to insertAt is correct, and that the desired return type simply requires" <> " inserting effects."
- Polysemy.Internal.Index: type family InsertAtUnprovidedIndex
- Polysemy.Internal.Sing: instance forall a (xs :: [a]) (x :: a). Polysemy.Internal.Sing.KnownList xs => Polysemy.Internal.Sing.KnownList (x : xs)
- Polysemy.Internal.TH.Common: splitArrowTs :: Type -> [Type]
- Polysemy.Internal.Union: hoist :: (forall x. m x -> n x) -> Union r m a -> Union r n a
- Polysemy.Internal.Union: weave :: (Functor s, Functor n) => s () -> (forall x. s (m x) -> n (s x)) -> (forall x. s x -> Maybe x) -> Union r m a -> Union r n (s a)
- Polysemy.Internal.Writer: interpretViaLazyWriter :: forall o e r a. Monoid o => (forall m x. Monad m => Weaving e (WriterT o m) x -> WriterT o m x) -> Sem (e : r) a -> Sem r (o, a)
+ Polysemy.Internal.Index: instance forall a (index :: GHC.TypeNats.Nat) (head :: [a]) (tail :: [a]) (oldTail :: [a]) (full :: [a]) (insertedTail :: [a]) (inserted :: [a]) (e :: a). (Polysemy.Internal.Index.InsertAtIndex index head tail oldTail full insertedTail, inserted GHC.Types.~ (e : insertedTail)) => Polysemy.Internal.Index.InsertAtIndex index head (e : tail) oldTail full inserted
+ Polysemy.Internal.Index: instance forall k (inserted :: [k]) (index :: GHC.TypeNats.Nat) (head :: [k]) (oldTail :: [k]) (full :: [k]). (inserted GHC.Types.~ '[]) => Polysemy.Internal.Index.InsertAtIndex index head oldTail oldTail full inserted
+ Polysemy.Internal.Scoped: [OuterRun] :: forall effect m a. Word -> effect m a -> OuterRun effect m a
+ Polysemy.Internal.Scoped: data OuterRun (effect :: Effect) :: Effect
+ Polysemy.Internal.Sing: instance forall k (xs :: [k]) (x :: k). Polysemy.Internal.Sing.KnownList xs => Polysemy.Internal.Sing.KnownList (x : xs)
+ Polysemy.Opaque: Opaque :: e m a -> Opaque (e :: Effect) m a
+ Polysemy.Opaque: fromOpaque :: Sem (Opaque e ': r) a -> Sem (e ': r) a
+ Polysemy.Opaque: newtype Opaque (e :: Effect) m a
+ Polysemy.Opaque: toOpaque :: Sem (e ': r) a -> Sem (Opaque e ': r) a
+ Polysemy.Scoped: runScopedNew :: forall param effect r. (forall q. param -> InterpreterFor effect (Opaque q ': r)) -> InterpreterFor (Scoped param effect) r
+ Polysemy.Scoped: type Scoped_ effect = Scoped () effect
- Polysemy: [Embed] :: {unEmbed :: m a} -> Embed m z a
+ Polysemy: [Embed] :: m a -> Embed m z a
- Polysemy: bindT :: (a -> m b) -> Sem (WithTactics e f m r) (f a -> Sem (e : r) (f b))
+ Polysemy: bindT :: (a -> m b) -> Sem (WithTactics e f m r) (f a -> Sem (e ': r) (f b))
- Polysemy: embedToFinal :: (Member (Final m) r, Functor m) => Sem (Embed m : r) a -> Sem r a
+ Polysemy: embedToFinal :: (Member (Final m) r, Functor m) => Sem (Embed m ': r) a -> Sem r a
- Polysemy: interpret :: FirstOrder e "interpret" => (forall rInitial x. e (Sem rInitial) x -> Sem r x) -> Sem (e : r) a -> Sem r a
+ Polysemy: interpret :: FirstOrder e "interpret" => (forall rInitial x. e (Sem rInitial) x -> Sem r x) -> Sem (e ': r) a -> Sem r a
- Polysemy: interpretH :: (forall rInitial x. e (Sem rInitial) x -> Tactical e (Sem rInitial) r x) -> Sem (e : r) a -> Sem r a
+ Polysemy: interpretH :: (forall rInitial x. e (Sem rInitial) x -> Tactical e (Sem rInitial) r x) -> Sem (e ': r) a -> Sem r a
- Polysemy: raise :: forall e r a. Sem r a -> Sem (e : r) a
+ Polysemy: raise :: forall e r a. Sem r a -> Sem (e ': r) a
- Polysemy: raiseUnder :: forall e2 e1 r a. Sem (e1 : r) a -> Sem (e1 : (e2 : r)) a
+ Polysemy: raiseUnder :: forall e2 e1 r a. Sem (e1 ': r) a -> Sem (e1 ': (e2 ': r)) a
- Polysemy: raiseUnder2 :: forall e2 e3 e1 r a. Sem (e1 : r) a -> Sem (e1 : (e2 : (e3 : r))) a
+ Polysemy: raiseUnder2 :: forall e2 e3 e1 r a. Sem (e1 ': r) a -> Sem (e1 ': (e2 ': (e3 ': r))) a
- Polysemy: raiseUnder3 :: forall e2 e3 e4 e1 r a. Sem (e1 : r) a -> Sem (e1 : (e2 : (e3 : (e4 : r)))) a
+ Polysemy: raiseUnder3 :: forall e2 e3 e4 e1 r a. Sem (e1 ': r) a -> Sem (e1 ': (e2 ': (e3 ': (e4 ': r)))) a
- Polysemy: reinterpret :: forall e1 e2 r a. FirstOrder e1 "reinterpret" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 : r) x) -> Sem (e1 : r) a -> Sem (e2 : r) a
+ Polysemy: reinterpret :: forall e1 e2 r a. FirstOrder e1 "reinterpret" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 ': r) x) -> Sem (e1 ': r) a -> Sem (e2 ': r) a
- Polysemy: reinterpret2 :: forall e1 e2 e3 r a. FirstOrder e1 "reinterpret2" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 : (e3 : r)) x) -> Sem (e1 : r) a -> Sem (e2 : (e3 : r)) a
+ Polysemy: reinterpret2 :: forall e1 e2 e3 r a. FirstOrder e1 "reinterpret2" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 ': (e3 ': r)) x) -> Sem (e1 ': r) a -> Sem (e2 ': (e3 ': r)) a
- Polysemy: reinterpret2H :: forall e1 e2 e3 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 : (e3 : r)) x) -> Sem (e1 : r) a -> Sem (e2 : (e3 : r)) a
+ Polysemy: reinterpret2H :: forall e1 e2 e3 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 ': (e3 ': r)) x) -> Sem (e1 ': r) a -> Sem (e2 ': (e3 ': r)) a
- Polysemy: reinterpret3 :: forall e1 e2 e3 e4 r a. FirstOrder e1 "reinterpret3" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 : (e3 : (e4 : r))) x) -> Sem (e1 : r) a -> Sem (e2 : (e3 : (e4 : r))) a
+ Polysemy: reinterpret3 :: forall e1 e2 e3 e4 r a. FirstOrder e1 "reinterpret3" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 ': (e3 ': (e4 ': r))) x) -> Sem (e1 ': r) a -> Sem (e2 ': (e3 ': (e4 ': r))) a
- Polysemy: reinterpret3H :: forall e1 e2 e3 e4 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 : (e3 : (e4 : r))) x) -> Sem (e1 : r) a -> Sem (e2 : (e3 : (e4 : r))) a
+ Polysemy: reinterpret3H :: forall e1 e2 e3 e4 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 ': (e3 ': (e4 ': r))) x) -> Sem (e1 ': r) a -> Sem (e2 ': (e3 ': (e4 ': r))) a
- Polysemy: reinterpretH :: forall e1 e2 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 : r) x) -> Sem (e1 : r) a -> Sem (e2 : r) a
+ Polysemy: reinterpretH :: forall e1 e2 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 ': r) x) -> Sem (e1 ': r) a -> Sem (e2 ': r) a
- Polysemy: rewrite :: forall e1 e2 r a. (forall rInitial x. e1 (Sem rInitial) x -> e2 (Sem rInitial) x) -> Sem (e1 : r) a -> Sem (e2 : r) a
+ Polysemy: rewrite :: forall e1 e2 r a. (forall rInitial x. e1 (Sem rInitial) x -> e2 (Sem rInitial) x) -> Sem (e1 ': r) a -> Sem (e2 ': r) a
- Polysemy: runT :: m a -> Sem (WithTactics e f m r) (Sem (e : r) (f a))
+ Polysemy: runT :: m a -> Sem (WithTactics e f m r) (Sem (e ': r) (f a))
- Polysemy: subsume :: forall e r a. Member e r => Sem (e : r) a -> Sem r a
+ Polysemy: subsume :: forall e r a. Member e r => Sem (e ': r) a -> Sem r a
- Polysemy: transform :: forall e1 e2 r a. Member e2 r => (forall rInitial x. e1 (Sem rInitial) x -> e2 (Sem rInitial) x) -> Sem (e1 : r) a -> Sem r a
+ Polysemy: transform :: forall e1 e2 r a. Member e2 r => (forall rInitial x. e1 (Sem rInitial) x -> e2 (Sem rInitial) x) -> Sem (e1 ': r) a -> Sem r a
- Polysemy: type InterpreterFor e r = forall a. Sem (e : r) a -> Sem r a
+ Polysemy: type InterpreterFor e r = forall a. Sem (e ': r) a -> Sem r a
- Polysemy: type WithTactics e f m r = Tactics f m (e : r) : r
+ Polysemy: type WithTactics e f m r = Tactics f m (e ': r) ': r
- Polysemy.Async: async :: forall r_aprf a_X0. Member Async r_aprf => Sem r_aprf a_X0 -> Sem r_aprf (Async (Maybe a_X0))
+ Polysemy.Async: async :: forall r_aqtw a_X0. Member Async r_aqtw => Sem r_aqtw a_X0 -> Sem r_aqtw (Async (Maybe a_X0))
- Polysemy.Async: asyncToIOFinal :: Member (Final IO) r => Sem (Async : r) a -> Sem r a
+ Polysemy.Async: asyncToIOFinal :: Member (Final IO) r => Sem (Async ': r) a -> Sem r a
- Polysemy.Async: await :: forall r_aprh a_apm1. Member Async r_aprh => Async a_apm1 -> Sem r_aprh a_apm1
+ Polysemy.Async: await :: forall r_aqty a_aqol. Member Async r_aqty => Async a_aqol -> Sem r_aqty a_aqol
- Polysemy.Async: cancel :: forall r_aprj a_X0. Member Async r_aprj => Async a_X0 -> Sem r_aprj ()
+ Polysemy.Async: cancel :: forall r_aqtA a_X0. Member Async r_aqtA => Async a_X0 -> Sem r_aqtA ()
- Polysemy.AtomicState: atomicStateToIO :: forall s r a. Member (Embed IO) r => s -> Sem (AtomicState s : r) a -> Sem r (s, a)
+ Polysemy.AtomicState: atomicStateToIO :: forall s r a. Member (Embed IO) r => s -> Sem (AtomicState s ': r) a -> Sem r (s, a)
- Polysemy.AtomicState: atomicStateToState :: Member (State s) r => Sem (AtomicState s : r) a -> Sem r a
+ Polysemy.AtomicState: atomicStateToState :: Member (State s) r => Sem (AtomicState s ': r) a -> Sem r a
- Polysemy.AtomicState: evalAtomicStateViaState :: s -> Sem (AtomicState s : r) a -> Sem r a
+ Polysemy.AtomicState: evalAtomicStateViaState :: s -> Sem (AtomicState s ': r) a -> Sem r a
- Polysemy.AtomicState: execAtomicStateViaState :: s -> Sem (AtomicState s : r) a -> Sem r s
+ Polysemy.AtomicState: execAtomicStateViaState :: s -> Sem (AtomicState s ': r) a -> Sem r s
- Polysemy.AtomicState: runAtomicStateIORef :: forall s r a. Member (Embed IO) r => IORef s -> Sem (AtomicState s : r) a -> Sem r a
+ Polysemy.AtomicState: runAtomicStateIORef :: forall s r a. Member (Embed IO) r => IORef s -> Sem (AtomicState s ': r) a -> Sem r a
- Polysemy.AtomicState: runAtomicStateTVar :: Member (Embed IO) r => TVar s -> Sem (AtomicState s : r) a -> Sem r a
+ Polysemy.AtomicState: runAtomicStateTVar :: Member (Embed IO) r => TVar s -> Sem (AtomicState s ': r) a -> Sem r a
- Polysemy.AtomicState: runAtomicStateViaState :: s -> Sem (AtomicState s : r) a -> Sem r (s, a)
+ Polysemy.AtomicState: runAtomicStateViaState :: s -> Sem (AtomicState s ': r) a -> Sem r (s, a)
- Polysemy.Bundle: runBundle :: forall r' r a. KnownList r' => Sem (Bundle r' : r) a -> Sem (Append r' r) a
+ Polysemy.Bundle: runBundle :: forall r' r a. KnownList r' => Sem (Bundle r' ': r) a -> Sem (Append r' r) a
- Polysemy.Bundle: sendBundle :: forall e r' r a. (Member e r', Member (Bundle r') r) => Sem (e : r) a -> Sem r a
+ Polysemy.Bundle: sendBundle :: forall e r' r a. (Member e r', Member (Bundle r') r) => Sem (e ': r) a -> Sem r a
- Polysemy.Bundle: subsumeBundle :: forall r' r a. Members r' r => Sem (Bundle r' : r) a -> Sem r a
+ Polysemy.Bundle: subsumeBundle :: forall r' r a. Members r' r => Sem (Bundle r' ': r) a -> Sem r a
- Polysemy.Embed: [Embed] :: {unEmbed :: m a} -> Embed m z a
+ Polysemy.Embed: [Embed] :: m a -> Embed m z a
- Polysemy.Embed: runEmbedded :: forall m1 m2 r a. Member (Embed m2) r => (forall x. m1 x -> m2 x) -> Sem (Embed m1 : r) a -> Sem r a
+ Polysemy.Embed: runEmbedded :: forall m1 m2 r a. Member (Embed m2) r => (forall x. m1 x -> m2 x) -> Sem (Embed m1 ': r) a -> Sem r a
- Polysemy.Embed.Type: [Embed] :: {unEmbed :: m a} -> Embed m z a
+ Polysemy.Embed.Type: [Embed] :: m a -> Embed m z a
- Polysemy.Error: catch :: forall e_apQf r_apS7 a_apQh. Member (Error e_apQf) r_apS7 => Sem r_apS7 a_apQh -> (e_apQf -> Sem r_apS7 a_apQh) -> Sem r_apS7 a_apQh
+ Polysemy.Error: catch :: forall e_aqTV r_aqVR a_aqTX. Member (Error e_aqTV) r_aqVR => Sem r_aqVR a_aqTX -> (e_aqTV -> Sem r_aqVR a_aqTX) -> Sem r_aqVR a_aqTX
- Polysemy.Error: errorToIOFinal :: forall e r a. Member (Final IO) r => Sem (Error e : r) a -> Sem r (Either e a)
+ Polysemy.Error: errorToIOFinal :: forall e r a. Member (Final IO) r => Sem (Error e ': r) a -> Sem r (Either e a)
- Polysemy.Error: mapError :: forall e1 e2 r a. Member (Error e2) r => (e1 -> e2) -> Sem (Error e1 : r) a -> Sem r a
+ Polysemy.Error: mapError :: forall e1 e2 r a. Member (Error e2) r => (e1 -> e2) -> Sem (Error e1 ': r) a -> Sem r a
- Polysemy.Error: runError :: Sem (Error e : r) a -> Sem r (Either e a)
+ Polysemy.Error: runError :: Sem (Error e ': r) a -> Sem r (Either e a)
- Polysemy.Error: throw :: forall e_apQc r_apS5 a_apQe. Member (Error e_apQc) r_apS5 => e_apQc -> Sem r_apS5 a_apQe
+ Polysemy.Error: throw :: forall e_aqTS r_aqVP a_aqTU. Member (Error e_aqTS) r_aqVP => e_aqTS -> Sem r_aqVP a_aqTU
- Polysemy.Fail: failToEmbed :: forall m r a. (Member (Embed m) r, MonadFail m) => Sem (Fail : r) a -> Sem r a
+ Polysemy.Fail: failToEmbed :: forall m r a. (Member (Embed m) r, MonadFail m) => Sem (Fail ': r) a -> Sem r a
- Polysemy.Fail: failToError :: Member (Error e) r => (String -> e) -> Sem (Fail : r) a -> Sem r a
+ Polysemy.Fail: failToError :: Member (Error e) r => (String -> e) -> Sem (Fail ': r) a -> Sem r a
- Polysemy.Fail: failToNonDet :: Member NonDet r => Sem (Fail : r) a -> Sem r a
+ Polysemy.Fail: failToNonDet :: Member NonDet r => Sem (Fail ': r) a -> Sem r a
- Polysemy.Fail: runFail :: Sem (Fail : r) a -> Sem r (Either String a)
+ Polysemy.Fail: runFail :: Sem (Fail ': r) a -> Sem r (Either String a)
- Polysemy.Final: embedToFinal :: (Member (Final m) r, Functor m) => Sem (Embed m : r) a -> Sem r a
+ Polysemy.Final: embedToFinal :: (Member (Final m) r, Functor m) => Sem (Embed m ': r) a -> Sem r a
- Polysemy.Final: finalToFinal :: forall m1 m2 r a. Member (Final m2) r => (forall x. m1 x -> m2 x) -> (forall x. m2 x -> m1 x) -> Sem (Final m1 : r) a -> Sem r a
+ Polysemy.Final: finalToFinal :: forall m1 m2 r a. Member (Final m2) r => (forall x. m1 x -> m2 x) -> (forall x. m2 x -> m1 x) -> Sem (Final m1 ': r) a -> Sem r a
- Polysemy.Final: interpretFinal :: forall m e r a. Member (Final m) r => (forall x rInitial. e (Sem rInitial) x -> Strategic m (Sem rInitial) x) -> Sem (e : r) a -> Sem r a
+ Polysemy.Final: interpretFinal :: forall m e r a. Member (Final m) r => (forall x rInitial. e (Sem rInitial) x -> Strategic m (Sem rInitial) x) -> Sem (e ': r) a -> Sem r a
- Polysemy.Fixpoint: fixpointToFinal :: forall m r a. (Member (Final m) r, MonadFix m) => Sem (Fixpoint : r) a -> Sem r a
+ Polysemy.Fixpoint: fixpointToFinal :: forall m r a. (Member (Final m) r, MonadFix m) => Sem (Fixpoint ': r) a -> Sem r a
- Polysemy.IO: embedToMonadIO :: forall m r a. (MonadIO m, Member (Embed m) r) => Sem (Embed IO : r) a -> Sem r a
+ Polysemy.IO: embedToMonadIO :: forall m r a. (MonadIO m, Member (Embed m) r) => Sem (Embed IO ': r) a -> Sem r a
- Polysemy.Input: input :: forall i_azGB r_azHu. Member (Input i_azGB) r_azHu => Sem r_azHu i_azGB
+ Polysemy.Input: input :: forall i_aBnj r_aBod. Member (Input i_aBnj) r_aBod => Sem r_aBod i_aBnj
- Polysemy.Input: runInputConst :: i -> Sem (Input i : r) a -> Sem r a
+ Polysemy.Input: runInputConst :: i -> Sem (Input i ': r) a -> Sem r a
- Polysemy.Input: runInputList :: [i] -> Sem (Input (Maybe i) : r) a -> Sem r a
+ Polysemy.Input: runInputList :: [i] -> Sem (Input (Maybe i) ': r) a -> Sem r a
- Polysemy.Input: runInputSem :: forall i r a. Sem r i -> Sem (Input i : r) a -> Sem r a
+ Polysemy.Input: runInputSem :: forall i r a. Sem r i -> Sem (Input i ': r) a -> Sem r a
- Polysemy.Internal: [Embed] :: {unEmbed :: m a} -> Embed m z a
+ Polysemy.Internal: [Embed] :: m a -> Embed m z a
- Polysemy.Internal: raise :: forall e r a. Sem r a -> Sem (e : r) a
+ Polysemy.Internal: raise :: forall e r a. Sem r a -> Sem (e ': r) a
- Polysemy.Internal: raiseUnder :: forall e2 e1 r a. Sem (e1 : r) a -> Sem (e1 : (e2 : r)) a
+ Polysemy.Internal: raiseUnder :: forall e2 e1 r a. Sem (e1 ': r) a -> Sem (e1 ': (e2 ': r)) a
- Polysemy.Internal: raiseUnder2 :: forall e2 e3 e1 r a. Sem (e1 : r) a -> Sem (e1 : (e2 : (e3 : r))) a
+ Polysemy.Internal: raiseUnder2 :: forall e2 e3 e1 r a. Sem (e1 ': r) a -> Sem (e1 ': (e2 ': (e3 ': r))) a
- Polysemy.Internal: raiseUnder3 :: forall e2 e3 e4 e1 r a. Sem (e1 : r) a -> Sem (e1 : (e2 : (e3 : (e4 : r)))) a
+ Polysemy.Internal: raiseUnder3 :: forall e2 e3 e4 e1 r a. Sem (e1 ': r) a -> Sem (e1 ': (e2 ': (e3 ': (e4 ': r)))) a
- Polysemy.Internal: subsume :: forall e r a. Member e r => Sem (e : r) a -> Sem r a
+ Polysemy.Internal: subsume :: forall e r a. Member e r => Sem (e ': r) a -> Sem r a
- Polysemy.Internal: subsumeUsing :: forall e r a. ElemOf e r -> Sem (e : r) a -> Sem r a
+ Polysemy.Internal: subsumeUsing :: forall e r a. ElemOf e r -> Sem (e ': r) a -> Sem r a
- Polysemy.Internal: type InterpreterFor e r = forall a. Sem (e : r) a -> Sem r a
+ Polysemy.Internal: type InterpreterFor e r = forall a. Sem (e ': r) a -> Sem r a
- Polysemy.Internal.Combinators: interpret :: FirstOrder e "interpret" => (forall rInitial x. e (Sem rInitial) x -> Sem r x) -> Sem (e : r) a -> Sem r a
+ Polysemy.Internal.Combinators: interpret :: FirstOrder e "interpret" => (forall rInitial x. e (Sem rInitial) x -> Sem r x) -> Sem (e ': r) a -> Sem r a
- Polysemy.Internal.Combinators: interpretH :: (forall rInitial x. e (Sem rInitial) x -> Tactical e (Sem rInitial) r x) -> Sem (e : r) a -> Sem r a
+ Polysemy.Internal.Combinators: interpretH :: (forall rInitial x. e (Sem rInitial) x -> Tactical e (Sem rInitial) r x) -> Sem (e ': r) a -> Sem r a
- Polysemy.Internal.Combinators: lazilyStateful :: (forall x m. e m x -> s -> Sem r (s, x)) -> s -> Sem (e : r) a -> Sem r (s, a)
+ Polysemy.Internal.Combinators: lazilyStateful :: (forall x m. e m x -> s -> Sem r (s, x)) -> s -> Sem (e ': r) a -> Sem r (s, a)
- Polysemy.Internal.Combinators: reinterpret :: forall e1 e2 r a. FirstOrder e1 "reinterpret" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 : r) x) -> Sem (e1 : r) a -> Sem (e2 : r) a
+ Polysemy.Internal.Combinators: reinterpret :: forall e1 e2 r a. FirstOrder e1 "reinterpret" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 ': r) x) -> Sem (e1 ': r) a -> Sem (e2 ': r) a
- Polysemy.Internal.Combinators: reinterpret2 :: forall e1 e2 e3 r a. FirstOrder e1 "reinterpret2" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 : (e3 : r)) x) -> Sem (e1 : r) a -> Sem (e2 : (e3 : r)) a
+ Polysemy.Internal.Combinators: reinterpret2 :: forall e1 e2 e3 r a. FirstOrder e1 "reinterpret2" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 ': (e3 ': r)) x) -> Sem (e1 ': r) a -> Sem (e2 ': (e3 ': r)) a
- Polysemy.Internal.Combinators: reinterpret2H :: forall e1 e2 e3 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 : (e3 : r)) x) -> Sem (e1 : r) a -> Sem (e2 : (e3 : r)) a
+ Polysemy.Internal.Combinators: reinterpret2H :: forall e1 e2 e3 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 ': (e3 ': r)) x) -> Sem (e1 ': r) a -> Sem (e2 ': (e3 ': r)) a
- Polysemy.Internal.Combinators: reinterpret3 :: forall e1 e2 e3 e4 r a. FirstOrder e1 "reinterpret3" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 : (e3 : (e4 : r))) x) -> Sem (e1 : r) a -> Sem (e2 : (e3 : (e4 : r))) a
+ Polysemy.Internal.Combinators: reinterpret3 :: forall e1 e2 e3 e4 r a. FirstOrder e1 "reinterpret3" => (forall rInitial x. e1 (Sem rInitial) x -> Sem (e2 ': (e3 ': (e4 ': r))) x) -> Sem (e1 ': r) a -> Sem (e2 ': (e3 ': (e4 ': r))) a
- Polysemy.Internal.Combinators: reinterpret3H :: forall e1 e2 e3 e4 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 : (e3 : (e4 : r))) x) -> Sem (e1 : r) a -> Sem (e2 : (e3 : (e4 : r))) a
+ Polysemy.Internal.Combinators: reinterpret3H :: forall e1 e2 e3 e4 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 ': (e3 ': (e4 ': r))) x) -> Sem (e1 ': r) a -> Sem (e2 ': (e3 ': (e4 ': r))) a
- Polysemy.Internal.Combinators: reinterpretH :: forall e1 e2 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 : r) x) -> Sem (e1 : r) a -> Sem (e2 : r) a
+ Polysemy.Internal.Combinators: reinterpretH :: forall e1 e2 r a. (forall rInitial x. e1 (Sem rInitial) x -> Tactical e1 (Sem rInitial) (e2 ': r) x) -> Sem (e1 ': r) a -> Sem (e2 ': r) a
- Polysemy.Internal.Combinators: rewrite :: forall e1 e2 r a. (forall rInitial x. e1 (Sem rInitial) x -> e2 (Sem rInitial) x) -> Sem (e1 : r) a -> Sem (e2 : r) a
+ Polysemy.Internal.Combinators: rewrite :: forall e1 e2 r a. (forall rInitial x. e1 (Sem rInitial) x -> e2 (Sem rInitial) x) -> Sem (e1 ': r) a -> Sem (e2 ': r) a
- Polysemy.Internal.Combinators: stateful :: (forall x m. e m x -> s -> Sem r (s, x)) -> s -> Sem (e : r) a -> Sem r (s, a)
+ Polysemy.Internal.Combinators: stateful :: (forall x m. e m x -> s -> Sem r (s, x)) -> s -> Sem (e ': r) a -> Sem r (s, a)
- Polysemy.Internal.Combinators: transform :: forall e1 e2 r a. Member e2 r => (forall rInitial x. e1 (Sem rInitial) x -> e2 (Sem rInitial) x) -> Sem (e1 : r) a -> Sem r a
+ Polysemy.Internal.Combinators: transform :: forall e1 e2 r a. Member e2 r => (forall rInitial x. e1 (Sem rInitial) x -> e2 (Sem rInitial) x) -> Sem (e1 ': r) a -> Sem r a
- Polysemy.Internal.Scoped: [InScope] :: forall param effect m a. param -> m a -> Scoped param effect m a
+ Polysemy.Internal.Scoped: [InScope] :: forall param effect m a. param -> (Word -> m a) -> Scoped param effect m a
- Polysemy.Internal.Scoped: [Run] :: forall param effect m a. effect m a -> Scoped param effect m a
+ Polysemy.Internal.Scoped: [Run] :: forall param effect m a. Word -> effect m a -> Scoped param effect m a
- Polysemy.Internal.Sing: [SCons] :: SList xs -> SList (x : xs)
+ Polysemy.Internal.Sing: [SCons] :: SList xs -> SList (x ': xs)
- Polysemy.Internal.Tactics: bindT :: (a -> m b) -> Sem (WithTactics e f m r) (f a -> Sem (e : r) (f b))
+ Polysemy.Internal.Tactics: bindT :: (a -> m b) -> Sem (WithTactics e f m r) (f a -> Sem (e ': r) (f b))
- Polysemy.Internal.Tactics: runT :: m a -> Sem (WithTactics e f m r) (Sem (e : r) (f a))
+ Polysemy.Internal.Tactics: runT :: m a -> Sem (WithTactics e f m r) (Sem (e ': r) (f a))
- Polysemy.Internal.Tactics: runTactics :: Functor f => f () -> (forall x. f (m x) -> Sem r2 (f x)) -> (forall x. f x -> Maybe x) -> (forall x. f (m x) -> Sem r (f x)) -> Sem (Tactics f m r2 : r) a -> Sem r a
+ Polysemy.Internal.Tactics: runTactics :: Functor f => f () -> (forall x. f (m x) -> Sem r2 (f x)) -> (forall x. f x -> Maybe x) -> (forall x. f (m x) -> Sem r (f x)) -> Sem (Tactics f m r2 ': r) a -> Sem r a
- Polysemy.Internal.Tactics: type WithTactics e f m r = Tactics f m (e : r) : r
+ Polysemy.Internal.Tactics: type WithTactics e f m r = Tactics f m (e ': r) ': r
- Polysemy.Internal.Union: [Weaving] :: forall f e rInitial a resultType mAfter. Functor f => {weaveEffect :: e (Sem rInitial) a " The original effect GADT originally lifted via 'Polysemy.Internal.send'. ^ @rInitial@ is the effect row that was in scope when this 'Weaving' was originally created.", weaveState :: f () " A piece of state that other effects' interpreters have already woven through this 'Weaving'. @f@ is a 'Functor', so you can always 'fmap' into this thing.", weaveDistrib :: forall x. f (Sem rInitial x) -> mAfter (f x) " Distribute @f@ by transforming @Sem rInitial@ into @mAfter@. This is usually of the form @f ('Polysemy.Sem' (Some ': Effects ': r) x) -> Sem r (f x)@", weaveResult :: f a -> resultType " Even though @f a@ is the moral resulting type of 'Weaving', we can't expose that fact; such a thing would prevent 'Polysemy.Sem' from being a 'Monad'.", weaveInspect :: forall x. f x -> Maybe x " A function for attempting to see inside an @f@. This is no guarantees that such a thing will succeed (for example, 'Polysemy.Error.Error' might have 'Polysemy.Error.throw'n.)"} -> Weaving e mAfter resultType
+ Polysemy.Internal.Union: [Weaving] :: forall f e rInitial a resultType mAfter. Functor f => e (Sem rInitial) a -> f () -> (forall x. f (Sem rInitial x) -> mAfter (f x)) -> (f a -> resultType) -> (forall x. f x -> Maybe x) -> Weaving e mAfter resultType
- Polysemy.Internal.Union: decomp :: Union (e : r) m a -> Either (Union r m a) (Weaving e m a)
+ Polysemy.Internal.Union: decomp :: Union (e ': r) m a -> Either (Union r m a) (Weaving e m a)
- Polysemy.Internal.Union: decompCoerce :: Union (e : r) m a -> Either (Union (f : r) m a) (Weaving e m a)
+ Polysemy.Internal.Union: decompCoerce :: Union (e ': r) m a -> Either (Union (f ': r) m a) (Weaving e m a)
- Polysemy.Internal.Union: pattern There :: () => r' ~ (e' : r) => ElemOf e r -> ElemOf e r'
+ Polysemy.Internal.Union: pattern There :: () => r' ~ (e' ': r) => ElemOf e r -> ElemOf e r'
- Polysemy.Internal.Union: weaken :: forall e r m a. Union r m a -> Union (e : r) m a
+ Polysemy.Internal.Union: weaken :: forall e r m a. Union r m a -> Union (e ': r) m a
- Polysemy.Internal.Writer: listen :: forall o_as83 r_asam a_X0. Member (Writer o_as83) r_asam => Sem r_asam a_X0 -> Sem r_asam (o_as83, a_X0)
+ Polysemy.Internal.Writer: listen :: forall o_atkh r_atmC a_X0. Member (Writer o_atkh) r_atmC => Sem r_atmC a_X0 -> Sem r_atmC (o_atkh, a_X0)
- Polysemy.Internal.Writer: pass :: forall o_as87 r_asao a_as88. Member (Writer o_as87) r_asao => Sem r_asao (o_as87 -> o_as87, a_as88) -> Sem r_asao a_as88
+ Polysemy.Internal.Writer: pass :: forall o_atkl r_atmE a_atkm. Member (Writer o_atkl) r_atmE => Sem r_atmE (o_atkl -> o_atkl, a_atkm) -> Sem r_atmE a_atkm
- Polysemy.Internal.Writer: runWriterSTMAction :: forall o r a. (Member (Final IO) r, Monoid o) => (o -> STM ()) -> Sem (Writer o : r) a -> Sem r a
+ Polysemy.Internal.Writer: runWriterSTMAction :: forall o r a. (Member (Final IO) r, Monoid o) => (o -> STM ()) -> Sem (Writer o ': r) a -> Sem r a
- Polysemy.Internal.Writer: tell :: forall o_as81 r_asak. Member (Writer o_as81) r_asak => o_as81 -> Sem r_asak ()
+ Polysemy.Internal.Writer: tell :: forall o_atkf r_atmA. Member (Writer o_atkf) r_atmA => o_atkf -> Sem r_atmA ()
- Polysemy.Internal.Writer: writerToEndoWriter :: (Monoid o, Member (Writer (Endo o)) r) => Sem (Writer o : r) a -> Sem r a
+ Polysemy.Internal.Writer: writerToEndoWriter :: (Monoid o, Member (Writer (Endo o)) r) => Sem (Writer o ': r) a -> Sem r a
- Polysemy.Membership: pattern There :: () => r' ~ (e' : r) => ElemOf e r -> ElemOf e r'
+ Polysemy.Membership: pattern There :: () => r' ~ (e' ': r) => ElemOf e r -> ElemOf e r'
- Polysemy.Membership: subsumeUsing :: forall e r a. ElemOf e r -> Sem (e : r) a -> Sem r a
+ Polysemy.Membership: subsumeUsing :: forall e r a. ElemOf e r -> Sem (e ': r) a -> Sem r a
- Polysemy.NonDet: nonDetToError :: Member (Error e) r => e -> Sem (NonDet : r) a -> Sem r a
+ Polysemy.NonDet: nonDetToError :: Member (Error e) r => e -> Sem (NonDet ': r) a -> Sem r a
- Polysemy.NonDet: runNonDet :: Alternative f => Sem (NonDet : r) a -> Sem r (f a)
+ Polysemy.NonDet: runNonDet :: Alternative f => Sem (NonDet ': r) a -> Sem r (f a)
- Polysemy.NonDet: runNonDetMaybe :: Sem (NonDet : r) a -> Sem r (Maybe a)
+ Polysemy.NonDet: runNonDetMaybe :: Sem (NonDet ': r) a -> Sem r (Maybe a)
- Polysemy.Output: ignoreOutput :: Sem (Output o : r) a -> Sem r a
+ Polysemy.Output: ignoreOutput :: Sem (Output o ': r) a -> Sem r a
- Polysemy.Output: output :: forall o_ay8I r_ay9y. Member (Output o_ay8I) r_ay9y => o_ay8I -> Sem r_ay9y ()
+ Polysemy.Output: output :: forall o_azL4 r_azLV. Member (Output o_azL4) r_azLV => o_azL4 -> Sem r_azLV ()
- Polysemy.Output: outputToIOMonoid :: forall o m r a. (Monoid m, Member (Embed IO) r) => (o -> m) -> Sem (Output o : r) a -> Sem r (m, a)
+ Polysemy.Output: outputToIOMonoid :: forall o m r a. (Monoid m, Member (Embed IO) r) => (o -> m) -> Sem (Output o ': r) a -> Sem r (m, a)
- Polysemy.Output: outputToIOMonoidAssocR :: forall o m r a. (Monoid m, Member (Embed IO) r) => (o -> m) -> Sem (Output o : r) a -> Sem r (m, a)
+ Polysemy.Output: outputToIOMonoidAssocR :: forall o m r a. (Monoid m, Member (Embed IO) r) => (o -> m) -> Sem (Output o ': r) a -> Sem r (m, a)
- Polysemy.Output: runLazyOutputList :: forall o r a. Sem (Output o : r) a -> Sem r ([o], a)
+ Polysemy.Output: runLazyOutputList :: forall o r a. Sem (Output o ': r) a -> Sem r ([o], a)
- Polysemy.Output: runLazyOutputMonoid :: forall o m r a. Monoid m => (o -> m) -> Sem (Output o : r) a -> Sem r (m, a)
+ Polysemy.Output: runLazyOutputMonoid :: forall o m r a. Monoid m => (o -> m) -> Sem (Output o ': r) a -> Sem r (m, a)
- Polysemy.Output: runLazyOutputMonoidAssocR :: forall o m r a. Monoid m => (o -> m) -> Sem (Output o : r) a -> Sem r (m, a)
+ Polysemy.Output: runLazyOutputMonoidAssocR :: forall o m r a. Monoid m => (o -> m) -> Sem (Output o ': r) a -> Sem r (m, a)
- Polysemy.Output: runOutputBatched :: forall o r a. Member (Output [o]) r => Int -> Sem (Output o : r) a -> Sem r a
+ Polysemy.Output: runOutputBatched :: forall o r a. Member (Output [o]) r => Int -> Sem (Output o ': r) a -> Sem r a
- Polysemy.Output: runOutputList :: forall o r a. Sem (Output o : r) a -> Sem r ([o], a)
+ Polysemy.Output: runOutputList :: forall o r a. Sem (Output o ': r) a -> Sem r ([o], a)
- Polysemy.Output: runOutputMonoid :: forall o m r a. Monoid m => (o -> m) -> Sem (Output o : r) a -> Sem r (m, a)
+ Polysemy.Output: runOutputMonoid :: forall o m r a. Monoid m => (o -> m) -> Sem (Output o ': r) a -> Sem r (m, a)
- Polysemy.Output: runOutputMonoidAssocR :: forall o m r a. Monoid m => (o -> m) -> Sem (Output o : r) a -> Sem r (m, a)
+ Polysemy.Output: runOutputMonoidAssocR :: forall o m r a. Monoid m => (o -> m) -> Sem (Output o ': r) a -> Sem r (m, a)
- Polysemy.Output: runOutputMonoidIORef :: forall o m r a. (Monoid m, Member (Embed IO) r) => IORef m -> (o -> m) -> Sem (Output o : r) a -> Sem r a
+ Polysemy.Output: runOutputMonoidIORef :: forall o m r a. (Monoid m, Member (Embed IO) r) => IORef m -> (o -> m) -> Sem (Output o ': r) a -> Sem r a
- Polysemy.Output: runOutputMonoidTVar :: forall o m r a. (Monoid m, Member (Embed IO) r) => TVar m -> (o -> m) -> Sem (Output o : r) a -> Sem r a
+ Polysemy.Output: runOutputMonoidTVar :: forall o m r a. (Monoid m, Member (Embed IO) r) => TVar m -> (o -> m) -> Sem (Output o ': r) a -> Sem r a
- Polysemy.Output: runOutputSem :: (o -> Sem r ()) -> Sem (Output o : r) a -> Sem r a
+ Polysemy.Output: runOutputSem :: (o -> Sem r ()) -> Sem (Output o ': r) a -> Sem r a
- Polysemy.Reader: ask :: forall i_aA1L r_aA3g. Member (Reader i_aA1L) r_aA3g => Sem r_aA3g i_aA1L
+ Polysemy.Reader: ask :: forall i_aBIy r_aBK5. Member (Reader i_aBIy) r_aBK5 => Sem r_aBK5 i_aBIy
- Polysemy.Reader: inputToReader :: Member (Reader i) r => Sem (Input i : r) a -> Sem r a
+ Polysemy.Reader: inputToReader :: Member (Reader i) r => Sem (Input i ': r) a -> Sem r a
- Polysemy.Reader: local :: forall i_aA1N r_aA3h a_aA1P. Member (Reader i_aA1N) r_aA3h => (i_aA1N -> i_aA1N) -> Sem r_aA3h a_aA1P -> Sem r_aA3h a_aA1P
+ Polysemy.Reader: local :: forall i_aBIA r_aBK6 a_aBIC. Member (Reader i_aBIA) r_aBK6 => (i_aBIA -> i_aBIA) -> Sem r_aBK6 a_aBIC -> Sem r_aBK6 a_aBIC
- Polysemy.Reader: runReader :: i -> Sem (Reader i : r) a -> Sem r a
+ Polysemy.Reader: runReader :: i -> Sem (Reader i ': r) a -> Sem r a
- Polysemy.Resource: bracket :: forall r_avlc a_X0 c_X1 b_avj1. Member Resource r_avlc => Sem r_avlc a_X0 -> (a_X0 -> Sem r_avlc c_X1) -> (a_X0 -> Sem r_avlc b_avj1) -> Sem r_avlc b_avj1
+ Polysemy.Resource: bracket :: forall r_awS9 a_X0 c_X1 b_awPY. Member Resource r_awS9 => Sem r_awS9 a_X0 -> (a_X0 -> Sem r_awS9 c_X1) -> (a_X0 -> Sem r_awS9 b_awPY) -> Sem r_awS9 b_awPY
- Polysemy.Resource: bracketOnError :: forall r_avlg a_X0 c_X1 b_avj5. Member Resource r_avlg => Sem r_avlg a_X0 -> (a_X0 -> Sem r_avlg c_X1) -> (a_X0 -> Sem r_avlg b_avj5) -> Sem r_avlg b_avj5
+ Polysemy.Resource: bracketOnError :: forall r_awSd a_X0 c_X1 b_awQ2. Member Resource r_awSd => Sem r_awSd a_X0 -> (a_X0 -> Sem r_awSd c_X1) -> (a_X0 -> Sem r_awSd b_awQ2) -> Sem r_awSd b_awQ2
- Polysemy.Resource: resourceToIOFinal :: Member (Final IO) r => Sem (Resource : r) a -> Sem r a
+ Polysemy.Resource: resourceToIOFinal :: Member (Final IO) r => Sem (Resource ': r) a -> Sem r a
- Polysemy.Resource: runResource :: forall r a. Sem (Resource : r) a -> Sem r a
+ Polysemy.Resource: runResource :: forall r a. Sem (Resource ': r) a -> Sem r a
- Polysemy.Scoped: interpretScoped :: forall resource param effect r. (forall x. param -> (resource -> Sem r x) -> Sem r x) -> (forall m x. resource -> effect m x -> Sem r x) -> InterpreterFor (Scoped param effect) r
+ Polysemy.Scoped: interpretScoped :: forall resource param effect r. (forall q x. param -> (resource -> Sem (Opaque q ': r) x) -> Sem (Opaque q ': r) x) -> (forall m x. resource -> effect m x -> Sem r x) -> InterpreterFor (Scoped param effect) r
- Polysemy.Scoped: interpretScopedH :: forall resource param effect r. (forall x. param -> (resource -> Sem r x) -> Sem r x) -> (forall r0 x. resource -> effect (Sem r0) x -> Tactical effect (Sem r0) r x) -> InterpreterFor (Scoped param effect) r
+ Polysemy.Scoped: interpretScopedH :: forall resource param effect r. (forall q x. param -> (resource -> Sem (Opaque q ': r) x) -> Sem (Opaque q ': r) x) -> (forall q r0 x. resource -> effect (Sem r0) x -> Tactical effect (Sem r0) (Opaque q ': r) x) -> InterpreterFor (Scoped param effect) r
- Polysemy.Scoped: interpretScopedWith :: forall extra param resource effect r r1. (r1 ~ Append extra r, KnownList extra) => (forall x. param -> (resource -> Sem r1 x) -> Sem r x) -> (forall m x. resource -> effect m x -> Sem r1 x) -> InterpreterFor (Scoped param effect) r
+ Polysemy.Scoped: interpretScopedWith :: forall extra param resource effect r. KnownList extra => (forall q x. param -> (resource -> Sem (Append extra (Opaque q ': r)) x) -> Sem (Opaque q ': r) x) -> (forall m x. resource -> effect m x -> Sem (Append extra r) x) -> InterpreterFor (Scoped param effect) r
- Polysemy.Scoped: interpretScopedWithH :: forall extra resource param effect r r1. (KnownList extra, r1 ~ Append extra r) => (forall x. param -> (resource -> Sem r1 x) -> Sem r x) -> (forall r0 x. resource -> effect (Sem r0) x -> Tactical effect (Sem r0) r1 x) -> InterpreterFor (Scoped param effect) r
+ Polysemy.Scoped: interpretScopedWithH :: forall extra resource param effect r. KnownList extra => (forall q x. param -> (resource -> Sem (Append extra (Opaque q ': r)) x) -> Sem (Opaque q ': r) x) -> (forall q r0 x. resource -> effect (Sem r0) x -> Tactical effect (Sem r0) (Append extra (Opaque q ': r)) x) -> InterpreterFor (Scoped param effect) r
- Polysemy.Scoped: interpretScopedWith_ :: forall extra param effect r r1. (r1 ~ Append extra r, KnownList extra) => (forall x. param -> Sem r1 x -> Sem r x) -> (forall m x. effect m x -> Sem r1 x) -> InterpreterFor (Scoped param effect) r
+ Polysemy.Scoped: interpretScopedWith_ :: forall extra param effect r. KnownList extra => (forall q x. param -> Sem (Append extra (Opaque q ': r)) x -> Sem (Opaque q ': r) x) -> (forall m x. effect m x -> Sem (Append extra r) x) -> InterpreterFor (Scoped param effect) r
- Polysemy.Scoped: runScoped :: forall resource param effect r. (forall x. param -> (resource -> Sem r x) -> Sem r x) -> (resource -> InterpreterFor effect r) -> InterpreterFor (Scoped param effect) r
+ Polysemy.Scoped: runScoped :: forall resource param effect r. (forall q x. param -> (resource -> Sem (Opaque q ': r) x) -> Sem (Opaque q ': r) x) -> (forall q. resource -> InterpreterFor effect (Opaque q ': r)) -> InterpreterFor (Scoped param effect) r
- Polysemy.Scoped: runScopedAs :: forall resource param effect r. (param -> Sem r resource) -> (resource -> InterpreterFor effect r) -> InterpreterFor (Scoped param effect) r
+ Polysemy.Scoped: runScopedAs :: forall resource param effect r. (param -> Sem r resource) -> (forall q. resource -> InterpreterFor effect (Opaque q ': r)) -> InterpreterFor (Scoped param effect) r
- Polysemy.State: evalLazyState :: s -> Sem (State s : r) a -> Sem r a
+ Polysemy.State: evalLazyState :: s -> Sem (State s ': r) a -> Sem r a
- Polysemy.State: evalState :: s -> Sem (State s : r) a -> Sem r a
+ Polysemy.State: evalState :: s -> Sem (State s ': r) a -> Sem r a
- Polysemy.State: execLazyState :: s -> Sem (State s : r) a -> Sem r s
+ Polysemy.State: execLazyState :: s -> Sem (State s ': r) a -> Sem r s
- Polysemy.State: execState :: s -> Sem (State s : r) a -> Sem r s
+ Polysemy.State: execState :: s -> Sem (State s ': r) a -> Sem r s
- Polysemy.State: get :: forall s_awDj r_awEJ. Member (State s_awDj) r_awEJ => Sem r_awEJ s_awDj
+ Polysemy.State: get :: forall s_ayhe r_ayiG. Member (State s_ayhe) r_ayiG => Sem r_ayiG s_ayhe
- Polysemy.State: hoistStateIntoStateT :: Sem (State s : r) a -> StateT s (Sem r) a
+ Polysemy.State: hoistStateIntoStateT :: Sem (State s ': r) a -> StateT s (Sem r) a
- Polysemy.State: put :: forall s_awDl r_awEK. Member (State s_awDl) r_awEK => s_awDl -> Sem r_awEK ()
+ Polysemy.State: put :: forall s_ayhg r_ayiH. Member (State s_ayhg) r_ayiH => s_ayhg -> Sem r_ayiH ()
- Polysemy.State: runLazyState :: s -> Sem (State s : r) a -> Sem r (s, a)
+ Polysemy.State: runLazyState :: s -> Sem (State s ': r) a -> Sem r (s, a)
- Polysemy.State: runState :: s -> Sem (State s : r) a -> Sem r (s, a)
+ Polysemy.State: runState :: s -> Sem (State s ': r) a -> Sem r (s, a)
- Polysemy.State: runStateIORef :: forall s r a. Member (Embed IO) r => IORef s -> Sem (State s : r) a -> Sem r a
+ Polysemy.State: runStateIORef :: forall s r a. Member (Embed IO) r => IORef s -> Sem (State s ': r) a -> Sem r a
- Polysemy.State: runStateSTRef :: forall s st r a. Member (Embed (ST st)) r => STRef st s -> Sem (State s : r) a -> Sem r a
+ Polysemy.State: runStateSTRef :: forall s st r a. Member (Embed (ST st)) r => STRef st s -> Sem (State s ': r) a -> Sem r a
- Polysemy.State: stateToIO :: forall s r a. Member (Embed IO) r => s -> Sem (State s : r) a -> Sem r (s, a)
+ Polysemy.State: stateToIO :: forall s r a. Member (Embed IO) r => s -> Sem (State s ': r) a -> Sem r (s, a)
- Polysemy.State: stateToST :: forall s st r a. Member (Embed (ST st)) r => s -> Sem (State s : r) a -> Sem r (s, a)
+ Polysemy.State: stateToST :: forall s st r a. Member (Embed (ST st)) r => s -> Sem (State s ': r) a -> Sem r (s, a)
- Polysemy.Tagged: retag :: forall k1 k2 e r a. Member (Tagged k2 e) r => Sem (Tagged k1 e : r) a -> Sem r a
+ Polysemy.Tagged: retag :: forall k1 k2 e r a. Member (Tagged k2 e) r => Sem (Tagged k1 e ': r) a -> Sem r a
- Polysemy.Tagged: tag :: forall k e r a. Member (Tagged k e) r => Sem (e : r) a -> Sem r a
+ Polysemy.Tagged: tag :: forall k e r a. Member (Tagged k e) r => Sem (e ': r) a -> Sem r a
- Polysemy.Tagged: tagged :: forall k e r a. Sem (e : r) a -> Sem (Tagged k e : r) a
+ Polysemy.Tagged: tagged :: forall k e r a. Sem (e ': r) a -> Sem (Tagged k e ': r) a
- Polysemy.Tagged: untag :: forall k e r a. Sem (Tagged k e : r) a -> Sem (e : r) a
+ Polysemy.Tagged: untag :: forall k e r a. Sem (Tagged k e ': r) a -> Sem (e ': r) a
- Polysemy.Trace: ignoreTrace :: Sem (Trace : r) a -> Sem r a
+ Polysemy.Trace: ignoreTrace :: Sem (Trace ': r) a -> Sem r a
- Polysemy.Trace: outputToTrace :: forall w r a. Member Trace r => (w -> String) -> Sem (Output w : r) a -> Sem r a
+ Polysemy.Trace: outputToTrace :: forall w r a. Member Trace r => (w -> String) -> Sem (Output w ': r) a -> Sem r a
- Polysemy.Trace: runTraceList :: Sem (Trace : r) a -> Sem r ([String], a)
+ Polysemy.Trace: runTraceList :: Sem (Trace ': r) a -> Sem r ([String], a)
- Polysemy.Trace: trace :: forall r_aBJn. Member Trace r_aBJn => String -> Sem r_aBJn ()
+ Polysemy.Trace: trace :: forall r_aDrU. Member Trace r_aDrU => String -> Sem r_aDrU ()
- Polysemy.Trace: traceToHandle :: Member (Embed IO) r => Handle -> Sem (Trace : r) a -> Sem r a
+ Polysemy.Trace: traceToHandle :: Member (Embed IO) r => Handle -> Sem (Trace ': r) a -> Sem r a
- Polysemy.Trace: traceToIO :: Member (Embed IO) r => Sem (Trace : r) a -> Sem r a
+ Polysemy.Trace: traceToIO :: Member (Embed IO) r => Sem (Trace ': r) a -> Sem r a
- Polysemy.Trace: traceToOutput :: Member (Output String) r => Sem (Trace : r) a -> Sem r a
+ Polysemy.Trace: traceToOutput :: Member (Output String) r => Sem (Trace ': r) a -> Sem r a
- Polysemy.Trace: traceToStderr :: Member (Embed IO) r => Sem (Trace : r) a -> Sem r a
+ Polysemy.Trace: traceToStderr :: Member (Embed IO) r => Sem (Trace ': r) a -> Sem r a
- Polysemy.Trace: traceToStdout :: Member (Embed IO) r => Sem (Trace : r) a -> Sem r a
+ Polysemy.Trace: traceToStdout :: Member (Embed IO) r => Sem (Trace ': r) a -> Sem r a
- Polysemy.Writer: listen :: forall o_as83 r_asam a_X0. Member (Writer o_as83) r_asam => Sem r_asam a_X0 -> Sem r_asam (o_as83, a_X0)
+ Polysemy.Writer: listen :: forall o_atkh r_atmC a_X0. Member (Writer o_atkh) r_atmC => Sem r_atmC a_X0 -> Sem r_atmC (o_atkh, a_X0)
- Polysemy.Writer: outputToWriter :: Member (Writer o) r => Sem (Output o : r) a -> Sem r a
+ Polysemy.Writer: outputToWriter :: Member (Writer o) r => Sem (Output o ': r) a -> Sem r a
- Polysemy.Writer: pass :: forall o_as87 r_asao a_as88. Member (Writer o_as87) r_asao => Sem r_asao (o_as87 -> o_as87, a_as88) -> Sem r_asao a_as88
+ Polysemy.Writer: pass :: forall o_atkl r_atmE a_atkm. Member (Writer o_atkl) r_atmE => Sem r_atmE (o_atkl -> o_atkl, a_atkm) -> Sem r_atmE a_atkm
- Polysemy.Writer: runLazyWriter :: forall o r a. Monoid o => Sem (Writer o : r) a -> Sem r (o, a)
+ Polysemy.Writer: runLazyWriter :: forall o r a. Monoid o => Sem (Writer o ': r) a -> Sem r (o, a)
- Polysemy.Writer: runLazyWriterAssocR :: Monoid o => Sem (Writer o : r) a -> Sem r (o, a)
+ Polysemy.Writer: runLazyWriterAssocR :: Monoid o => Sem (Writer o ': r) a -> Sem r (o, a)
- Polysemy.Writer: runWriter :: Monoid o => Sem (Writer o : r) a -> Sem r (o, a)
+ Polysemy.Writer: runWriter :: Monoid o => Sem (Writer o ': r) a -> Sem r (o, a)
- Polysemy.Writer: runWriterAssocR :: Monoid o => Sem (Writer o : r) a -> Sem r (o, a)
+ Polysemy.Writer: runWriterAssocR :: Monoid o => Sem (Writer o ': r) a -> Sem r (o, a)
- Polysemy.Writer: runWriterTVar :: (Monoid o, Member (Final IO) r) => TVar o -> Sem (Writer o : r) a -> Sem r a
+ Polysemy.Writer: runWriterTVar :: (Monoid o, Member (Final IO) r) => TVar o -> Sem (Writer o ': r) a -> Sem r a
- Polysemy.Writer: tell :: forall o_as81 r_asak. Member (Writer o_as81) r_asak => o_as81 -> Sem r_asak ()
+ Polysemy.Writer: tell :: forall o_atkf r_atmA. Member (Writer o_atkf) r_atmA => o_atkf -> Sem r_atmA ()
- Polysemy.Writer: writerToEndoWriter :: (Monoid o, Member (Writer (Endo o)) r) => Sem (Writer o : r) a -> Sem r a
+ Polysemy.Writer: writerToEndoWriter :: (Monoid o, Member (Writer (Endo o)) r) => Sem (Writer o ': r) a -> Sem r a
- Polysemy.Writer: writerToIOAssocRFinal :: (Monoid o, Member (Final IO) r) => Sem (Writer o : r) a -> Sem r (o, a)
+ Polysemy.Writer: writerToIOAssocRFinal :: (Monoid o, Member (Final IO) r) => Sem (Writer o ': r) a -> Sem r (o, a)
- Polysemy.Writer: writerToIOFinal :: (Monoid o, Member (Final IO) r) => Sem (Writer o : r) a -> Sem r (o, a)
+ Polysemy.Writer: writerToIOFinal :: (Monoid o, Member (Final IO) r) => Sem (Writer o ': r) a -> Sem r (o, a)
Files
- ChangeLog.md +24/−1
- polysemy.cabal +5/−3
- src/Polysemy.hs +1/−0
- src/Polysemy/Async.hs +4/−0
- src/Polysemy/AtomicState.hs +8/−0
- src/Polysemy/Bundle.hs +2/−0
- src/Polysemy/Embed.hs +1/−0
- src/Polysemy/Embed/Type.hs +1/−0
- src/Polysemy/Error.hs +10/−0
- src/Polysemy/Fail.hs +1/−0
- src/Polysemy/Fail/Type.hs +8/−0
- src/Polysemy/Final.hs +3/−0
- src/Polysemy/Fixpoint.hs +1/−0
- src/Polysemy/IO.hs +2/−1
- src/Polysemy/Input.hs +2/−0
- src/Polysemy/Internal.hs +9/−1
- src/Polysemy/Internal/Bundle.hs +6/−0
- src/Polysemy/Internal/Combinators.hs +1/−0
- src/Polysemy/Internal/CustomErrors.hs +5/−3
- src/Polysemy/Internal/CustomErrors/Redefined.hs +1/−0
- src/Polysemy/Internal/Fixpoint.hs +1/−0
- src/Polysemy/Internal/Index.hs +2/−1
- src/Polysemy/Internal/Kind.hs +3/−0
- src/Polysemy/Internal/NonDet.hs +1/−0
- src/Polysemy/Internal/Scoped.hs +10/−5
- src/Polysemy/Internal/Sing.hs +9/−1
- src/Polysemy/Internal/Strategy.hs +4/−1
- src/Polysemy/Internal/TH/Common.hs +4/−3
- src/Polysemy/Internal/TH/Effect.hs +8/−8
- src/Polysemy/Internal/Tactics.hs +5/−0
- src/Polysemy/Internal/Union.hs +9/−1
- src/Polysemy/Internal/Writer.hs +6/−1
- src/Polysemy/Membership.hs +1/−0
- src/Polysemy/NonDet.hs +1/−0
- src/Polysemy/Opaque.hs +54/−0
- src/Polysemy/Output.hs +2/−0
- src/Polysemy/Reader.hs +5/−0
- src/Polysemy/Resource.hs +3/−0
- src/Polysemy/Scoped.hs +151/−101
- src/Polysemy/State.hs +15/−8
- src/Polysemy/Tagged.hs +2/−0
- src/Polysemy/Trace.hs +2/−0
- src/Polysemy/Writer.hs +1/−0
- test/ScopedSpec.hs +52/−2
ChangeLog.md view
@@ -6,7 +6,24 @@ ### Other Changes +## 1.9.0.0 (2022-12-28) +### Breaking Changes+- Slightly modified the signatures of the various `Scoped` interpreters.++### Other Changes+- Added `runScopedNew`, a simple but powerful `Scoped` interpreter.+ `runScopedNew` can be considered a sneak-peek of the future of `Scoped`,+ which will eventually receive a major API rework to make it both simpler and+ more expressive.+- Fixed a bug in various `Scoped` interpreters where a `scoped` usage of an+ effect always relied on the nearest enclosing use of `scoped` from the same+ `Scoped` effect, rather than the `scoped` which handles the effect.+- Added `Polysemy.Opaque`, a module for the `Opaque` effect newtype, meant as+ a tool to wrap polymorphic effect variables so they don't jam up resolution of+ `Member` constraints.+- Expose the type alias `Scoped_` for a scoped effect without callsite parameters.+ ## 1.8.0.0 (2022-12-22) ### Breaking Changes@@ -25,13 +42,19 @@ `fixpointToFinal` instead. - Changed semantics of `errorToIOFinal` so that it no longer catches errors from other handlers of the same type.+- The semantics of `runScoped` has been changed so that the provided interpreter+ is now used only once per use of `scoped`, instead of each individual action. ### Other Changes - Exposed `send` from `Polysemy`. - Dramatically improved build performance of projects when compiling with `-O2`. - Removed the debug `dump-core` flag.-+- Introduced the new meta-effect `Scoped`, which allows running an interpreter locally whose implementation is deferred+ to a later stage.+- Fixed a bug in various `Scoped` interpreters where any explicit recursive+ interpretation of higher-order computations that the handler may perform are+ ignored by the interpreter, and the original handler was reused instead. ## 1.7.1.0 (2021-11-23)
polysemy.cabal view
@@ -1,11 +1,11 @@ cabal-version: 2.0 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.34.7. -- -- see: https://github.com/sol/hpack name: polysemy-version: 1.8.0.0+version: 1.9.0.0 synopsis: Higher-order, low-boilerplate free monads. description: Please see the README on GitHub at <https://github.com/polysemy-research/polysemy#readme> category: Language@@ -65,6 +65,7 @@ Polysemy.IO Polysemy.Membership Polysemy.NonDet+ Polysemy.Opaque Polysemy.Output Polysemy.Reader Polysemy.Resource@@ -142,6 +143,7 @@ Paths_polysemy Build_doctests autogen-modules:+ Paths_polysemy Build_doctests hs-source-dirs: test@@ -165,7 +167,7 @@ async >=2.2 && <3 , base >=4.9 && <5 , containers >=0.5 && <0.7- , doctest >=0.16.0.1 && <0.19+ , doctest >=0.16.0.1 && <0.21 , first-class-families >=0.5.0.0 && <0.9 , hspec >=2.6.0 && <3 , hspec-discover >=2.0
src/Polysemy.hs view
@@ -1,3 +1,4 @@+-- | Description: Polysemy is a library for writing high-power, low-boilerplate domain specific languages module Polysemy ( -- * Core Types Sem ()
src/Polysemy/Async.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE TemplateHaskell #-} +-- | Description: The effect 'Async', providing an interface to "Control.Concurrent.Async" module Polysemy.Async ( -- * Effect Async (..)@@ -30,8 +31,11 @@ -- -- @since 0.5.0.0 data Async m a where+ -- | Run the given action asynchronously and return a thread handle. Async :: m a -> Async m (A.Async (Maybe a))+ -- | Wait for the thread referenced by the given handle to terminate. Await :: A.Async a -> Async m a+ -- | Cancel the thread referenced by the given handle. Cancel :: A.Async a -> Async m () makeSem ''Async
src/Polysemy/AtomicState.hs view
@@ -1,5 +1,7 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE TemplateHaskell #-}++-- | Description: The 'AtomicState' effect module Polysemy.AtomicState ( -- * Effect AtomicState (..)@@ -36,7 +38,9 @@ -- -- @since 1.1.0.0 data AtomicState s m a where+ -- | Run a state action. AtomicState :: (s -> (s, a)) -> AtomicState s m a+ -- | Get the state. AtomicGet :: AtomicState s m s makeSem_ ''AtomicState@@ -78,6 +82,8 @@ return a {-# INLINE atomicState' #-} +-----------------------------------------------------------------------------+-- | Replace the state with the given value. atomicPut :: Member (AtomicState s) r => s -> Sem r ()@@ -86,6 +92,8 @@ return () {-# INLINE atomicPut #-} +-----------------------------------------------------------------------------+-- | Modify the state lazily. atomicModify :: Member (AtomicState s) r => (s -> s) -> Sem r ()
src/Polysemy/Bundle.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-}++-- | Description: The 'Bundle' effect for bundling effects module Polysemy.Bundle ( -- * Effect Bundle (..)
src/Polysemy/Embed.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE TemplateHaskell #-} +-- | Description: Interpreters for the effect 'Embed' module Polysemy.Embed ( -- * Effect Embed (..)
src/Polysemy/Embed/Type.hs view
@@ -2,6 +2,7 @@ {-# OPTIONS_HADDOCK not-home #-} +-- | Description: 'Embed' effect module Polysemy.Embed.Type ( -- * Effect Embed (..)
src/Polysemy/Error.hs view
@@ -1,6 +1,8 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE TemplateHaskell #-}+{-# OPTIONS_HADDOCK prune #-} +-- | Description: The effect 'Error' and its interpreters module Polysemy.Error ( -- * Effect Error (..)@@ -37,8 +39,16 @@ import Unsafe.Coerce (unsafeCoerce) +------------------------------------------------------------------------------+-- | This effect abstracts the throwing and catching of errors, leaving+-- it up to the interpreter whether to use exceptions or monad transformers+-- like 'E.ExceptT' to perform the short-circuiting mechanism. data Error e m a where+ -- | Short-circuit the current program using the given error value. Throw :: e -> Error e m a+ -- | Recover from an error that might have been thrown in the higher-order+ -- action given by the first argument by passing the error to the handler+ -- given by the second argument. Catch :: ∀ e m a. m a -> (e -> m a) -> Error e m a makeSem ''Error
src/Polysemy/Fail.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +-- | Description: 'Fail' interpreters module Polysemy.Fail ( -- * Effect Fail(..)
src/Polysemy/Fail/Type.hs view
@@ -1,3 +1,11 @@+-- | Description: 'Fail' effect module Polysemy.Fail.Type where +------------------------------------------------------------------------------+-- | This effect abstracts the concept of 'Control.Monad.Fail.MonadFail',+-- which is a built-in mechanism that converts pattern matching errors to+-- calls to the current monad's instance of that class.+--+-- The instance defined in "Polysemy.Internal" uses this effect to catch+-- those errors. newtype Fail m a = Fail String
src/Polysemy/Final.hs view
@@ -1,4 +1,7 @@ {-# LANGUAGE TemplateHaskell #-}++-- | Description: The effect 'Final' that allows embedding higher-order actions in+-- the final target monad of the effect stack module Polysemy.Final ( -- * Effect
src/Polysemy/Fixpoint.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes, TemplateHaskell #-} +-- | Description: Interpreters for 'Fixpoint' module Polysemy.Fixpoint ( -- * Effect Fixpoint (..)
src/Polysemy/IO.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +-- | Description: Compatibility with 'MonadIO' module Polysemy.IO ( -- * Interpretations embedToMonadIO@@ -11,7 +12,7 @@ --------------------------------------------------------------------------------- The 'MonadIO' class is conceptually an interpretation of 'IO' to some+-- | The 'MonadIO' class is conceptually an interpretation of 'IO' to some -- other monad. This function reifies that intuition, by transforming an 'IO' -- effect into some other 'MonadIO'. --
src/Polysemy/Input.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE TemplateHaskell #-} +-- | Description: The 'Input' effect module Polysemy.Input ( -- * Effect Input (..)@@ -23,6 +24,7 @@ -- | An effect which can provide input to an application. Useful for dealing -- with streaming input. data Input i m a where+ -- | Get the next available message. Input :: Input i m i makeSem ''Input
src/Polysemy/Internal.hs view
@@ -8,6 +8,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_HADDOCK not-home #-} +-- | Description: The 'Sem' type and the most basic stack manipulation utilities module Polysemy.Internal ( Sem (..) , Member@@ -332,11 +333,15 @@ {-# INLINE mfix #-} +------------------------------------------------------------------------------+-- | Create a 'Sem' from a 'Union' with matching stacks. liftSem :: Union r (Sem r) a -> Sem r a liftSem u = Sem $ \k -> k u {-# INLINE liftSem #-} +------------------------------------------------------------------------------+-- | Extend the stack of a 'Sem' with an explicit 'Union' transformation. hoistSem :: (∀ x. Union r (Sem r) x -> Union r' (Sem r') x) -> Sem r a@@ -344,6 +349,9 @@ hoistSem nat (Sem m) = Sem $ \k -> m $ \u -> k $ nat u {-# INLINE hoistSem #-} +------------------------------------------------------------------------------+-- | Extend the stack of a 'Sem' with an explicit membership proof+-- transformation. restack :: (forall e. ElemOf e r -> ElemOf e r') -> Sem r a -> Sem r' a@@ -362,7 +370,7 @@ {-# INLINE raise_ #-} --- | See 'raise''.+-- | See 'raise'. -- -- @since 1.4.0.0 class Raise (r :: EffectRow) (r' :: EffectRow) where
src/Polysemy/Internal/Bundle.hs view
@@ -2,17 +2,23 @@ {-# OPTIONS_HADDOCK not-home #-} +-- | Description: Stack manipulation handlers for the 'Polysemy.Bundle.Bundle' effect module Polysemy.Internal.Bundle where import Polysemy (Members) import Polysemy.Internal.Union (ElemOf(..), membership) import Polysemy.Internal.Kind (Append) +------------------------------------------------------------------------------+-- | Extend a membership proof's stack by arbitrary effects. extendMembership :: forall r r' e. ElemOf e r -> ElemOf e (Append r r') extendMembership Here = Here extendMembership (There e) = There (extendMembership @_ @r' e) {-# INLINE extendMembership #-} +------------------------------------------------------------------------------+-- | Transform a membership proof's stack by arbitrary effects using evidence+-- from the context. subsumeMembership :: forall r r' e. Members r r' => ElemOf e r -> ElemOf e r' subsumeMembership Here = membership @e @r' subsumeMembership (There (pr :: ElemOf e r'')) = subsumeMembership @r'' @r' pr
src/Polysemy/Internal/Combinators.hs view
@@ -2,6 +2,7 @@ {-# OPTIONS_HADDOCK not-home #-} +-- | Description: The basic interpreter-building combinators module Polysemy.Internal.Combinators ( -- * First order interpret
src/Polysemy/Internal/CustomErrors.hs view
@@ -4,8 +4,9 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} -{-# OPTIONS_HADDOCK not-home #-}+{-# OPTIONS_HADDOCK not-home, prune #-} +-- | Description: type-errors-pretty redefinitions module Polysemy.Internal.CustomErrors ( WhenStuck , FirstOrder@@ -16,9 +17,10 @@ import Data.Kind import Fcf import GHC.TypeLits (Symbol)-import Polysemy.Internal.Kind+import Type.Errors hiding (IfStuck, UnlessStuck, WhenStuck)+ import Polysemy.Internal.CustomErrors.Redefined-import Type.Errors hiding (IfStuck, WhenStuck, UnlessStuck)+import Polysemy.Internal.Kind -- These are taken from type-errors-pretty because it's not in stackage for 9.0.1
src/Polysemy/Internal/CustomErrors/Redefined.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE ConstraintKinds #-}+{-# OPTIONS_HADDOCK prune #-} ------------------------------------------------------------------------------ -- | This code is copied verbatim from 'Type.Errors' due to limitations in the
src/Polysemy/Internal/Fixpoint.hs view
@@ -1,5 +1,6 @@ {-# OPTIONS_HADDOCK not-home #-} +-- | Description: 'Fixpoint' effect module Polysemy.Internal.Fixpoint where ------------------------------------------------------------------------------
src/Polysemy/Internal/Index.hs view
@@ -4,8 +4,9 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE CPP #-} -{-# OPTIONS_HADDOCK not-home #-}+{-# OPTIONS_HADDOCK not-home, prune #-} +-- | Description: Class 'InsertAtIndex' that allows stack extension at a numeric index module Polysemy.Internal.Index where import GHC.TypeLits (Nat)
src/Polysemy/Internal/Kind.hs view
@@ -1,5 +1,6 @@ {-# OPTIONS_HADDOCK not-home #-} +-- | Description: Kind aliases 'Effect' and 'EffectRow' module Polysemy.Internal.Kind where import Data.Kind (Type)@@ -17,6 +18,8 @@ type EffectRow = [Effect] +------------------------------------------------------------------------------+-- | Append two type-level lists. type family Append l r where Append (a ': l) r = a ': (Append l r) Append '[] r = r
src/Polysemy/Internal/NonDet.hs view
@@ -4,6 +4,7 @@ {-# OPTIONS_HADDOCK not-home #-} +-- | Description: The 'NonDet' effect module Polysemy.Internal.NonDet where
src/Polysemy/Internal/Scoped.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# OPTIONS_HADDOCK not-home #-} +-- | Description: The meta-effect 'Scoped' module Polysemy.Internal.Scoped where import Data.Kind (Type)@@ -103,9 +104,13 @@ -- -- The type 'Scoped_' and the constructor 'scoped_' simply fix @param@ to @()@. data Scoped (param :: Type) (effect :: Effect) :: Effect where- Run :: ∀ param effect m a . effect m a -> Scoped param effect m a- InScope :: ∀ param effect m a . param -> m a -> Scoped param effect m a+ Run :: ∀ param effect m a . Word -> effect m a -> Scoped param effect m a+ InScope :: ∀ param effect m a . param -> (Word -> m a) -> Scoped param effect m a +-- | An auxiliary effect for 'Scoped'.+data OuterRun (effect :: Effect) :: Effect where+ OuterRun :: ∀ effect m a . Word -> effect m a -> OuterRun effect m a+ -- |A convenience alias for a scope without parameters. type Scoped_ effect = Scoped () effect@@ -120,8 +125,8 @@ param -> InterpreterFor effect r scoped param main =- send $ InScope @param @effect param do- transform @effect (Run @param) main+ send $ InScope @param @effect param $ \w ->+ transform @effect (Run @param w) main {-# inline scoped #-} -- | Constructor for 'Scoped_', taking a nested program and transforming all@@ -148,7 +153,7 @@ InterpreterFor (Scoped param0 effect) r rescope fp = transform \case- Run e -> Run @param1 e+ Run w e -> Run @param1 w e InScope p main -> InScope (fp p) main {-# inline rescope #-}
src/Polysemy/Internal/Sing.hs view
@@ -5,15 +5,21 @@ {-# OPTIONS_HADDOCK not-home #-} +-- | Description: Singleton list module Polysemy.Internal.Sing where -import GHC.TypeLits (type (-), Nat)+import GHC.TypeLits (Nat, type (-))+ import Polysemy.Internal.Kind (Effect) +------------------------------------------------------------------------------+-- | A singleton type used as a witness for type-level lists. data SList l where SEnd :: SList '[] SCons :: SList xs -> SList (x ': xs) +------------------------------------------------------------------------------+-- | A singleton list constructor class. class KnownList l where singList :: SList l @@ -25,6 +31,8 @@ singList = SCons singList {-# INLINE singList #-} +------------------------------------------------------------------------------+-- | A utility class for constructing a type-level list of a given length. class ListOfLength (n :: Nat) (l :: [Effect]) where listOfLength :: SList l
src/Polysemy/Internal/Strategy.hs view
@@ -1,5 +1,7 @@ {-# OPTIONS_HADDOCK not-home #-} +-- | Description: The auxiliary effect 'Strategy' used for building interpreters+-- that embed 'Sem's in 'IO' callbacks module Polysemy.Internal.Strategy where import Polysemy.Internal@@ -7,7 +9,8 @@ import Polysemy.Internal.Tactics (Inspector(..)) -+------------------------------------------------------------------------------+-- | See 'Strategic'. data Strategy m f n z a where GetInitialState :: Strategy m f n z (f ()) HoistInterpretation :: (a -> n b) -> Strategy m f n z (f a -> m (f b))
src/Polysemy/Internal/TH/Common.hs view
@@ -4,8 +4,9 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE ViewPatterns #-} -{-# OPTIONS_HADDOCK not-home #-}+{-# OPTIONS_HADDOCK not-home, prune #-} +-- | Description: TH utilities for generating effect constructors module Polysemy.Internal.TH.Common ( ConLiftInfo (..) , getEffectMetadata@@ -168,8 +169,8 @@ ------------------------------------------------------------------------------ -- | Given a 'ConLiftInfo', this will produce an action for it. It's arguments--- will come from any variables in scope that correspond to the 'cliArgs' of--- the 'ConLiftInfo'.+-- will come from any variables in scope that correspond to the 'cliEffArgs'+-- of the 'ConLiftInfo'. makeUnambiguousSend :: Bool -> ConLiftInfo -> Exp makeUnambiguousSend should_make_sigs cli = let fun_args_names = fst <$> cliFunArgs cli
src/Polysemy/Internal/TH/Effect.hs view
@@ -3,7 +3,7 @@ {-# OPTIONS_HADDOCK not-home #-} -- | This module provides Template Haskell functions for automatically generating--- effect operation functions (that is, functions that use 'send') from a given+-- effect operation functions (that is, functions that use 'Polysemy.send') from a given -- effect algebra. For example, using the @FileSystem@ effect from the example in -- the module documentation for "Polysemy", we can write the following: --@@ -18,11 +18,11 @@ -- This will automatically generate (approximately) the following functions: -- -- @--- readFile :: 'Member' FileSystem r => 'FilePath' -> 'Sem' r 'String'--- readFile a = 'send' (ReadFile a)+-- readFile :: 'Polysemy.Member' FileSystem r => 'FilePath' -> 'Polysemy.Sem' r 'String'+-- readFile a = 'Polysemy.send' (ReadFile a) ----- writeFile :: 'Member' FileSystem r => 'FilePath' -> 'String' -> 'Sem' r ()--- writeFile a b = 'send' (WriteFile a b)+-- writeFile :: 'Polysemy.Member' FileSystem r => 'FilePath' -> 'String' -> 'Polysemy.Sem' r ()+-- writeFile a b = 'Polysemy.send' (WriteFile a b) -- @ module Polysemy.Internal.TH.Effect ( makeSem@@ -76,8 +76,8 @@ -- rules to work properly: -- -- * 'makeSem_' must be used /before/ the explicit type signatures--- * signatures have to specify argument of 'Sem' representing union of--- effects as @r@ (e.g. @'Sem' r ()@)+-- * signatures have to specify argument of 'Polysemy.Sem' representing union of+-- effects as @r@ (e.g. @'Polysemy.Sem' r ()@) -- * all arguments in effect's type constructor have to follow naming scheme -- from data constructor's declaration: --@@ -121,7 +121,7 @@ ------------------------------------------------------------------------------ -- | Generates declarations and possibly signatures for functions to lift GADT--- constructors into 'Sem' actions.+-- constructors into 'Polysemy.Sem' actions. genFreer :: Bool -> Name -> Q [Dec] genFreer should_mk_sigs type_name = do checkExtensions [ScopedTypeVariables, FlexibleContexts, DataKinds]
src/Polysemy/Internal/Tactics.hs view
@@ -2,6 +2,7 @@ {-# OPTIONS_HADDOCK not-home #-} +-- | Description: The auxiliary higher-order interpreter effect 'Tactics' module Polysemy.Internal.Tactics ( Tactics (..) , getInitialStateT@@ -76,8 +77,12 @@ type Tactical e m r x = ∀ f. Functor f => Sem (WithTactics e f m r) (f x) +------------------------------------------------------------------------------+-- | Convenience type alias, see 'Tactical'. type WithTactics e f m r = Tactics f m (e ': r) ': r +------------------------------------------------------------------------------+-- | See 'Tactical'. data Tactics f n r m a where GetInitialState :: Tactics f n r m (f ()) HoistInterpretation :: (a -> n b) -> Tactics f n r m (f a -> Sem r (f b))
src/Polysemy/Internal/Union.hs view
@@ -14,8 +14,9 @@ {-# LANGUAGE UndecidableSuperClasses #-} {-# LANGUAGE ViewPatterns #-} -{-# OPTIONS_HADDOCK not-home #-}+{-# OPTIONS_HADDOCK not-home, prune #-} +-- | Description: 'Union', 'Weaving' and 'ElemOf', Polysemy's core types module Polysemy.Internal.Union ( Union (..) , Weaving (..)@@ -75,6 +76,9 @@ {-# INLINABLE fmap #-} +------------------------------------------------------------------------------+-- | Polysemy's core type that stores effect values together with information+-- about the higher-order interpretation state of its construction site. data Weaving e mAfter resultType where Weaving :: forall f e rInitial a resultType mAfter. (Functor f)@@ -188,7 +192,11 @@ Nothing +------------------------------------------------------------------------------+-- | This class indicates that an effect must be present in the caller's stack.+-- It is the main mechanism by which a program defines its effect dependencies. class Member (t :: Effect) (r :: EffectRow) where+ -- | Create a proof that the effect @t@ is present in the effect stack @r@. membership' :: ElemOf t r instance {-# OVERLAPPING #-} Member t (t ': z) where
src/Polysemy/Internal/Writer.hs view
@@ -1,5 +1,7 @@ {-# LANGUAGE BangPatterns, TemplateHaskell, TupleSections #-}-{-# OPTIONS_HADDOCK not-home #-}+{-# OPTIONS_HADDOCK not-home, prune #-}++-- | Description: The 'Writer' effect module Polysemy.Internal.Writer where import Control.Concurrent.STM@@ -20,8 +22,11 @@ ------------------------------------------------------------------------------ -- | An effect capable of emitting and intercepting messages. data Writer o m a where+ -- | Write a message to the log. Tell :: o -> Writer o m ()+ -- | Return the log produced by the higher-order action. Listen :: ∀ o m a. m a -> Writer o m (o, a)+ -- | Run the given action and apply the function it returns to the log. Pass :: m (o -> o, a) -> Writer o m a makeSem ''Writer
src/Polysemy/Membership.hs view
@@ -1,3 +1,4 @@+-- | Description: Reexports of membership related functionality module Polysemy.Membership ( -- * Witnesses ElemOf (..)
src/Polysemy/NonDet.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE TemplateHaskell #-} +-- | Description: Interpreters for 'NonDet' module Polysemy.NonDet ( -- * Effect NonDet (..)
+ src/Polysemy/Opaque.hs view
@@ -0,0 +1,54 @@+-- | The auxiliary effect 'Opaque' used by interpreters of 'Polysemy.Scoped.Scoped'+module Polysemy.Opaque (+ -- * Effect+ Opaque(..),++ -- * Interpreters+ toOpaque,+ fromOpaque,+ ) where++import Polysemy++-- | An effect newtype meant to be used to wrap polymorphic effect variables to+-- prevent them from jamming up resolution of 'Polysemy.Member'.+-- For example, consider:+--+-- @+-- badPut :: 'Sem' (e ': 'Polysemy.State.State' () ': r) ()+-- badPut = 'Polysemy.State.put' () -- error+-- @+--+-- This fails to compile. This is because @e@ /could/ be+-- @'Polysemy.State.State' ()@' -- in which case the 'Polysemy.State.put'+-- should target it instead of the concretely provided+-- @'Polysemy.State.State' ()@; as the compiler can't know for sure which effect+-- should be targeted, the program is rejected.+-- There are various ways to resolve this, including using 'raise' or+-- 'Polysemy.Membership.subsumeUsing'. 'Opaque' provides another way:+--+-- @+-- okPut :: 'Sem' (e ': 'Polysemy.State.State' () ': r) ()+-- okPut = 'fromOpaque' ('Polysemy.State.put' ()) -- OK+-- @+--+-- 'Opaque' is most useful as a tool for library writers, in the case where some+-- function of the library requires the user to work with an effect stack+-- containing some polymorphic effect variables. By wrapping the polymorphic+-- effect variables using 'Opaque', users of the function can use effects as+-- normal, without having to use 'raise' or 'Polysemy.Membership.subsumeUsing'+-- in order to have 'Polysemy.Member' resolve. The various interpreters of+-- 'Polysemy.Scoped.Scoped' are examples of such usage of 'Opaque'.+--+-- @since 1.9.0.0+newtype Opaque (e :: Effect) m a = Opaque (e m a)++-- | Wrap 'Opaque' around the top effect of the effect stack+toOpaque :: Sem (e ': r) a -> Sem (Opaque e ': r) a+toOpaque = rewrite Opaque+{-# INLINE toOpaque #-}++-- | Unwrap 'Opaque' around the top effect of the effect stack+fromOpaque :: Sem (Opaque e ': r) a -> Sem (e ': r) a+fromOpaque = rewrite (\(Opaque e) -> e)+{-# INLINE fromOpaque #-}
src/Polysemy/Output.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE BangPatterns, TemplateHaskell #-} +-- | Description: The 'Output' effect for sending side-effecting messages module Polysemy.Output ( -- * Effect Output (..)@@ -41,6 +42,7 @@ -- | An effect capable of sending messages. Useful for streaming output and for -- logging. data Output o m a where+ -- | Output a message. Output :: o -> Output o m () makeSem ''Output
src/Polysemy/Reader.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE TemplateHaskell #-} +-- | Description: The 'Reader' effect and its interpreters module Polysemy.Reader ( -- * Effect Reader (..)@@ -23,12 +24,16 @@ ------------------------------------------------------------------------------ -- | An effect corresponding to 'Control.Monad.Trans.Reader.ReaderT'. data Reader i m a where+ -- | Get the environment. Ask :: Reader i m i+ -- | Transform the environment. Local :: (i -> i) -> m a -> Reader i m a makeSem ''Reader +------------------------------------------------------------------------------+-- | Apply a function to the environment and return the result. asks :: forall i j r. Member (Reader i) r => (i -> j) -> Sem r j asks f = f <$> ask {-# INLINABLE asks #-}
src/Polysemy/Resource.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE TemplateHaskell #-} +-- | Description: The 'Resource' effect, providing bracketing functionality module Polysemy.Resource ( -- * Effect Resource (..)@@ -26,6 +27,7 @@ -- will successfully run the deallocation action even in the presence of other -- short-circuiting effects. data Resource m a where+ -- | Allocate a resource, use it, and clean it up afterwards. Bracket :: m a -- Action to allocate a resource.@@ -35,6 +37,7 @@ -> (a -> m b) -- Action which uses the resource. -> Resource m b+ -- | Allocate a resource, use it, and clean it up afterwards if an error occurred. BracketOnError :: m a -- Action to allocate a resource.
src/Polysemy/Scoped.hs view
@@ -1,8 +1,10 @@-{-# language AllowAmbiguousTypes #-}+{-# language AllowAmbiguousTypes, BangPatterns #-} +-- | Description: Interpreters for 'Scoped' module Polysemy.Scoped ( -- * Effect Scoped,+ Scoped_, -- * Constructors scoped,@@ -10,6 +12,7 @@ rescope, -- * Interpreters+ runScopedNew, interpretScopedH, interpretScopedH', interpretScoped,@@ -21,6 +24,11 @@ runScopedAs, ) where +import Data.Function ((&))+import Data.Sequence (Seq(..))+import qualified Data.Sequence as S++import Polysemy.Opaque import Polysemy.Internal import Polysemy.Internal.Sing import Polysemy.Internal.Union@@ -40,23 +48,17 @@ -- | A callback function that allows the user to acquire a resource for each -- computation wrapped by 'scoped' using other effects, with an additional -- argument that contains the call site parameter passed to 'scoped'.- (∀ x . param -> (resource -> Sem r x) -> Sem r x) ->+ (∀ q x . param ->+ (resource -> Sem (Opaque q ': r) x) ->+ Sem (Opaque q ': r) x) -> -- | A handler like the one expected by 'interpretH' with an additional -- parameter that contains the @resource@ allocated by the first argument.- (∀ r0 x . resource -> effect (Sem r0) x -> Tactical effect (Sem r0) r x) ->+ (∀ q r0 x . resource ->+ effect (Sem r0) x ->+ Tactical effect (Sem r0) (Opaque q ': r) x) -> InterpreterFor (Scoped param effect) r-interpretScopedH withResource scopedHandler =- -- TODO investigate whether loopbreaker optimization is effective here- go (errorWithoutStackTrace "top level run")- where- go :: resource -> InterpreterFor (Scoped param effect) r- go resource =- interpretWeaving \ (Weaving effect s wv ex ins) -> case effect of- Run act ->- ex <$> runTactics s (raise . go resource . wv) ins (go resource . wv)- (scopedHandler resource act)- InScope param main ->- withResource param \ resource' -> ex <$> go resource' (wv (main <$ s))+interpretScopedH withResource scopedHandler = runScopedNew \param sem ->+ withResource param \r -> interpretH (scopedHandler r) sem {-# inline interpretScopedH #-} -- | Variant of 'interpretScopedH' that allows the resource acquisition function@@ -70,26 +72,28 @@ Tactical (Scoped param effect) (Sem r0) r x) -> InterpreterFor (Scoped param effect) r interpretScopedH' withResource scopedHandler =- go (errorWithoutStackTrace "top level run")+ go 0 Empty where- go :: resource -> InterpreterFor (Scoped param effect) r- go resource =+ go :: Word -> Seq resource -> InterpreterFor (Scoped param effect) r+ go depth resources = interpretH \case- Run act ->- scopedHandler resource act- InScope param main ->- withResource param \ resource' ->- raise . go resource' =<< runT main+ Run w act ->+ scopedHandler (S.index resources (fromIntegral w)) act+ InScope param main | !depth' <- depth + 1 ->+ withResource param \ resource ->+ raise . go depth' (resources :|> resource) =<< runT (main depth) {-# inline interpretScopedH' #-} -- | First-order variant of 'interpretScopedH'. interpretScoped :: ∀ resource param effect r .- (∀ x . param -> (resource -> Sem r x) -> Sem r x) ->+ (∀ q x . param ->+ (resource -> Sem (Opaque q ': r) x) ->+ Sem (Opaque q ': r) x) -> (∀ m x . resource -> effect m x -> Sem r x) -> InterpreterFor (Scoped param effect) r interpretScoped withResource scopedHandler =- interpretScopedH withResource \ r e -> liftT (scopedHandler r e)+ interpretScopedH withResource \ r e -> liftT (raise (scopedHandler r e)) {-# inline interpretScoped #-} -- | Variant of 'interpretScoped' in which the resource allocator is a plain@@ -100,7 +104,7 @@ (∀ m x . resource -> effect m x -> Sem r x) -> InterpreterFor (Scoped param effect) r interpretScopedAs resource =- interpretScoped \ p use -> use =<< resource p+ interpretScoped \ p use -> use =<< raise (resource p) {-# inline interpretScopedAs #-} -- | Higher-order interpreter for 'Scoped' that allows the handler to use@@ -150,32 +154,24 @@ -- > MRead -> -- > liftT atomicGet interpretScopedWithH ::- ∀ extra resource param effect r r1 .- (KnownList extra, r1 ~ Append extra r) =>- (∀ x . param -> (resource -> Sem r1 x) -> Sem r x) ->- (∀ r0 x . resource -> effect (Sem r0) x -> Tactical effect (Sem r0) r1 x) ->+ ∀ extra resource param effect r .+ KnownList extra =>+ (∀ q x .+ param ->+ (resource -> Sem (Append extra (Opaque q ': r)) x) ->+ Sem (Opaque q ': r) x) ->+ (∀ q r0 x .+ resource ->+ effect (Sem r0) x ->+ Tactical effect (Sem r0) (Append extra (Opaque q ': r)) x) -> InterpreterFor (Scoped param effect) r-interpretScopedWithH withResource scopedHandler =- interpretWeaving \case- Weaving (InScope param main) s wv ex _ ->- ex <$> withResource param \ resource -> inScope resource $- restack- (injectMembership- (singList @'[Scoped param effect])- (singList @extra)) $ wv (main <$ s)- _ ->- errorWithoutStackTrace "top level Run"- where- inScope :: resource -> InterpreterFor (Scoped param effect) r1- inScope resource =- interpretWeaving \case- Weaving (InScope param main) s wv ex _ ->- restack (extendMembershipLeft (singList @extra))- (ex <$> withResource param \resource' ->- inScope resource' (wv (main <$ s)))- Weaving (Run act) s wv ex ins ->- ex <$> runTactics s (raise . inScope resource . wv) ins (inScope resource . wv)- (scopedHandler resource act)+interpretScopedWithH withResource scopedHandler = runScopedNew+ \param (sem :: Sem (effect ': Opaque q ': r) x) ->+ withResource param \resource ->+ sem+ & restack+ (injectMembership (singList @'[effect]) (singList @extra))+ & interpretH (scopedHandler @q resource) {-# inline interpretScopedWithH #-} -- | First-order variant of 'interpretScopedWithH'.@@ -194,13 +190,24 @@ -- > where -- > localEffects () use = evalState False (runReader 5 (use ())) interpretScopedWith ::- ∀ extra param resource effect r r1 .- (r1 ~ Append extra r, KnownList extra) =>- (∀ x . param -> (resource -> Sem r1 x) -> Sem r x) ->- (∀ m x . resource -> effect m x -> Sem r1 x) ->+ ∀ extra param resource effect r.+ KnownList extra =>+ (∀ q x .+ param ->+ (resource -> Sem (Append extra (Opaque q ': r)) x) ->+ Sem (Opaque q ': r) x) ->+ (∀ m x . resource -> effect m x -> Sem (Append extra r) x) -> InterpreterFor (Scoped param effect) r-interpretScopedWith withResource scopedHandler =- interpretScopedWithH @extra withResource \ r e -> liftT (scopedHandler r e)+interpretScopedWith withResource scopedHandler = runScopedNew+ \param (sem :: Sem (effect ': Opaque q ': r) x) ->+ withResource param \resource ->+ sem+ & restack+ (injectMembership (singList @'[effect]) (singList @extra))+ & interpretH \e -> liftT $+ restack+ (injectMembership @r (singList @extra) (singList @'[Opaque q]))+ (scopedHandler resource e) {-# inline interpretScopedWith #-} -- | Variant of 'interpretScopedWith' in which no resource is used and the@@ -210,13 +217,18 @@ -- -- See the /Note/ on 'interpretScopedWithH'. interpretScopedWith_ ::- ∀ extra param effect r r1 .- (r1 ~ Append extra r, KnownList extra) =>- (∀ x . param -> Sem r1 x -> Sem r x) ->- (∀ m x . effect m x -> Sem r1 x) ->+ ∀ extra param effect r .+ KnownList extra =>+ (∀ q x .+ param ->+ Sem (Append extra (Opaque q ': r)) x ->+ Sem (Opaque q ': r) x) ->+ (∀ m x . effect m x -> Sem (Append extra r) x) -> InterpreterFor (Scoped param effect) r interpretScopedWith_ withResource scopedHandler =- interpretScopedWithH @extra (\ p f -> withResource p (f ())) \ () e -> liftT (scopedHandler e)+ interpretScopedWith @extra+ (\ p f -> withResource p (f ()))+ (\ () -> scopedHandler) {-# inline interpretScopedWith_ #-} -- | Variant of 'interpretScoped' that uses another interpreter instead of a@@ -226,54 +238,92 @@ -- easily rewrite (like from another library). If you have full control over the -- implementation, 'interpretScoped' should be preferred. ----- /Note/: The wrapped interpreter will be executed fully, including the--- initializing code surrounding its handler, for each action in the program, so--- if the interpreter allocates any resources, they will be scoped to a single--- action. Move them to @withResource@ instead.------ For example, consider the following interpreter for--- 'Polysemy.AtomicState.AtomicState':------ > atomicTVar :: Member (Embed IO) r => a -> InterpreterFor (AtomicState a) r--- > atomicTVar initial sem = do--- > tv <- embed (newTVarIO initial)--- > runAtomicStateTVar tv sem------ If this interpreter were used for a scoped version of @AtomicState@ like--- this:------ > runScoped (\ initial use -> use initial) \ initial -> atomicTVar initial------ Then the @TVar@ would be created every time an @AtomicState@ action is run,--- not just when entering the scope.------ The proper way to implement this would be to rewrite the resource allocation:+-- /Note/: In previous versions of Polysemy, the wrapped interpreter was+-- executed fully, including the initializing code surrounding its handler,+-- for each action in the program. However, new and continuing discoveries+-- regarding 'Scoped' has allowed the improvement of having the interpreter be+-- used only once per use of 'scoped', and have it cover the same scope of+-- actions that the resource allocator does. ----- > runScoped (\ initial use -> use =<< embed (newTVarIO initial)) runAtomicStateTVar+-- This renders the resource allocator practically redundant; for the moment,+-- the API surrounding 'Scoped' remains the same, but work is in progress to+-- revamp the entire API of 'Scoped'. runScoped :: ∀ resource param effect r .- (∀ x . param -> (resource -> Sem r x) -> Sem r x) ->- (resource -> InterpreterFor effect r) ->+ (∀ q x . param -> (resource -> Sem (Opaque q ': r) x) -> Sem (Opaque q ': r) x) ->+ (∀ q . resource -> InterpreterFor effect (Opaque q ': r)) -> InterpreterFor (Scoped param effect) r-runScoped withResource scopedInterpreter =- go (errorWithoutStackTrace "top level run")- where- go :: resource -> InterpreterFor (Scoped param effect) r- go resource =- interpretWeaving \ (Weaving effect s wv ex ins) -> case effect of- Run act ->- scopedInterpreter resource- $ liftSem $ injWeaving $ Weaving act s (raise . go resource . wv) ex ins- InScope param main ->- withResource param \ resource' -> ex <$> go resource' (wv (main <$ s))+runScoped withResource scopedInterpreter = runScopedNew \param sem ->+ withResource param (\r -> scopedInterpreter r sem) {-# inline runScoped #-} -- | Variant of 'runScoped' in which the resource allocator returns the resource--- rather tnen calling a continuation.+-- rather than calling a continuation. runScopedAs :: ∀ resource param effect r . (param -> Sem r resource) ->- (resource -> InterpreterFor effect r) ->+ (∀ q. resource -> InterpreterFor effect (Opaque q ': r)) -> InterpreterFor (Scoped param effect) r-runScopedAs resource = runScoped \ p use -> use =<< resource p+runScopedAs resource = runScoped \ p use -> use =<< raise (resource p) {-# inline runScopedAs #-}++-- | Run a 'Scoped' effect by specifying the interpreter to be used at every+-- use of 'scoped'.+--+-- This interpretation of 'Scoped' is powerful enough to subsume all other+-- interpretations of 'Scoped' (except 'interpretScopedH'' which works+-- differently from all other interpretations) while also being much simpler.+--+-- Consider this a sneak-peek of the future of 'Scoped'. In the API rework+-- planned for 'Scoped', the effect and its interpreters will be further+-- expanded to make 'Scoped' even more flexible.+--+-- @since 1.9.0.0+runScopedNew ::+ ∀ param effect r .+ (∀ q. param -> InterpreterFor effect (Opaque q ': r)) ->+ InterpreterFor (Scoped param effect) r+runScopedNew h =+ interpretWeaving $ \(Weaving effect s wv ex _) -> case effect of+ Run w _ -> errorWithoutStackTrace $ "top level run with depth " ++ show w+ InScope param main ->+ wv (main 0 <$ s)+ & raiseUnder2+ & go 0+ & h param+ & interpretH (\(Opaque (OuterRun w _)) ->+ errorWithoutStackTrace $ "unhandled OuterRun with depth " ++ show w)+ & fmap ex+ where+ go' :: Word+ -> InterpreterFor+ (Opaque (OuterRun effect))+ (effect ': Opaque (OuterRun effect) ': r)+ go' depth =+ interpretWeaving \ (Weaving sr@(Opaque (OuterRun w act)) s wv ex ins) ->+ if w == depth then+ liftSem $ injWeaving $ Weaving act s (go' depth . wv) ex ins+ else+ liftSem $ injWeaving $ Weaving sr s (go' depth . wv) ex ins++ -- TODO investigate whether loopbreaker optimization is effective here+ go :: Word+ -> InterpreterFor+ (Scoped param effect)+ (effect ': Opaque (OuterRun effect) ': r)+ go depth =+ interpretWeaving \ (Weaving effect s wv ex ins) -> case effect of+ Run w act+ | w == depth -> liftSem $ injWeaving $+ Weaving act s (go depth . wv) ex ins+ | otherwise -> liftSem $ injWeaving $+ Weaving (Opaque (OuterRun w act)) s (go depth . wv) ex ins+ InScope param main -> do+ let !depth' = depth + 1+ wv (main depth' <$ s)+ & go depth'+ & h param+ & raiseUnder2+ & go' depth+ & fmap ex+{-# INLINE runScopedNew #-}
src/Polysemy/State.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE TemplateHaskell #-} +-- | Description: The 'State' effect module Polysemy.State ( -- * Effect State (..)@@ -28,15 +29,15 @@ , hoistStateIntoStateT ) where -import Control.Monad.ST+import Control.Monad.ST import qualified Control.Monad.Trans.State as S-import Data.IORef-import Data.STRef-import Data.Tuple (swap)-import Polysemy-import Polysemy.Internal-import Polysemy.Internal.Combinators-import Polysemy.Internal.Union+import Data.IORef+import Data.STRef+import Data.Tuple (swap)+import Polysemy+import Polysemy.Internal+import Polysemy.Internal.Combinators+import Polysemy.Internal.Union ------------------------------------------------------------------------------@@ -48,17 +49,23 @@ -- Interpreters which require statefulness can 'Polysemy.reinterpret' -- themselves in terms of 'State', and subsequently call 'runState'. data State s m a where+ -- | Get the state. Get :: State s m s+ -- | Update the state. Put :: s -> State s m () makeSem ''State +------------------------------------------------------------------------------+-- | Apply a function to the state and return the result. gets :: forall s a r. Member (State s) r => (s -> a) -> Sem r a gets f = f <$> get {-# INLINABLE gets #-} +------------------------------------------------------------------------------+-- | Modify the state. modify :: Member (State s) r => (s -> s) -> Sem r () modify f = do s <- get
src/Polysemy/Tagged.hs view
@@ -1,4 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-}++-- | Description: The 'Tagged' effect and its interpreters module Polysemy.Tagged ( -- * Effect
src/Polysemy/Trace.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE TemplateHaskell #-} +-- | Description: The 'Trace' effect and its interpreters module Polysemy.Trace ( -- * Effect Trace (..)@@ -28,6 +29,7 @@ ------------------------------------------------------------------------------ -- | An effect for logging strings. data Trace m a where+ -- | Log a message. Trace :: String -> Trace m () makeSem ''Trace
src/Polysemy/Writer.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE TupleSections #-} +-- | Description: Interpreters for 'Writer' module Polysemy.Writer ( -- * Effect Writer (..)
test/ScopedSpec.hs view
@@ -4,6 +4,7 @@ import Control.Concurrent.STM import Polysemy+import Polysemy.Internal.Tactics import Polysemy.Scoped import Test.Hspec @@ -54,6 +55,41 @@ tv <- embed (newTVarIO n) interpretF tv (use tv) +data HO :: Effect where+ Inc :: m a -> HO m a+ Ret :: HO m Int++makeSem ''HO++scopeHO :: () -> (() -> Sem r a) -> Sem r a+scopeHO () use =+ use ()++handleHO :: Int -> () -> HO m a -> Tactical HO m r a+handleHO n () = \case+ Inc ma -> raise . interpretH (handleHO (n + 1) ()) =<< runT ma+ Ret -> pureT n++data Esc :: Effect where+ Esc :: Esc m Int+makeSem ''Esc++data Indirect :: Effect where+ Indirect :: Indirect m Int+makeSem ''Indirect++interpretIndirect :: Member Esc r => InterpreterFor Indirect r+interpretIndirect = interpret \ Indirect -> esc++handleEsc :: Int -> Esc m a -> Sem r a+handleEsc i = \ Esc -> pure i++test_escape :: Sem (Scoped Int Esc ': r) Int+test_escape =+ scoped @Int @Esc 2+ $ interpretIndirect+ $ scoped @Int @Esc 1 indirect+ spec :: Spec spec = parallel do describe "Scoped" do@@ -63,5 +99,19 @@ i1 <- e1 i2 <- scoped @Par @E 23 e1 pure (i1, i2)- 35 `shouldBe` i1- 38 `shouldBe` i2+ i1 `shouldBe` 35+ i2 `shouldBe` 38+ it "switch interpreter" do+ r <- runM $ interpretScopedH scopeHO (handleHO 1) do+ scoped_ @HO do+ inc do+ ret+ r `shouldBe` 2+ it "scoped depth" do+ r <- runM $ interpretScoped (flip ($)) handleEsc $ test_escape+ r `shouldBe` 2+ r' <- runM $ interpretScopedH'+ (\r h -> h r)+ (\i e -> liftT (handleEsc i e))+ $ test_escape+ r' `shouldBe` 2