packages feed

Shpadoinkle-streaming (empty) → 0.0.0.1

raw patch · 4 files changed

+91/−0 lines, 4 filesdep +Shpadoinkledep +basedep +lenssetup-changed

Dependencies added: Shpadoinkle, base, lens, streaming, text

Files

+ LICENSE view
@@ -0,0 +1,27 @@+Shpadoinkle Streaming aka S11 Streaming+Copyright © 2021 Morgan Thomas+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright notice,+   this list of conditions and the following disclaimer.+ * Redistributions in binary form must reproduce the above copyright+   notice, this list of conditions and the following disclaimer in the+   documentation and/or other materials provided with the distribution.+ * Neither the name of Shpadoinkle nor the names of its contributors may be+   used to endorse or promote products derived from this software without+   specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import           Distribution.Simple+main = defaultMain
+ Shpadoinkle-streaming.cabal view
@@ -0,0 +1,34 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.33.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 693d20b2676ff508bd219f3ec4316438b9fddb2c2fec92a13496b5e2da453954++name:           Shpadoinkle-streaming+version:        0.0.0.1+synopsis:       Integration of the streaming library with Shpadoinkle continuations.+description:    Integration of the streaming library with Shpadoinkle continuations.+category:       Web+author:         Morgan Thomas+maintainer:     morgan.a.s.thomas@gmail.com+license:        BSD3+license-file:   LICENSE+build-type:     Simple++library+  exposed-modules:+      Shpadoinkle.Streaming+  other-modules:+      Paths_Shpadoinkle_streaming+  hs-source-dirs:+      ./.+  ghc-options: -Wall -Wcompat -fwarn-redundant-constraints -fwarn-tabs -fwarn-incomplete-record-updates -fwarn-identities+  build-depends:+      Shpadoinkle+    , base >=4.12.0 && <4.16+    , lens+    , streaming >=0.2 && <0.3+    , text+  default-language: Haskell2010
+ Shpadoinkle/Streaming.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE ScopedTypeVariables #-}+++module Shpadoinkle.Streaming+  ( consumeStream+  ) where+++import           Shpadoinkle        hiding (h)++import           Data.Functor.Of    (Of ((:>)))+import           Streaming          (Stream)+import           Streaming.Internal (destroy)+++consumeStream :: forall m a b. Monad m => Stream (Of a) m () -> (a -> m (b -> b)) -> Continuation m b+consumeStream stream f = destroy stream g h j+  where+    g :: Of a (Continuation m b) -> Continuation m b+    g (a :> k) = voidRunContinuationT $ do+      commit (impur (f a))+      commit (merge k)++    h :: m (Continuation m b) -> Continuation m b+    h = causedBy++    j :: () -> Continuation m b+    j = const done