{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE BlockArguments #-}

-- | Chan Transport Instance.

module Control.Churro.Transport.Chan where
    
import Control.Churro.Types
import Control.Churro.Prelude

import Control.Concurrent
import Data.Void

instance Transport Chan where
    yank :: Chan a -> IO a
yank = Chan a -> IO a
forall a. Chan a -> IO a
readChan
    yeet :: Chan a -> a -> IO ()
yeet = Chan a -> a -> IO ()
forall a. Chan a -> a -> IO ()
writeChan
    flex :: IO (Chan a, Chan a)
flex = do 
        Chan a
c <- IO (Chan a)
forall a. IO (Chan a)
newChan
        (Chan a, Chan a) -> IO (Chan a, Chan a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Chan a
c,Chan a
c)

type ChurroChan      = Churro Chan
type TransportChan a = (Chan (Maybe a), Chan (Maybe a))

-- | Convenience function for running a Churro with a Chan Transport.
-- 
runWaitChan :: ChurroChan Void Void -> IO ()
runWaitChan :: ChurroChan Void Void -> IO ()
runWaitChan = ChurroChan Void Void -> IO ()
forall (t :: * -> *). Transport t => Churro t Void Void -> IO ()
runWait

-- | Convenience function for running a Churro into a List with a Chan Transport.
-- 
runWaitListChan :: ChurroChan Void o -> IO [o]
runWaitListChan :: ChurroChan Void o -> IO [o]
runWaitListChan = ChurroChan Void o -> IO [o]
forall (t :: * -> *) o. Transport t => Churro t Void o -> IO [o]
runWaitList