module Effectful.Concurrent.Chan
(
Concurrent
, runConcurrent
, Chan
, newChan
, writeChan
, readChan
, dupChan
, getChanContents
, writeList2Chan
) where
import Control.Concurrent.Chan (Chan)
import qualified Control.Concurrent.Chan as C
import Effectful
import Effectful.Concurrent.Effect
import Effectful.Dispatch.Static
newChan :: Concurrent :> es => Eff es (Chan a)
newChan :: forall (es :: [Effect]) a. (Concurrent :> es) => Eff es (Chan a)
newChan = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall a. IO (Chan a)
C.newChan
writeChan :: Concurrent :> es => Chan a -> a -> Eff es ()
writeChan :: forall (es :: [Effect]) a.
(Concurrent :> es) =>
Chan a -> a -> Eff es ()
writeChan Chan a
c = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Chan a -> a -> IO ()
C.writeChan Chan a
c
readChan :: Concurrent :> es => Chan a -> Eff es a
readChan :: forall (es :: [Effect]) a. (Concurrent :> es) => Chan a -> Eff es a
readChan = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Chan a -> IO a
C.readChan
dupChan :: Concurrent :> es => Chan a -> Eff es (Chan a)
dupChan :: forall (es :: [Effect]) a.
(Concurrent :> es) =>
Chan a -> Eff es (Chan a)
dupChan = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Chan a -> IO (Chan a)
C.dupChan
getChanContents :: Concurrent :> es => Chan a -> Eff es [a]
getChanContents :: forall (es :: [Effect]) a.
(Concurrent :> es) =>
Chan a -> Eff es [a]
getChanContents = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Chan a -> IO [a]
C.getChanContents
writeList2Chan :: Concurrent :> es => Chan a -> [a] -> Eff es ()
writeList2Chan :: forall (es :: [Effect]) a.
(Concurrent :> es) =>
Chan a -> [a] -> Eff es ()
writeList2Chan Chan a
c = forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Chan a -> [a] -> IO ()
C.writeList2Chan Chan a
c