capability-0.4.0.0: Extensional capabilities and deriving combinators
Safe HaskellNone
LanguageHaskell2010

Capability.Accessors

Description

Defines newtypes that serve as combinators to compose deriving via strategies.

Synopsis

Documentation

newtype Coerce (to :: Type) m (a :: Type) Source #

Coerce the type in the context m to to.

Example:

newtype MyInt = MyInt Int
newtype MyReader a = MyReader (Reader Int a)
  deriving (HasReader "a" MyInt) via
    Coerce MyInt (MonadReader (Reader Int))

Converts the HasReader "a" Int instance of MonadReader (Reader Int) to a HasReader "a" MyInt instance using Coercible Int MyInt.

Constructors

Coerce (m a) 

Instances

Instances details
(Coercible from to, HasSink tag from m) => HasSink (tag :: k) to (Coerce to m) Source #

Convert the state using safe coercion.

Instance details

Defined in Capability.Sink.Internal.Strategies

Methods

yield_ :: Proxy# tag -> to -> Coerce to m () Source #

(Coercible from to, HasSource tag from m, forall x y. Coercible x y => Coercible (m x) (m y)) => HasSource (tag :: k) to (Coerce to m) Source # 
Instance details

Defined in Capability.Source.Internal.Strategies

Methods

await_ :: Proxy# tag -> Coerce to m to Source #

(Coercible from to, HasReader tag from m, forall x y. Coercible x y => Coercible (m x) (m y)) => HasReader (tag :: k) to (Coerce to m) Source #

Convert the environment using safe coercion.

Instance details

Defined in Capability.Reader.Internal.Strategies

Methods

local_ :: Proxy# tag -> (to -> to) -> Coerce to m a -> Coerce to m a Source #

reader_ :: Proxy# tag -> (to -> a) -> Coerce to m a Source #

(Coercible from to, HasState tag from m, forall x y. Coercible x y => Coercible (m x) (m y)) => HasState (tag :: k) to (Coerce to m) Source #

Convert the state using safe coercion.

Instance details

Defined in Capability.State.Internal.Strategies

Methods

state_ :: Proxy# tag -> (to -> (a, to)) -> Coerce to m a Source #

Monad m => Monad (Coerce to m) Source # 
Instance details

Defined in Capability.Accessors

Methods

(>>=) :: Coerce to m a -> (a -> Coerce to m b) -> Coerce to m b #

(>>) :: Coerce to m a -> Coerce to m b -> Coerce to m b #

return :: a -> Coerce to m a #

Functor m => Functor (Coerce to m) Source # 
Instance details

Defined in Capability.Accessors

Methods

fmap :: (a -> b) -> Coerce to m a -> Coerce to m b #

(<$) :: a -> Coerce to m b -> Coerce to m a #

Applicative m => Applicative (Coerce to m) Source # 
Instance details

Defined in Capability.Accessors

Methods

pure :: a -> Coerce to m a #

(<*>) :: Coerce to m (a -> b) -> Coerce to m a -> Coerce to m b #

liftA2 :: (a -> b -> c) -> Coerce to m a -> Coerce to m b -> Coerce to m c #

(*>) :: Coerce to m a -> Coerce to m b -> Coerce to m b #

(<*) :: Coerce to m a -> Coerce to m b -> Coerce to m a #

MonadIO m => MonadIO (Coerce to m) Source # 
Instance details

Defined in Capability.Accessors

Methods

liftIO :: IO a -> Coerce to m a #

PrimMonad m => PrimMonad (Coerce to m) Source # 
Instance details

Defined in Capability.Accessors

Associated Types

type PrimState (Coerce to m) #

Methods

