{-# LANGUAGE BlockArguments #-}

-- | Re-exporting Transport instances.
-- 
-- Also includes convenience functions for working directly with transports.
-- 
module Control.Churro.Transport

    ( module Control.Churro.Transport.Chan
    , module Control.Churro.Transport
    )

where

import Control.Churro.Transport.Chan
import Control.Churro.Types

-- | Write a list to a raw Transport.
-- 
-- >>> :set -XTypeApplications
-- >>> import Control.Concurrent.Chan
-- >>> :{
-- do
--   (i,o) <- flex @Chan
--   l2c i (map Just [1,2] ++ [Nothing])
--   yankAll' o print
-- :}
-- Just (Just 1)
-- Just (Just 2)
-- Just Nothing
-- Nothing
-- 
l2c :: (Foldable f, Transport t) => In t (Maybe a) -> f a -> IO ()
l2c :: In t (Maybe a) -> f a -> IO ()
l2c In t (Maybe a)
c f a
l = (a -> IO ()) -> f a -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (In t (Maybe a) -> Maybe a -> IO ()
forall (t :: * -> *) a. Transport t => In t a -> a -> IO ()
yeet In t (Maybe a)
c (Maybe a -> IO ()) -> (a -> Maybe a) -> a -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Maybe a
forall a. a -> Maybe a
Just) f a
l IO () -> IO () -> IO ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> In t (Maybe a) -> Maybe a -> IO ()
forall (t :: * -> *) a. Transport t => In t a -> a -> IO ()
yeet In t (Maybe a)
c Maybe a
forall a. Maybe a
Nothing