churros 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+29/−11 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Control.Churro.Prelude: sink :: Transport t => Churro t b Void
+ Control.Churro.Types: type DoubleDipped t = Churro t Void Void
+ Control.Churro.Types: type Sink t i = Churro t i Void
+ Control.Churro.Types: type Source t o = Churro t Void o
- Control.Churro.Prelude: sourceIO :: Transport t => ((o -> IO ()) -> IO a2) -> Churro t Void o
+ Control.Churro.Prelude: sourceIO :: Transport t => ((o -> IO ()) -> IO ()) -> Churro t Void o
Files
- churros.cabal +4/−6
- src/Control/Churro/Prelude.hs +12/−1
- src/Control/Churro/Types.hs +13/−4
churros.cabal view
@@ -1,13 +1,15 @@ cabal-version: 2.2 name: churros-version: 0.1.0.0+version: 0.1.0.1 license-file: LICENSE author: Lyndon Maydwell maintainer: lyndon@sordina.net+homepage: http://github.com/sordina/churros+bug-reports: http://github.com/sordina/churros/issues build-type: Simple extra-source-files: CHANGELOG.md license: MIT-synopsis: Churros: Channel/Arrow based streaming computation library.+synopsis: Channel/Arrow based streaming computation library. category: Data, Control description: The Churro library takes an opinionated approach to streaming by focusing on IO processes and allowing different transport@@ -16,10 +18,6 @@ source-repository head type: git location: git@github.com:sordina/churros.git---- custom-setup--- setup-depends:--- base, Cabal, cabal-doctest common churros-dependencies default-language: Haskell2010
src/Control/Churro/Prelude.hs view
@@ -106,7 +106,7 @@ -- >>> runWaitChan $ sourceIO (\cb -> cb 4 >> cb 2) >>> sinkPrint -- 4 -- 2-sourceIO :: Transport t => ((o -> IO ()) -> IO a2) -> Churro t Void o+sourceIO :: Transport t => ((o -> IO ()) -> IO ()) -> Churro t Void o sourceIO cb = buildChurro \_i o -> do cb (yeet o . Just)@@ -114,6 +114,16 @@ -- ** Sinks +-- | Consume all items with no additional effects.+-- +-- TODO: Decide if we should use some kind of `nf` evaluation here to force items.+-- +-- >>> runWaitChan $ pure 1 >>> process print >>> sink+-- 1+-- +sink :: Transport t => Churro t b Void+sink = sinkIO (const (return ()))+ -- | Consume a churro with an IO process. -- -- >>> runWaitChan $ pure 1 >>> sinkIO (\x -> print "hello" >> print (succ x))@@ -128,6 +138,7 @@ -- "hi" sinkPrint :: (Transport t, Show a) => Churro t a Void sinkPrint = sinkIO print+ -- ** Churros
src/Control/Churro/Types.hs view
@@ -24,12 +24,19 @@ -- ** Data, Classes and Instances -- | The core datatype for the library.--- Parameters`t`, `i` and `o` represent the transport,--- input and output types respectively. -- +-- Parameters `t`, `i` and `o` represent the transport, input, and output types respectively.+-- +-- The items on transports are wrapped in `Maybe` to allow signalling of completion of a source.+-- -- When building a program by composing Churros, the output Transport of one Churro is fed into the input Transports of other Churros. -- -data Churro t i o = Churro { runChurro :: IO (t (Maybe i), t (Maybe o), Async ()) }+-- Convenience types of `Source`, `Sink`, and `DoubleDipped` are also defined, although use is not required.+-- +data Churro t i o = Churro { runChurro :: IO (t (Maybe i), t (Maybe o), Async ()) }+type Source t o = Churro t Void o+type Sink t i = Churro t i Void+type DoubleDipped t = Churro t Void Void -- | The transport method is abstracted via the Transport class -- @@ -115,6 +122,7 @@ (Just f', Just g') -> (yeet o $ Just (f' g')) >> prog _ -> return () + -- TODO: Should we cancel asyncs here in finally block? prog yeet o Nothing wait fa@@ -136,7 +144,8 @@ -- m <- arr (> 5) -< j -- n <- sect -< (k,l,m) -- o <- arr not -< n--- sinkPrint -< o+-- p <- delay 0.1 -< o+-- sinkPrint -< p -- in -- runWaitChan $ sourceList [1,5,30] >>> graph -- :}