primitive :: (State# (PrimState (Coerce to m)) -> (# State# (PrimState (Coerce to m)), a #)) -> Coerce to m a #

type PrimState (Coerce to m) Source # 
Instance details

Defined in Capability.Accessors

type PrimState (Coerce to m) = PrimState m

newtype Rename (oldtag :: k) m (a :: Type) Source #

Rename the tag.

Example:

newtype MyReader a = MyReader (Reader Int a)
  deriving (HasReader "foo" Int) via
    Rename "bar" (MonadReader (Reader Int))

Converts the HasReader "bar" Int instance of MonadReader (Reader Int) to a HasReader "foo" Int instance by renaming the tag.

Note, that MonadReader itself does not fix a tag, and Rename is redundant in this example.

See Pos below for a common use-case.

Constructors

Rename (m a) 

Instances

Instances details
HasSink oldtag s m => HasSink (newtag :: k2) s (Rename oldtag m) Source #

Rename the tag.

Instance details

Defined in Capability.Sink.Internal.Strategies

Methods

yield_ :: Proxy# newtag -> s -> Rename oldtag m () Source #

HasSource oldtag r m => HasSource (newtag :: k2) r (Rename oldtag m) Source #

Rename the tag.

Instance details

Defined in Capability.Source.Internal.Strategies

Methods

await_ :: Proxy# newtag -> Rename oldtag m r Source #

HasReader oldtag r m => HasReader (newtag :: k2) r (Rename oldtag m) Source #

Rename the tag.

Instance details

Defined in Capability.Reader.Internal.Strategies

Methods

local_ :: Proxy# newtag -> (r -> r) -> Rename oldtag m a -> Rename oldtag m a Source #

reader_ :: Proxy# newtag -> (r -> a) -> Rename oldtag m a Source #

HasState oldtag s m => HasState (newtag :: k2) s (Rename oldtag m) Source #

Rename the tag.

Instance details

Defined in Capability.State.Internal.Strategies

Methods

state_ :: Proxy# newtag -> (s -> (a, s)) -> Rename oldtag m a Source #

HasCatch oldtag e m => HasCatch (newtag :: k2) e (Rename oldtag m) Source #

Rename the tag.

Apply cautiously. E.g. the following code produces colliding instances, where exceptions thrown in "Foo" cannot be distinguished from exceptions thrown in "Bar" and vice-versa.

newtype Bad a = Bad (IO a)
  deriving (Functor, Applicative, Monad)
  deriving
    ( HasThrow "Foo" m
    , HasCatch "Foo" m
    ) via Rename () (MonadUnliftIO SomeError IO)
  deriving
    ( HasThrow "Bar" m
    , HasCatch "Bar" m
    ) via Rename () (MonadUnliftIO SomeError IO)
Instance details

Defined in Capability.Error

Methods

catch_ :: Proxy# newtag -> Rename oldtag m a -> (e -> Rename oldtag m a) -> Rename oldtag m a Source #

catchJust_ :: Proxy# newtag -> (e -> Maybe b) -> Rename oldtag m a -> (b -> Rename oldtag m a) -> Rename oldtag m a Source #

HasThrow oldtag e m => HasThrow (newtag :: k2) e (Rename oldtag m) Source #

Rename the tag.

Apply cautiously. See HasCatch newtag e (Rename oldtag m).

Instance details

Defined in Capability.Error

Methods

throw_ :: Proxy# newtag -> e -> Rename oldtag m a Source #

Monad m => Monad (Rename oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

(>>=) :: Rename oldtag m a -> (a -> Rename oldtag m b) -> Rename oldtag m b #

(>>) :: Rename oldtag m a -> Rename oldtag m b -> Rename oldtag m b #

return :: a -> Rename oldtag m a #

Functor m => Functor (Rename oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

fmap :: (a -> b) -> Rename oldtag m a -> Rename oldtag m b #

(<$) :: a -> Rename oldtag m b -> Rename oldtag m a #

Applicative m => Applicative (Rename oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

pure :: a -> Rename oldtag m a #

(<*>) :: Rename oldtag m (a -> b) -> Rename oldtag m a -> Rename oldtag m b #

liftA2 :: (a -> b -> c) -> Rename oldtag m a -> Rename oldtag m b -> Rename oldtag m c #

(*>) :: Rename oldtag m a -> Rename oldtag m b -> Rename oldtag m b #

(<*) :: Rename oldtag m a -> Rename oldtag m b -> Rename oldtag m a #

MonadIO m => MonadIO (Rename oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

liftIO :: IO a -> Rename oldtag m a #

PrimMonad m => PrimMonad (Rename oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Associated Types

type PrimState (Rename oldtag m) #

Methods

primitive :: (State# (PrimState (Rename oldtag m)) -> (# State# (PrimState (Rename oldtag m)), a #)) -> Rename oldtag m a #

type PrimState (Rename oldtag m) Source # 
Instance details

Defined in Capability.Accessors

type PrimState (Rename oldtag m) = PrimState m

newtype Field (field :: Symbol) (oldtag :: k) m (a :: Type) Source #

Access the record field field in the context m.

Example:

data Foo = Foo { foo :: Int }
newtype MyReader a = MyReader (Reader Foo a)
  deriving (HasReader "foo" Int) via
    Field "foo" () (MonadReader (Reader Foo))

Converts the HasReader () Foo instance of MonadReader (Reader Foo) to a HasReader "foo" Int instance by focusing on the field foo in the Foo record.

See Rename for a way to change the tag.

Constructors

Field (m a) 

Instances

Instances details
(tag ~ field, HasField' field record v, HasState oldtag record m) => HasSink (tag :: Symbol) v (Field field oldtag m) Source #

Zoom in on the record field field of type v in the state record.

Instance details

Defined in Capability.Sink.Internal.Strategies

Methods

yield_ :: Proxy# tag -> v -> Field field oldtag m () Source #

(tag ~ field, HasField' field record v, HasSource oldtag record m) => HasSource (tag :: Symbol) v (Field field oldtag m) Source # 
Instance details

Defined in Capability.Source.Internal.Strategies

Methods

await_ :: Proxy# tag -> Field field oldtag m v Source #

(tag ~ field, HasField' field record v, HasReader oldtag record m) => HasReader (tag :: Symbol) v (Field field oldtag m) Source #

Zoom in on the record field field of type v in the environment record.

Instance details

Defined in Capability.Reader.Internal.Strategies

Methods

local_ :: Proxy# tag -> (v -> v) -> Field field oldtag m a -> Field field oldtag m a Source #

reader_ :: Proxy# tag -> (v -> a) -> Field field oldtag m a Source #

(tag ~ field, HasField' field record v, HasState oldtag record m) => HasState (tag :: Symbol) v (Field field oldtag m) Source #

Zoom in on the record field field of type v in the state record.

Instance details

Defined in Capability.State.Internal.Strategies

Methods

state_ :: Proxy# tag -> (v -> (a, v)) -> Field field oldtag m a Source #

Monad m => Monad (Field field oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

(>>=) :: Field field oldtag m a -> (a -> Field field oldtag m b) -> Field field oldtag m b #

(>>) :: Field field oldtag m a -> Field field oldtag m b -> Field field oldtag m b #

return :: a -> Field field oldtag m a #

Functor m => Functor (Field field oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

fmap :: (a -> b) -> Field field oldtag m a -> Field field oldtag m b #

(<$) :: a -> Field field oldtag m b -> Field field oldtag m a #

Applicative m => Applicative (Field field oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

pure :: a -> Field field oldtag m a #

(<*>) :: Field field oldtag m (a -> b) -> Field field oldtag m a -> Field field oldtag m b #

liftA2 :: (a -> b -> c) -> Field field oldtag m a -> Field field oldtag m b -> Field field oldtag m c #

(*>) :: Field field oldtag m a -> Field field oldtag m b -> Field field oldtag m b #

(<*) :: Field field oldtag m a -> Field field oldtag m b -> Field field oldtag m a #

MonadIO m => MonadIO (Field field oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

liftIO :: IO a -> Field field oldtag m a #

PrimMonad m => PrimMonad (Field field oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Associated Types

type PrimState (Field field oldtag m) #

Methods

primitive :: (State# (PrimState (Field field oldtag m)) -> (# State# (PrimState (Field field oldtag m)), a #)) -> Field field oldtag m a #

type PrimState (Field field oldtag m) Source # 
Instance details

Defined in Capability.Accessors

type PrimState (Field field oldtag m) = PrimState m

newtype Pos (pos :: Nat) (oldtag :: k) m (a :: Type) Source #

Access the value at position pos in the context m.

Example:

newtype MyReader a = MyReader (Reader (Int, Bool) a)
  deriving (HasReader 1 Int) via
    Pos 1 () (MonadReader (Reader (Int, Bool)))

Converts the HasReader () (Int, Bool) instance of MonadReader (Reader (Int, Bool)) to a HasReader 1 Int instance by focusing on the first element of the tuple.

The implied number tag can be renamed to a more descriptive name using the Rename combinator:

newtype MyReader a = MyReader (Reader (Int, Bool) a)
  deriving (HasReader "foo" Int) via
    Rename 1 (Pos 1 () (MonadReader (Reader (Int, Bool))))

Constructors

Pos (m a) 

Instances

Instances details
(tag ~ pos, HasPosition' pos struct v, HasState oldtag struct m) => HasSink (tag :: Nat) v (Pos pos oldtag m) Source #

Zoom in on the field at position pos of type v in the state struct.

Instance details

Defined in Capability.Sink.Internal.Strategies

Methods

yield_ :: Proxy# tag -> v -> Pos pos oldtag m () Source #

(tag ~ pos, HasPosition' pos struct v, HasSource oldtag struct m) => HasSource (tag :: Nat) v (Pos pos oldtag m) Source # 
Instance details

Defined in Capability.Source.Internal.Strategies

Methods

await_ :: Proxy# tag -> Pos pos oldtag m v Source #

(tag ~ pos, HasPosition' pos struct v, HasReader oldtag struct m) => HasReader (tag :: Nat) v (Pos pos oldtag m) Source #

Zoom in on the field at position pos of type v in the environment struct.

Instance details

Defined in Capability.Reader.Internal.Strategies

Methods

local_ :: Proxy# tag -> (v -> v) -> Pos pos oldtag m a -> Pos pos oldtag m a Source #

reader_ :: Proxy# tag -> (v -> a) -> Pos pos oldtag m a Source #

(tag ~ pos, HasPosition' pos struct v, HasState oldtag struct m) => HasState (tag :: Nat) v (Pos pos oldtag m) Source #

Zoom in on the field at position pos of type v in the state struct.

Instance details

Defined in Capability.State.Internal.Strategies

Methods

state_ :: Proxy# tag -> (v -> (a, v)) -> Pos pos oldtag m a Source #

Monad m => Monad (Pos pos oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

(>>=) :: Pos pos oldtag m a -> (a -> Pos pos oldtag m b) -> Pos pos oldtag m b #

(>>) :: Pos pos oldtag m a -> Pos pos oldtag m b -> Pos pos oldtag m b #

return :: a -> Pos pos oldtag m a #

Functor m => Functor (Pos pos oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

fmap :: (a -> b) -> Pos pos oldtag m a -> Pos pos oldtag m b #

(<$) :: a -> Pos pos oldtag m b -> Pos pos oldtag m a #

Applicative m => Applicative (Pos pos oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

pure :: a -> Pos pos oldtag m a #

(<*>) :: Pos pos oldtag m (a -> b) -> Pos pos oldtag m a -> Pos pos oldtag m b #

liftA2 :: (a -> b -> c) -> Pos pos oldtag m a -> Pos pos oldtag m b -> Pos pos oldtag m c #

(*>) :: Pos pos oldtag m a -> Pos pos oldtag m b -> Pos pos oldtag m b #

(<*) :: Pos pos oldtag m a -> Pos pos oldtag m b -> Pos pos oldtag m a #

MonadIO m => MonadIO (Pos pos oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

liftIO :: IO a -> Pos pos oldtag m a #

PrimMonad m => PrimMonad (Pos pos oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Associated Types

type PrimState (Pos pos oldtag m) #

Methods

primitive :: (State# (PrimState (Pos pos oldtag m)) -> (# State# (PrimState (Pos pos oldtag m)), a #)) -> Pos pos oldtag m a #

type PrimState (Pos pos oldtag m) Source # 
Instance details

Defined in Capability.Accessors

type PrimState (Pos pos oldtag m) = PrimState m

newtype Ctor (ctor :: Symbol) (oldtag :: k) m (a :: Type) Source #

Choose the given constructor in the sum-type in context m.

Example:

data MyError = ErrA String | ErrB String
newtype MyExcept a = MyExcept (ExceptT MyError Identity a)
  deriving (HasThrow "ErrB" String) via
    Ctor "ErrB" () (MonadError (ExceptT MyError Identity))

Converts the HasThrow () "MyError" instance of MonadError (ExceptT MyError Identity) to a HasThrow "ErrB" String instance by wrapping thrown Strings in the ErrB constructor.

Constructors

Ctor (m a) 

Instances

Instances details
(AsConstructor' ctor sum e, HasCatch oldtag sum m) => HasCatch (ctor :: Symbol) e (Ctor ctor oldtag m) Source #

Catch an exception of type sum if its constructor matches ctor.

Instance details

Defined in Capability.Error

Methods

catch_ :: Proxy# ctor -> Ctor ctor oldtag m a -> (e -> Ctor ctor oldtag m a) -> Ctor ctor oldtag m a Source #

catchJust_ :: Proxy# ctor -> (e -> Maybe b) -> Ctor ctor oldtag m a -> (b -> Ctor ctor oldtag m a) -> Ctor ctor oldtag m a Source #

(AsConstructor' ctor sum e, HasThrow oldtag sum m) => HasThrow (ctor :: Symbol) e (Ctor ctor oldtag m) Source #

Wrap the exception e with the constructor ctor to throw an exception of type sum.

Instance details

Defined in Capability.Error

Methods

throw_ :: Proxy# ctor -> e -> Ctor ctor oldtag m a Source #

Monad m => Monad (Ctor ctor oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

(>>=) :: Ctor ctor oldtag m a -> (a -> Ctor ctor oldtag m b) -> Ctor ctor oldtag m b #

(>>) :: Ctor ctor oldtag m a -> Ctor ctor oldtag m b -> Ctor ctor oldtag m b #

return :: a -> Ctor ctor oldtag m a #

Functor m => Functor (Ctor ctor oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

fmap :: (a -> b) -> Ctor ctor oldtag m a -> Ctor ctor oldtag m b #

(<$) :: a -> Ctor ctor oldtag m b -> Ctor ctor oldtag m a #

Applicative m => Applicative (Ctor ctor oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

pure :: a -> Ctor ctor oldtag m a #

(<*>) :: Ctor ctor oldtag m (a -> b) -> Ctor ctor oldtag m a -> Ctor ctor oldtag m b #

liftA2 :: (a -> b -> c) -> Ctor ctor oldtag m a -> Ctor ctor oldtag m b -> Ctor ctor oldtag m c #

(*>) :: Ctor ctor oldtag m a -> Ctor ctor oldtag m b -> Ctor ctor oldtag m b #

(<*) :: Ctor ctor oldtag m a -> Ctor ctor oldtag m b -> Ctor ctor oldtag m a #

MonadIO m => MonadIO (Ctor ctor oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Methods

liftIO :: IO a -> Ctor ctor oldtag m a #

PrimMonad m => PrimMonad (Ctor ctor oldtag m) Source # 
Instance details

Defined in Capability.Accessors

Associated Types

type PrimState (Ctor ctor oldtag m) #

Methods

primitive :: (State# (PrimState (Ctor ctor oldtag m)) -> (# State# (PrimState (Ctor ctor oldtag m)), a #)) -> Ctor ctor oldtag m a #

type PrimState (Ctor ctor oldtag m) Source # 
Instance details

Defined in Capability.Accessors

type PrimState (Ctor ctor oldtag m) = PrimState m

newtype Lift m (a :: Type) Source #

Skip one level in a monad transformer stack.

Note, that instances generated with this strategy can incur a performance penalty.

Example:

newtype MyStates a = MyStates (StateT Int (State Bool) a)
  deriving (HasState "foo" Bool) via
    Lift (StateT Int (MonadState (State Bool)))

Uses the MonadTrans instance of StateT Int to lift the HasState "foo" Bool instance of the underlying MonadState (State Bool) over the StateT Int monad transformer.

Constructors

Lift (m a) 

Instances

Instances details
(HasSink tag a m, MonadTrans t, Monad (t m)) => HasSink (tag :: k) a (Lift (t m)) Source #

Lift one layer in a monad transformer stack.

Note, that if the HasSink instance is based on HasState, then it is more efficient to apply Lift to the underlying state capability. E.g. you should favour

deriving (HasSink tag w) via
  SinkLog (Lift (SomeTrans (MonadState SomeStateMonad)))

over

deriving (HasSink tag w) via
  Lift (SomeTrans (SinkLog (MonadState SomeStateMonad)))
Instance details

Defined in Capability.Sink.Internal.Strategies

Methods

yield_ :: Proxy# tag -> a -> Lift (t m) () Source #

(HasSource tag r m, MonadTrans t, Monad (t m)) => HasSource (tag :: k) r (Lift (t m)) Source # 
Instance details

Defined in Capability.Source.Internal.Strategies

Methods

await_ :: Proxy# tag -> Lift (t m) r Source #

(HasReader tag r m, MonadTransControl t, Monad (t m)) => HasReader (tag :: k) r (Lift (t m)) Source #

Lift one layer in a monad transformer stack.

Instance details

Defined in Capability.Reader.Internal.Strategies

Methods

local_ :: Proxy# tag -> (r -> r) -> Lift (t m) a -> Lift (t m) a Source #

reader_ :: Proxy# tag -> (r -> a) -> Lift (t m) a Source #

(HasState tag s m, MonadTrans t, Monad (t m)) => HasState (tag :: k) s (Lift (t m)) Source #

Lift one layer in a monad transformer stack.

Instance details

Defined in Capability.State.Internal.Strategies

Methods

state_ :: Proxy# tag -> (s -> (a, s)) -> Lift (t m) a Source #

(HasCatch tag e m, MonadTransControl t, Monad (t m)) => HasCatch (tag :: k) e (Lift (t m)) Source #

Lift one layer in a monad transformer stack.

Instance details

Defined in Capability.Error

Methods

catch_ :: Proxy# tag -> Lift (t m) a -> (e -> Lift (t m) a) -> Lift (t m) a Source #

catchJust_ :: Proxy# tag -> (e -> Maybe b) -> Lift (t m) a -> (b -> Lift (t m) a) -> Lift (t m) a Source #

(HasThrow tag e m, MonadTrans t, Monad (t m)) => HasThrow (tag :: k) e (Lift (t m)) Source #

Lift one layer in a monad transformer stack.

Instance details

Defined in Capability.Error

Methods

throw_ :: Proxy# tag -> e -> Lift (t m) a Source #

Monad m => Monad (Lift m) Source # 
Instance details

Defined in Capability.Accessors

Methods

(>>=) :: Lift m a -> (a -> Lift m b) -> Lift m b #

(>>) :: Lift m a -> Lift m b -> Lift m b #

return :: a -> Lift m a #

Functor m => Functor (Lift m) Source # 
Instance details

Defined in Capability.Accessors

Methods

fmap :: (a -> b) -> Lift m a -> Lift m b #

(<$) :: a -> Lift m b -> Lift m a #

Applicative m => Applicative (Lift m) Source # 
Instance details

Defined in Capability.Accessors

Methods

pure :: a -> Lift m a #

(<*>) :: Lift m (a -> b) -> Lift m a -> Lift m b #

liftA2 :: (a -> b -> c) -> Lift m a -> Lift m b -> Lift m c #

(*>) :: Lift m a -> Lift m b -> Lift m b #

(<*) :: Lift m a -> Lift m b -> Lift m a #

MonadIO m => MonadIO (Lift m) Source # 
Instance details

Defined in Capability.Accessors

Methods

liftIO :: IO a -> Lift m a #

PrimMonad m => PrimMonad (Lift m) Source # 
Instance details

Defined in Capability.Accessors

Associated Types

type PrimState (Lift m) #

Methods

primitive :: (State# (PrimState (Lift m)) -> (# State# (PrimState (Lift m)), a #)) -> Lift m a #

(HasWriter tag w m, MonadTransUnlift t, Monad (t m)) => HasWriter (tag :: Type) w (Lift (t m)) Source #

Lift one layer in a monad transformer stack.

Note, that if the HasWriter instance is based on HasState, then it is more efficient to apply Lift to the underlying state capability. E.g. you should favour

deriving (HasWriter tag w) via
  WriterLog (Lift (SomeTrans (MonadState SomeStateMonad)))

over

deriving (HasWriter tag w) via
  Lift (SomeTrans (WriterLog (MonadState SomeStateMonad)))
Instance details

Defined in Capability.Writer.Discouraged

Methods

writer_ :: Proxy# tag -> (a, w) -> Lift (t m) a Source #

listen_ :: Proxy# tag -> Lift (t m) a -> Lift (t m) (a, w) Source #

pass_ :: Proxy# tag -> Lift (t m) (a, w -> w) -> Lift (t m) a Source #

type PrimState (Lift m) Source # 
Instance details

Defined in Capability.Accessors

type PrimState (Lift m) = PrimState m

newtype ((t2 :: (Type -> Type) -> Type -> Type) :.: (t1 :: (Type -> Type) -> Type -> Type)) (m :: Type -> Type) (a :: Type) infixr 9 Source #

Compose two accessors.

This is not necessary in deriving via clauses, but in places where a transformer is expected as a type argument. E.g. wrapError.

Constructors

(:.:) (m a) infixr 9 

Instances

Instances details
(forall x. Coercible (m x) (t2 (t1 m) x), Monad m, HasSink tag a (t2 (t1 m))) => HasSink (tag :: k) a ((t2 :.: t1) m) Source #

Compose two accessors.

Instance details

Defined in Capability.Sink.Internal.Strategies

Methods

yield_ :: Proxy# tag -> a -> (t2 :.: t1) m () Source #

(forall x. Coercible (m x) (t2 (t1 m) x), Monad m, HasSource tag r (t2 (t1 m))) => HasSource (tag :: k) r ((t2 :.: t1) m) Source # 
Instance details

Defined in Capability.Source.Internal.Strategies

Methods

await_ :: Proxy# tag -> (t2 :.: t1) m r Source #

(forall x. Coercible (m x) (t2 (t1 m) x), Monad m, HasReader tag r (t2 (t1 m))) => HasReader (tag :: k) r ((t2 :.: t1) m) Source #

Compose two accessors.

Instance details

Defined in Capability.Reader.Internal.Strategies

Methods

local_ :: Proxy# tag -> (r -> r) -> (t2 :.: t1) m a -> (t2 :.: t1) m a Source #

reader_ :: Proxy# tag -> (r -> a) -> (t2 :.: t1) m a Source #

(forall x. Coercible (m x) (t2 (t1 m) x), Monad m, HasState tag s (t2 (t1 m))) => HasState (tag :: k) s ((t2 :.: t1) m) Source #

Compose two accessors.

Instance details

Defined in Capability.State.Internal.Strategies

Methods

state_ :: Proxy# tag -> (s -> (a, s)) -> (t2 :.: t1) m a Source #

(forall x. Coercible (m x) (t2 (t1 m) x), Monad m, HasCatch tag e (t2 (t1 m))) => HasCatch (tag :: k) e ((t2 :.: t1) m) Source #

Compose two accessors.

Instance details

Defined in Capability.Error

Methods

catch_ :: Proxy# tag -> (t2 :.: t1) m a -> (e -> (t2 :.: t1) m a) -> (t2 :.: t1) m a Source #

catchJust_ :: Proxy# tag -> (e -> Maybe b) -> (t2 :.: t1) m a -> (b -> (t2 :.: t1) m a) -> (t2 :.: t1) m a Source #

(forall x. Coercible (m x) (t2 (t1 m) x), Monad m, HasThrow tag e (t2 (t1 m))) => HasThrow (tag :: k) e ((t2 :.: t1) m) Source #

Compose two accessors.

Instance details

Defined in Capability.Error

Methods

throw_ :: Proxy# tag -> e -> (t2 :.: t1) m a Source #

(forall x. Coercible (m x) (t2 (t1 m) x), Monad m, HasWriter tag w (t2 (t1 m))) => HasWriter (tag :: k) w ((t2 :.: t1) m) Source #

Compose two accessors.

Instance details

Defined in Capability.Writer

Methods

writer_ :: Proxy# tag -> (a, w) -> (t2 :.: t1) m a Source #

listen_ :: Proxy# tag -> (t2 :.: t1) m a -> (t2 :.: t1) m (a, w) Source #

pass_ :: Proxy# tag -> (t2 :.: t1) m (a, w -> w) -> (t2 :.: t1) m a Source #

Monad m => Monad ((t2 :.: t1) m) Source # 
Instance details

Defined in Capability.Accessors

Methods

(>>=) :: (t2 :.: t1) m a -> (a -> (t2 :.: t1) m b) -> (t2 :.: t1) m b #

(>>) :: (t2 :.: t1) m a -> (t2 :.: t1) m b -> (t2 :.: t1) m b #

return :: a -> (t2 :.: t1) m a #

Functor m => Functor ((t2 :.: t1) m) Source # 
Instance details

Defined in Capability.Accessors

Methods

fmap :: (a -> b) -> (t2 :.: t1) m a -> (t2 :.: t1) m b #

(<$) :: a -> (t2 :.: t1) m b -> (t2 :.: t1) m a #

Applicative m => Applicative ((t2 :.: t1) m) Source # 
Instance details

Defined in Capability.Accessors

Methods

pure :: a -> (t2 :.: t1) m a #

(<*>) :: (t2 :.: t1) m (a -> b) -> (t2 :.: t1) m a -> (t2 :.: t1) m b #

liftA2 :: (a -> b -> c) -> (t2 :.: t1) m a -> (t2 :.: t1) m b -> (t2 :.: t1) m c #

(*>) :: (t2 :.: t1) m a -> (t2 :.: t1) m b -> (t2 :.: t1) m b #

(<*) :: (t2 :.: t1) m a -> (t2 :.: t1) m b -> (t2 :.: t1) m a #

MonadIO m => MonadIO ((t2 :.: t1) m) Source # 
Instance details

Defined in Capability.Accessors

Methods

liftIO :: IO a -> (t2 :.: t1) m a #

PrimMonad m => PrimMonad ((t2 :.: t1) m) Source # 
Instance details

Defined in Capability.Accessors

Associated Types

type PrimState ((t2 :.: t1) m) #

Methods

primitive :: (State# (PrimState ((t2 :.: t1) m)) -> (# State# (PrimState ((t2 :.: t1) m)), a #)) -> (t2 :.: t1) m a #

type PrimState ((t2 :.: t1) m) Source # 
Instance details

Defined in Capability.Accessors

type PrimState ((t2 :.: t1) m) = PrimState m