{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Control.Effect.Labelled
( runLabelled
, Labelled(Labelled)
, LabelledMember(..)
, HasLabelled
, sendLabelled
, runUnderLabel
, UnderLabel(UnderLabel)
, module Control.Algebra
) where
import Control.Algebra
import Control.Applicative (Alternative)
import Control.Effect.Sum (reassociateSumL)
import Control.Monad (MonadPlus)
import Control.Monad.Fail as Fail
import Control.Monad.Fix
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Data.Functor.Identity
import Data.Kind (Type)
newtype Labelled (label :: k) (sub :: (Type -> Type) -> (Type -> Type)) m a = Labelled (sub m a)
deriving
( Applicative (Labelled label sub m)
Applicative (Labelled label sub m) =>
(forall a. Labelled label sub m a)
-> (forall a.
Labelled label sub m a
-> Labelled label sub m a -> Labelled label sub m a)
-> (forall a. Labelled label sub m a -> Labelled label sub m [a])
-> (forall a. Labelled label sub m a -> Labelled label sub m [a])
-> Alternative (Labelled label sub m)
forall a. Labelled label sub m a
forall a. Labelled label sub m a -> Labelled label sub m [a]
forall a.
Labelled label sub m a
-> Labelled label sub m a -> Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
Alternative (sub m) =>
Applicative (Labelled label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative (sub m) =>
Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative (sub m) =>
Labelled label sub m a -> Labelled label sub m [a]
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative (sub m) =>
Labelled label sub m a
-> Labelled label sub m a -> Labelled label sub m a
forall (f :: * -> *).
Applicative f =>
(forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
$cempty :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative (sub m) =>
Labelled label sub m a
empty :: forall a. Labelled label sub m a
$c<|> :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative (sub m) =>
Labelled label sub m a
-> Labelled label sub m a -> Labelled label sub m a
<|> :: forall a.
Labelled label sub m a
-> Labelled label sub m a -> Labelled label sub m a
$csome :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative (sub m) =>
Labelled label sub m a -> Labelled label sub m [a]
some :: forall a. Labelled label sub m a -> Labelled label sub m [a]
$cmany :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative (sub m) =>
Labelled label sub m a -> Labelled label sub m [a]
many :: forall a. Labelled label sub m a -> Labelled label sub m [a]
Alternative
, Functor (Labelled label sub m)
Functor (Labelled label sub m) =>
(forall a. a -> Labelled label sub m a)
-> (forall a b.
Labelled label sub m (a -> b)
-> Labelled label sub m a -> Labelled label sub m b)
-> (forall a b c.
(a -> b -> c)
-> Labelled label sub m a
-> Labelled label sub m b
-> Labelled label sub m c)
-> (forall a b.
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m b)
-> (forall a b.
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m a)
-> Applicative (Labelled label sub m)
forall a. a -> Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
Applicative (sub m) =>
Functor (Labelled label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Applicative (sub m) =>
a -> Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative (sub m) =>
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative (sub m) =>
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m b
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative (sub m) =>
Labelled label sub m (a -> b)
-> Labelled label sub m a -> Labelled label sub m b
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a b
c.
Applicative (sub m) =>
(a -> b -> c)
-> Labelled label sub m a
-> Labelled label sub m b
-> Labelled label sub m c
forall a b.
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m a
forall a b.
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m b
forall a b.
Labelled label sub m (a -> b)
-> Labelled label sub m a -> Labelled label sub m b
forall a b c.
(a -> b -> c)
-> Labelled label sub m a
-> Labelled label sub m b
-> Labelled label sub m c
forall (f :: * -> *).
Functor f =>
(forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
$cpure :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Applicative (sub m) =>
a -> Labelled label sub m a
pure :: forall a. a -> Labelled label sub m a
$c<*> :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative (sub m) =>
Labelled label sub m (a -> b)
-> Labelled label sub m a -> Labelled label sub m b
<*> :: forall a b.
Labelled label sub m (a -> b)
-> Labelled label sub m a -> Labelled label sub m b
$cliftA2 :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a b
c.
Applicative (sub m) =>
(a -> b -> c)
-> Labelled label sub m a
-> Labelled label sub m b
-> Labelled label sub m c
liftA2 :: forall a b c.
(a -> b -> c)
-> Labelled label sub m a
-> Labelled label sub m b
-> Labelled label sub m c
$c*> :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative (sub m) =>
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m b
*> :: forall a b.
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m b
$c<* :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative (sub m) =>
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m a
<* :: forall a b.
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m a
Applicative
, (forall a b.
(a -> b) -> Labelled label sub m a -> Labelled label sub m b)
-> (forall a b.
a -> Labelled label sub m b -> Labelled label sub m a)
-> Functor (Labelled label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Functor (sub m) =>
a -> Labelled label sub m b -> Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Functor (sub m) =>
(a -> b) -> Labelled label sub m a -> Labelled label sub m b
forall a b. a -> Labelled label sub m b -> Labelled label sub m a
forall a b.
(a -> b) -> Labelled label sub m a -> Labelled label sub m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Functor (sub m) =>
(a -> b) -> Labelled label sub m a -> Labelled label sub m b
fmap :: forall a b.
(a -> b) -> Labelled label sub m a -> Labelled label sub m b
$c<$ :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Functor (sub m) =>
a -> Labelled label sub m b -> Labelled label sub m a
<$ :: forall a b. a -> Labelled label sub m b -> Labelled label sub m a
Functor
, Applicative (Labelled label sub m)
Applicative (Labelled label sub m) =>
(forall a b.
Labelled label sub m a
-> (a -> Labelled label sub m b) -> Labelled label sub m b)
-> (forall a b.
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m b)
-> (forall a. a -> Labelled label sub m a)
-> Monad (Labelled label sub m)
forall a. a -> Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
Monad (sub m) =>
Applicative (Labelled label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Monad (sub m) =>
a -> Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Monad (sub m) =>
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m b
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Monad (sub m) =>
Labelled label sub m a
-> (a -> Labelled label sub m b) -> Labelled label sub m b
forall a b.
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m b
forall a b.
Labelled label sub m a
-> (a -> Labelled label sub m b) -> Labelled label sub m b
forall (m :: * -> *).
Applicative m =>
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
$c>>= :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Monad (sub m) =>
Labelled label sub m a
-> (a -> Labelled label sub m b) -> Labelled label sub m b
>>= :: forall a b.
Labelled label sub m a
-> (a -> Labelled label sub m b) -> Labelled label sub m b
$c>> :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Monad (sub m) =>
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m b
>> :: forall a b.
Labelled label sub m a
-> Labelled label sub m b -> Labelled label sub m b
$creturn :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Monad (sub m) =>
a -> Labelled label sub m a
return :: forall a. a -> Labelled label sub m a
Monad
, Monad (Labelled label sub m)
Monad (Labelled label sub m) =>
(forall a. String -> Labelled label sub m a)
-> MonadFail (Labelled label sub m)
forall a. String -> Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
MonadFail (sub m) =>
Monad (Labelled label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadFail (sub m) =>
String -> Labelled label sub m a
forall (m :: * -> *).
Monad m =>
(forall a. String -> m a) -> MonadFail m
$cfail :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadFail (sub m) =>
String -> Labelled label sub m a
fail :: forall a. String -> Labelled label sub m a
Fail.MonadFail
, Monad (Labelled label sub m)
Monad (Labelled label sub m) =>
(forall a. (a -> Labelled label sub m a) -> Labelled label sub m a)
-> MonadFix (Labelled label sub m)
forall a. (a -> Labelled label sub m a) -> Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
MonadFix (sub m) =>
Monad (Labelled label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadFix (sub m) =>
(a -> Labelled label sub m a) -> Labelled label sub m a
forall (m :: * -> *).
Monad m =>
(forall a. (a -> m a) -> m a) -> MonadFix m
$cmfix :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadFix (sub m) =>
(a -> Labelled label sub m a) -> Labelled label sub m a
mfix :: forall a. (a -> Labelled label sub m a) -> Labelled label sub m a
MonadFix
, Monad (Labelled label sub m)
Monad (Labelled label sub m) =>
(forall a. IO a -> Labelled label sub m a)
-> MonadIO (Labelled label sub m)
forall a. IO a -> Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
MonadIO (sub m) =>
Monad (Labelled label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadIO (sub m) =>
IO a -> Labelled label sub m a
forall (m :: * -> *).
Monad m =>
(forall a. IO a -> m a) -> MonadIO m
$cliftIO :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadIO (sub m) =>
IO a -> Labelled label sub m a
liftIO :: forall a. IO a -> Labelled label sub m a
MonadIO
, Monad (Labelled label sub m)
Alternative (Labelled label sub m)
(Alternative (Labelled label sub m),
Monad (Labelled label sub m)) =>
(forall a. Labelled label sub m a)
-> (forall a.
Labelled label sub m a
-> Labelled label sub m a -> Labelled label sub m a)
-> MonadPlus (Labelled label sub m)
forall a. Labelled label sub m a
forall a.
Labelled label sub m a
-> Labelled label sub m a -> Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
MonadPlus (sub m) =>
Monad (Labelled label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
MonadPlus (sub m) =>
Alternative (Labelled label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadPlus (sub m) =>
Labelled label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadPlus (sub m) =>
Labelled label sub m a
-> Labelled label sub m a -> Labelled label sub m a
forall (m :: * -> *).
(Alternative m, Monad m) =>
(forall a. m a) -> (forall a. m a -> m a -> m a) -> MonadPlus m
$cmzero :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadPlus (sub m) =>
Labelled label sub m a
mzero :: forall a. Labelled label sub m a
$cmplus :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadPlus (sub m) =>
Labelled label sub m a
-> Labelled label sub m a -> Labelled label sub m a
mplus :: forall a.
Labelled label sub m a
-> Labelled label sub m a -> Labelled label sub m a
MonadPlus
, (forall (m :: * -> *). Monad m => Monad (Labelled label sub m)) =>
(forall (m :: * -> *) a. Monad m => m a -> Labelled label sub m a)
-> MonadTrans (Labelled label sub)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
(MonadTrans sub, Monad m) =>
Monad (Labelled label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans sub, Monad m) =>
m a -> Labelled label sub m a
forall (m :: * -> *). Monad m => Monad (Labelled label sub m)
forall (m :: * -> *) a. Monad m => m a -> Labelled label sub m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *). Monad m => Monad (t m)) =>
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
$clift :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans sub, Monad m) =>
m a -> Labelled label sub m a
lift :: forall (m :: * -> *) a. Monad m => m a -> Labelled label sub m a
MonadTrans
)
runLabelled :: forall label sub m a . Labelled label sub m a -> sub m a
runLabelled :: forall {k} (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *)
a.
Labelled label sub m a -> sub m a
runLabelled (Labelled sub m a
l) = sub m a
l
{-# INLINE runLabelled #-}
instance Algebra (eff :+: sig) (sub m) => Algebra (Labelled label eff :+: sig) (Labelled label sub m) where
alg :: forall (ctx :: * -> *) (n :: * -> *) a.
Functor ctx =>
Handler ctx n (Labelled label sub m)
-> (:+:) (Labelled label eff) sig n a
-> ctx ()
-> Labelled label sub m (ctx a)
alg Handler ctx n (Labelled label sub m)
hdl = \case
L Labelled label eff n a
eff -> sub m (ctx a) -> Labelled label sub m (ctx a)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
sub m a -> Labelled label sub m a
Labelled (sub m (ctx a) -> Labelled label sub m (ctx a))
-> (ctx () -> sub m (ctx a))
-> ctx ()
-> Labelled label sub m (ctx a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handler ctx n (sub m)
-> (:+:) eff sig n a -> ctx () -> sub m (ctx a)
forall (ctx :: * -> *) (n :: * -> *) a.
Functor ctx =>
Handler ctx n (sub m)
-> (:+:) eff sig n a -> ctx () -> sub m (ctx a)
forall (sig :: (* -> *) -> * -> *) (m :: * -> *) (ctx :: * -> *)
(n :: * -> *) a.
(Algebra sig m, Functor ctx) =>
Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
alg (Labelled label sub m (ctx x) -> sub m (ctx x)
forall {k} (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *)
a.
Labelled label sub m a -> sub m a
runLabelled (Labelled label sub m (ctx x) -> sub m (ctx x))
-> (ctx (n x) -> Labelled label sub m (ctx x))
-> ctx (n x)
-> sub m (ctx x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ctx (n x) -> Labelled label sub m (ctx x)
Handler ctx n (Labelled label sub m)
hdl) (eff n a -> (:+:) eff sig n a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
f m k -> (:+:) f g m k
L (Labelled label eff n a -> eff n a
forall {k} (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *)
a.
Labelled label sub m a -> sub m a
runLabelled Labelled label eff n a
eff))
R sig n a
sig -> sub m (ctx a) -> Labelled label sub m (ctx a)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
sub m a -> Labelled label sub m a
Labelled (sub m (ctx a) -> Labelled label sub m (ctx a))
-> (ctx () -> sub m (ctx a))
-> ctx ()
-> Labelled label sub m (ctx a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handler ctx n (sub m)
-> (:+:) eff sig n a -> ctx () -> sub m (ctx a)
forall (ctx :: * -> *) (n :: * -> *) a.
Functor ctx =>
Handler ctx n (sub m)
-> (:+:) eff sig n a -> ctx () -> sub m (ctx a)
forall (sig :: (* -> *) -> * -> *) (m :: * -> *) (ctx :: * -> *)
(n :: * -> *) a.
(Algebra sig m, Functor ctx) =>
Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
alg (Labelled label sub m (ctx x) -> sub m (ctx x)
forall {k} (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *)
a.
Labelled label sub m a -> sub m a
runLabelled (Labelled label sub m (ctx x) -> sub m (ctx x))
-> (ctx (n x) -> Labelled label sub m (ctx x))
-> ctx (n x)
-> sub m (ctx x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ctx (n x) -> Labelled label sub m (ctx x)
Handler ctx n (Labelled label sub m)
hdl) (sig n a -> (:+:) eff sig n a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
g m k -> (:+:) f g m k
R sig n a
sig)
{-# INLINE alg #-}
class LabelledMember label (sub :: (Type -> Type) -> (Type -> Type)) sup | label sup -> sub where
injLabelled :: Labelled label sub m a -> sup m a
instance LabelledMember label t (Labelled label t) where
injLabelled :: forall (m :: * -> *) a.
Labelled label t m a -> Labelled label t m a
injLabelled = Labelled label t m a -> Labelled label t m a
forall a. a -> a
id
{-# INLINE injLabelled #-}
instance {-# OVERLAPPABLE #-}
LabelledMember label t (l1 :+: l2 :+: r)
=> LabelledMember label t ((l1 :+: l2) :+: r) where
injLabelled :: forall (m :: * -> *) a.
Labelled label t m a -> (:+:) (l1 :+: l2) r m a
injLabelled = (:+:) l1 (l2 :+: r) m a -> (:+:) (l1 :+: l2) r m a
forall (l1 :: (* -> *) -> * -> *) (l2 :: (* -> *) -> * -> *)
(r :: (* -> *) -> * -> *) (m :: * -> *) a.
(:+:) l1 (l2 :+: r) m a -> (:+:) (l1 :+: l2) r m a
reassociateSumL ((:+:) l1 (l2 :+: r) m a -> (:+:) (l1 :+: l2) r m a)
-> (Labelled label t m a -> (:+:) l1 (l2 :+: r) m a)
-> Labelled label t m a
-> (:+:) (l1 :+: l2) r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Labelled label t m a -> (:+:) l1 (l2 :+: r) m a
forall {k} (label :: k) (sub :: (* -> *) -> * -> *)
(sup :: (* -> *) -> * -> *) (m :: * -> *) a.
LabelledMember label sub sup =>
Labelled label sub m a -> sup m a
forall (m :: * -> *) a.
Labelled label t m a -> (:+:) l1 (l2 :+: r) m a
injLabelled
{-# INLINE injLabelled #-}
instance {-# OVERLAPPABLE #-}
LabelledMember label l (Labelled label l :+: r) where
injLabelled :: forall (m :: * -> *) a.
Labelled label l m a -> (:+:) (Labelled label l) r m a
injLabelled = Labelled label l m a -> (:+:) (Labelled label l) r m a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
f m k -> (:+:) f g m k
L
{-# INLINE injLabelled #-}
instance {-# OVERLAPPABLE #-}
LabelledMember label l r
=> LabelledMember label l (l' :+: r) where
injLabelled :: forall (m :: * -> *) a. Labelled label l m a -> (:+:) l' r m a
injLabelled = r m a -> (:+:) l' r m a
forall (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *)
(m :: * -> *) k.
g m k -> (:+:) f g m k
R (r m a -> (:+:) l' r m a)
-> (Labelled label l m a -> r m a)
-> Labelled label l m a
-> (:+:) l' r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Labelled label l m a -> r m a
forall {k} (label :: k) (sub :: (* -> *) -> * -> *)
(sup :: (* -> *) -> * -> *) (m :: * -> *) a.
LabelledMember label sub sup =>
Labelled label sub m a -> sup m a
forall (m :: * -> *) a. Labelled label l m a -> r m a
injLabelled
{-# INLINE injLabelled #-}
type HasLabelled label eff sig m = (LabelledMember label eff sig, Algebra sig m)
sendLabelled :: forall label eff sig m a . HasLabelled label eff sig m => eff m a -> m a
sendLabelled :: forall {k} (label :: k) (eff :: (* -> *) -> * -> *)
(sig :: (* -> *) -> * -> *) (m :: * -> *) a.
HasLabelled label eff sig m =>
eff m a -> m a
sendLabelled eff m a
op = Identity a -> a
forall a. Identity a -> a
runIdentity (Identity a -> a) -> m (Identity a) -> m a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Handler Identity m m -> sig m a -> Identity () -> m (Identity a)
forall (ctx :: * -> *) (n :: * -> *) a.
Functor ctx =>
Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
forall (sig :: (* -> *) -> * -> *) (m :: * -> *) (ctx :: * -> *)
(n :: * -> *) a.
(Algebra sig m, Functor ctx) =>
Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
alg ((x -> Identity x) -> m x -> m (Identity x)
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap x -> Identity x
forall a. a -> Identity a
Identity (m x -> m (Identity x))
-> (Identity (m x) -> m x) -> Identity (m x) -> m (Identity x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identity (m x) -> m x
forall a. Identity a -> a
runIdentity) (forall (label :: k) (sub :: (* -> *) -> * -> *)
(sup :: (* -> *) -> * -> *) (m :: * -> *) a.
LabelledMember label sub sup =>
Labelled label sub m a -> sup m a
forall {k} (label :: k) (sub :: (* -> *) -> * -> *)
(sup :: (* -> *) -> * -> *) (m :: * -> *) a.
LabelledMember label sub sup =>
Labelled label sub m a -> sup m a
injLabelled @label (eff m a -> Labelled label eff m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
sub m a -> Labelled label sub m a
Labelled eff m a
op)) (() -> Identity ()
forall a. a -> Identity a
Identity ())
{-# INLINABLE sendLabelled #-}
newtype UnderLabel (label :: k) (sub :: (Type -> Type) -> (Type -> Type)) (m :: Type -> Type) a = UnderLabel (m a)
deriving
( Applicative (UnderLabel label sub m)
Applicative (UnderLabel label sub m) =>
(forall a. UnderLabel label sub m a)
-> (forall a.
UnderLabel label sub m a
-> UnderLabel label sub m a -> UnderLabel label sub m a)
-> (forall a.
UnderLabel label sub m a -> UnderLabel label sub m [a])
-> (forall a.
UnderLabel label sub m a -> UnderLabel label sub m [a])
-> Alternative (UnderLabel label sub m)
forall a. UnderLabel label sub m a
forall a. UnderLabel label sub m a -> UnderLabel label sub m [a]
forall a.
UnderLabel label sub m a
-> UnderLabel label sub m a -> UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
Alternative m =>
Applicative (UnderLabel label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative m =>
UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative m =>
UnderLabel label sub m a -> UnderLabel label sub m [a]
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative m =>
UnderLabel label sub m a
-> UnderLabel label sub m a -> UnderLabel label sub m a
forall (f :: * -> *).
Applicative f =>
(forall a. f a)
-> (forall a. f a -> f a -> f a)
-> (forall a. f a -> f [a])
-> (forall a. f a -> f [a])
-> Alternative f
$cempty :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative m =>
UnderLabel label sub m a
empty :: forall a. UnderLabel label sub m a
$c<|> :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative m =>
UnderLabel label sub m a
-> UnderLabel label sub m a -> UnderLabel label sub m a
<|> :: forall a.
UnderLabel label sub m a
-> UnderLabel label sub m a -> UnderLabel label sub m a
$csome :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative m =>
UnderLabel label sub m a -> UnderLabel label sub m [a]
some :: forall a. UnderLabel label sub m a -> UnderLabel label sub m [a]
$cmany :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Alternative m =>
UnderLabel label sub m a -> UnderLabel label sub m [a]
many :: forall a. UnderLabel label sub m a -> UnderLabel label sub m [a]
Alternative
, Functor (UnderLabel label sub m)
Functor (UnderLabel label sub m) =>
(forall a. a -> UnderLabel label sub m a)
-> (forall a b.
UnderLabel label sub m (a -> b)
-> UnderLabel label sub m a -> UnderLabel label sub m b)
-> (forall a b c.
(a -> b -> c)
-> UnderLabel label sub m a
-> UnderLabel label sub m b
-> UnderLabel label sub m c)
-> (forall a b.
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m b)
-> (forall a b.
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m a)
-> Applicative (UnderLabel label sub m)
forall a. a -> UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
Applicative m =>
Functor (UnderLabel label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Applicative m =>
a -> UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative m =>
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative m =>
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m b
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative m =>
UnderLabel label sub m (a -> b)
-> UnderLabel label sub m a -> UnderLabel label sub m b
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a b
c.
Applicative m =>
(a -> b -> c)
-> UnderLabel label sub m a
-> UnderLabel label sub m b
-> UnderLabel label sub m c
forall a b.
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m a
forall a b.
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m b
forall a b.
UnderLabel label sub m (a -> b)
-> UnderLabel label sub m a -> UnderLabel label sub m b
forall a b c.
(a -> b -> c)
-> UnderLabel label sub m a
-> UnderLabel label sub m b
-> UnderLabel label sub m c
forall (f :: * -> *).
Functor f =>
(forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
$cpure :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Applicative m =>
a -> UnderLabel label sub m a
pure :: forall a. a -> UnderLabel label sub m a
$c<*> :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative m =>
UnderLabel label sub m (a -> b)
-> UnderLabel label sub m a -> UnderLabel label sub m b
<*> :: forall a b.
UnderLabel label sub m (a -> b)
-> UnderLabel label sub m a -> UnderLabel label sub m b
$cliftA2 :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a b
c.
Applicative m =>
(a -> b -> c)
-> UnderLabel label sub m a
-> UnderLabel label sub m b
-> UnderLabel label sub m c
liftA2 :: forall a b c.
(a -> b -> c)
-> UnderLabel label sub m a
-> UnderLabel label sub m b
-> UnderLabel label sub m c
$c*> :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative m =>
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m b
*> :: forall a b.
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m b
$c<* :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Applicative m =>
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m a
<* :: forall a b.
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m a
Applicative
, (forall a b.
(a -> b) -> UnderLabel label sub m a -> UnderLabel label sub m b)
-> (forall a b.
a -> UnderLabel label sub m b -> UnderLabel label sub m a)
-> Functor (UnderLabel label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Functor m =>
a -> UnderLabel label sub m b -> UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Functor m =>
(a -> b) -> UnderLabel label sub m a -> UnderLabel label sub m b
forall a b.
a -> UnderLabel label sub m b -> UnderLabel label sub m a
forall a b.
(a -> b) -> UnderLabel label sub m a -> UnderLabel label sub m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Functor m =>
(a -> b) -> UnderLabel label sub m a -> UnderLabel label sub m b
fmap :: forall a b.
(a -> b) -> UnderLabel label sub m a -> UnderLabel label sub m b
$c<$ :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Functor m =>
a -> UnderLabel label sub m b -> UnderLabel label sub m a
<$ :: forall a b.
a -> UnderLabel label sub m b -> UnderLabel label sub m a
Functor
, Applicative (UnderLabel label sub m)
Applicative (UnderLabel label sub m) =>
(forall a b.
UnderLabel label sub m a
-> (a -> UnderLabel label sub m b) -> UnderLabel label sub m b)
-> (forall a b.
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m b)
-> (forall a. a -> UnderLabel label sub m a)
-> Monad (UnderLabel label sub m)
forall a. a -> UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
Monad m =>
Applicative (UnderLabel label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Monad m =>
a -> UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Monad m =>
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m b
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Monad m =>
UnderLabel label sub m a
-> (a -> UnderLabel label sub m b) -> UnderLabel label sub m b
forall a b.
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m b
forall a b.
UnderLabel label sub m a
-> (a -> UnderLabel label sub m b) -> UnderLabel label sub m b
forall (m :: * -> *).
Applicative m =>
(forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
$c>>= :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Monad m =>
UnderLabel label sub m a
-> (a -> UnderLabel label sub m b) -> UnderLabel label sub m b
>>= :: forall a b.
UnderLabel label sub m a
-> (a -> UnderLabel label sub m b) -> UnderLabel label sub m b
$c>> :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a
b.
Monad m =>
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m b
>> :: forall a b.
UnderLabel label sub m a
-> UnderLabel label sub m b -> UnderLabel label sub m b
$creturn :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
Monad m =>
a -> UnderLabel label sub m a
return :: forall a. a -> UnderLabel label sub m a
Monad
, Monad (UnderLabel label sub m)
Monad (UnderLabel label sub m) =>
(forall a. String -> UnderLabel label sub m a)
-> MonadFail (UnderLabel label sub m)
forall a. String -> UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
MonadFail m =>
Monad (UnderLabel label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadFail m =>
String -> UnderLabel label sub m a
forall (m :: * -> *).
Monad m =>
(forall a. String -> m a) -> MonadFail m
$cfail :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadFail m =>
String -> UnderLabel label sub m a
fail :: forall a. String -> UnderLabel label sub m a
Fail.MonadFail
, Monad (UnderLabel label sub m)
Monad (UnderLabel label sub m) =>
(forall a.
(a -> UnderLabel label sub m a) -> UnderLabel label sub m a)
-> MonadFix (UnderLabel label sub m)
forall a.
(a -> UnderLabel label sub m a) -> UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
MonadFix m =>
Monad (UnderLabel label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadFix m =>
(a -> UnderLabel label sub m a) -> UnderLabel label sub m a
forall (m :: * -> *).
Monad m =>
(forall a. (a -> m a) -> m a) -> MonadFix m
$cmfix :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadFix m =>
(a -> UnderLabel label sub m a) -> UnderLabel label sub m a
mfix :: forall a.
(a -> UnderLabel label sub m a) -> UnderLabel label sub m a
MonadFix
, Monad (UnderLabel label sub m)
Monad (UnderLabel label sub m) =>
(forall a. IO a -> UnderLabel label sub m a)
-> MonadIO (UnderLabel label sub m)
forall a. IO a -> UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
MonadIO m =>
Monad (UnderLabel label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadIO m =>
IO a -> UnderLabel label sub m a
forall (m :: * -> *).
Monad m =>
(forall a. IO a -> m a) -> MonadIO m
$cliftIO :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadIO m =>
IO a -> UnderLabel label sub m a
liftIO :: forall a. IO a -> UnderLabel label sub m a
MonadIO
, Monad (UnderLabel label sub m)
Alternative (UnderLabel label sub m)
(Alternative (UnderLabel label sub m),
Monad (UnderLabel label sub m)) =>
(forall a. UnderLabel label sub m a)
-> (forall a.
UnderLabel label sub m a
-> UnderLabel label sub m a -> UnderLabel label sub m a)
-> MonadPlus (UnderLabel label sub m)
forall a. UnderLabel label sub m a
forall a.
UnderLabel label sub m a
-> UnderLabel label sub m a -> UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
MonadPlus m =>
Monad (UnderLabel label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *).
MonadPlus m =>
Alternative (UnderLabel label sub m)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadPlus m =>
UnderLabel label sub m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadPlus m =>
UnderLabel label sub m a
-> UnderLabel label sub m a -> UnderLabel label sub m a
forall (m :: * -> *).
(Alternative m, Monad m) =>
(forall a. m a) -> (forall a. m a -> m a -> m a) -> MonadPlus m
$cmzero :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadPlus m =>
UnderLabel label sub m a
mzero :: forall a. UnderLabel label sub m a
$cmplus :: forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
MonadPlus m =>
UnderLabel label sub m a
-> UnderLabel label sub m a -> UnderLabel label sub m a
mplus :: forall a.
UnderLabel label sub m a
-> UnderLabel label sub m a -> UnderLabel label sub m a
MonadPlus
)
runUnderLabel :: forall label sub m a . UnderLabel label sub m a -> m a
runUnderLabel :: forall {k} (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *)
a.
UnderLabel label sub m a -> m a
runUnderLabel (UnderLabel m a
l) = m a
l
{-# INLINE runUnderLabel #-}
instance MonadTrans (UnderLabel sub label) where
lift :: forall (m :: * -> *) a. Monad m => m a -> UnderLabel sub label m a
lift = m a -> UnderLabel sub label m a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
m a -> UnderLabel label sub m a
UnderLabel
{-# INLINE lift #-}
instance (LabelledMember label sub sig, Algebra sig m) => Algebra (sub :+: sig) (UnderLabel label sub m) where
alg :: forall (ctx :: * -> *) (n :: * -> *) a.
Functor ctx =>
Handler ctx n (UnderLabel label sub m)
-> (:+:) sub sig n a -> ctx () -> UnderLabel label sub m (ctx a)
alg Handler ctx n (UnderLabel label sub m)
hdl = \case
L sub n a
sub -> m (ctx a) -> UnderLabel label sub m (ctx a)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
m a -> UnderLabel label sub m a
UnderLabel (m (ctx a) -> UnderLabel label sub m (ctx a))
-> (ctx () -> m (ctx a))
-> ctx ()
-> UnderLabel label sub m (ctx a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
forall (ctx :: * -> *) (n :: * -> *) a.
Functor ctx =>
Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
forall (sig :: (* -> *) -> * -> *) (m :: * -> *) (ctx :: * -> *)
(n :: * -> *) a.
(Algebra sig m, Functor ctx) =>
Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
alg (UnderLabel label sub m (ctx x) -> m (ctx x)
forall {k} (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *)
a.
UnderLabel label sub m a -> m a
runUnderLabel (UnderLabel label sub m (ctx x) -> m (ctx x))
-> (ctx (n x) -> UnderLabel label sub m (ctx x))
-> ctx (n x)
-> m (ctx x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ctx (n x) -> UnderLabel label sub m (ctx x)
Handler ctx n (UnderLabel label sub m)
hdl) (forall (label :: k) (sub :: (* -> *) -> * -> *)
(sup :: (* -> *) -> * -> *) (m :: * -> *) a.
LabelledMember label sub sup =>
Labelled label sub m a -> sup m a
forall {k} (label :: k) (sub :: (* -> *) -> * -> *)
(sup :: (* -> *) -> * -> *) (m :: * -> *) a.
LabelledMember label sub sup =>
Labelled label sub m a -> sup m a
injLabelled @label (sub n a -> Labelled label sub n a
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
sub m a -> Labelled label sub m a
Labelled sub n a
sub))
R sig n a
sig -> m (ctx a) -> UnderLabel label sub m (ctx a)
forall k (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *) a.
m a -> UnderLabel label sub m a
UnderLabel (m (ctx a) -> UnderLabel label sub m (ctx a))
-> (ctx () -> m (ctx a))
-> ctx ()
-> UnderLabel label sub m (ctx a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
forall (ctx :: * -> *) (n :: * -> *) a.
Functor ctx =>
Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
forall (sig :: (* -> *) -> * -> *) (m :: * -> *) (ctx :: * -> *)
(n :: * -> *) a.
(Algebra sig m, Functor ctx) =>
Handler ctx n m -> sig n a -> ctx () -> m (ctx a)
alg (UnderLabel label sub m (ctx x) -> m (ctx x)
forall {k} (label :: k) (sub :: (* -> *) -> * -> *) (m :: * -> *)
a.
UnderLabel label sub m a -> m a
runUnderLabel (UnderLabel label sub m (ctx x) -> m (ctx x))
-> (ctx (n x) -> UnderLabel label sub m (ctx x))
-> ctx (n x)
-> m (ctx x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ctx (n x) -> UnderLabel label sub m (ctx x)
Handler ctx n (UnderLabel label sub m)
hdl) sig n a
sig
{-# INLINE alg #-}