module Ouroboros.Network.Subscription.Subscriber
( SubscriptionTarget (..)
, listSubscriptionTarget
) where
newtype SubscriptionTarget m target = SubscriptionTarget
{ SubscriptionTarget m target
-> m (Maybe (target, SubscriptionTarget m target))
getSubscriptionTarget :: m (Maybe (target, SubscriptionTarget m target))
}
listSubscriptionTarget
:: Applicative m
=> [target]
-> SubscriptionTarget m target
listSubscriptionTarget :: [target] -> SubscriptionTarget m target
listSubscriptionTarget [] = m (Maybe (target, SubscriptionTarget m target))
-> SubscriptionTarget m target
forall (m :: * -> *) target.
m (Maybe (target, SubscriptionTarget m target))
-> SubscriptionTarget m target
SubscriptionTarget (m (Maybe (target, SubscriptionTarget m target))
-> SubscriptionTarget m target)
-> m (Maybe (target, SubscriptionTarget m target))
-> SubscriptionTarget m target
forall a b. (a -> b) -> a -> b
$ Maybe (target, SubscriptionTarget m target)
-> m (Maybe (target, SubscriptionTarget m target))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (target, SubscriptionTarget m target)
forall a. Maybe a
Nothing
listSubscriptionTarget (target
t:[target]
ts) = m (Maybe (target, SubscriptionTarget m target))
-> SubscriptionTarget m target
forall (m :: * -> *) target.
m (Maybe (target, SubscriptionTarget m target))
-> SubscriptionTarget m target
SubscriptionTarget (m (Maybe (target, SubscriptionTarget m target))
-> SubscriptionTarget m target)
-> m (Maybe (target, SubscriptionTarget m target))
-> SubscriptionTarget m target
forall a b. (a -> b) -> a -> b
$ Maybe (target, SubscriptionTarget m target)
-> m (Maybe (target, SubscriptionTarget m target))
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((target, SubscriptionTarget m target)
-> Maybe (target, SubscriptionTarget m target)
forall a. a -> Maybe a
Just (target
t, [target] -> SubscriptionTarget m target
forall (m :: * -> *) target.
Applicative m =>
[target] -> SubscriptionTarget m target
listSubscriptionTarget [target]
ts))