yaftee-conduit-mono-traversable (empty) → 0.1.0.0
raw patch · 8 files changed
+231/−0 lines, 8 filesdep +basedep +higher-order-open-uniondep +mono-traversablesetup-changed
Dependencies added: base, higher-order-open-union, mono-traversable, tools-yj, yaftee, yaftee-basic-monads, yaftee-conduit, yaftee-conduit-mono-traversable
Files
- CHANGELOG.md +11/−0
- LICENSE +26/−0
- README.md +3/−0
- Setup.hs +2/−0
- src/Control/Monad/Yaftee/Pipe/MonoTraversable.hs +61/−0
- src/Control/Monad/Yaftee/Pipe/MonoTraversable/Crc32.hs +57/−0
- test/Spec.hs +2/−0
- yaftee-conduit-mono-traversable.cabal +69/−0
+ CHANGELOG.md view
@@ -0,0 +1,11 @@+# Changelog for `yaftee-conduit-mono-traversable`++All notable changes to this project will be documented in this file.++The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),+and this project adheres to the+[Haskell Package Versioning Policy](https://pvp.haskell.org/).++## Unreleased++## 0.1.0.0 - YYYY-MM-DD
+ LICENSE view
@@ -0,0 +1,26 @@+Copyright 2025 Yoshikuni Jujo++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this+ list of conditions and the following disclaimer.++2. 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.++3. Neither the name of the copyright holder 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 HOLDER 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.
+ README.md view
@@ -0,0 +1,3 @@+# yaftee-conduit-mono-traversable++MonoTraversable tools for Yaftee Conduit.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Control/Monad/Yaftee/Pipe/MonoTraversable.hs view
@@ -0,0 +1,61 @@+{-# LANGUAGE ImportQualifiedPost #-}+{-# LANGUAGE BlockArguments, LambdaCase #-}+{-# LANGUAGE ExplicitForAll #-}+{-# LANGUAGE RequiredTypeArguments #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# OPTIONS_GHC -Wall -fno-warn-tabs #-}++module Control.Monad.Yaftee.Pipe.MonoTraversable (++ lengthRun, length, length', Length, lengthFromInt64, lengthToInt64++ ) where++import Prelude hiding (length)+import Control.Monad+import Control.Monad.Fix+import Control.Monad.Yaftee.Eff qualified as Eff+import Control.Monad.Yaftee.Pipe qualified as Pipe+import Control.Monad.Yaftee.State qualified as State+import Control.HigherOpenUnion qualified as U+import Data.HigherFunctor qualified as HFunctor+import Data.MonoTraversable+import Data.Int++lengthRun :: forall nm es i o r . HFunctor.Loose (U.U es) =>+ Eff.E (State.Named nm Length ': es) i o r -> Eff.E es i o (r, Length)+lengthRun = (`State.runN` (0 :: Length))++length :: forall nm -> (+ MonoFoldable mono,+ U.Member Pipe.P es,+ U.Member (State.Named nm Length) es ) =>+ Eff.E es mono mono r+length nm = do+ State.putN nm $ Length 0+ forever $ Pipe.await >>= \xs ->+ State.modifyN nm (+ Length (olength64 xs)) >> Pipe.yield xs++length' :: forall nm -> (+ MonoFoldable mono,+ U.Member Pipe.P es,+ U.Member (State.Named nm Length) es ) =>+ Eff.E es mono mono ()+length' nm = do+ State.putN nm $ Length 0+ fix \go -> Pipe.awaitMaybe >>= \case+ Nothing -> pure ()+ Just xs -> (>> go) do+ State.modifyN nm (+ Length (olength64 xs))+ Pipe.yield xs++newtype Length = Length { unLength :: Int64 }+ deriving (Show, Eq, Ord, Enum, Num, Real, Integral)++lengthToInt64 :: Length -> Int64+lengthToInt64 = unLength++lengthFromInt64 :: Int64 -> Length+lengthFromInt64 = Length
+ src/Control/Monad/Yaftee/Pipe/MonoTraversable/Crc32.hs view
@@ -0,0 +1,57 @@+{-# LANGUAGE ImportQualifiedPost #-}+{-# LANGUAGE BlockArguments, LambdaCase #-}+{-# LANGUAGE ExplicitForAll #-}+{-# LANGUAGE RequiredTypeArguments #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE FlexibleContexts #-}+{-# OPTIONS_GHC -Wall -fno-warn-tabs #-}++module Control.Monad.Yaftee.Pipe.MonoTraversable.Crc32 (++ run, complement, crc32, crc32',++ step++ ) where++import Control.Monad+import Control.Monad.Fix+import Control.Monad.Yaftee.Eff qualified as Eff+import Control.Monad.Yaftee.Pipe qualified as Pipe+import Control.Monad.Yaftee.State qualified as State+import Control.HigherOpenUnion qualified as U+import Data.HigherFunctor qualified as HFunctor+import Data.MonoTraversable+import Data.Word+import Data.Word.Crc32 qualified as Crc32++run :: forall nm es i o r . HFunctor.Loose (U.U es) =>+ Eff.E (State.Named nm Crc32.C ': es) i o r -> Eff.E es i o (r, Crc32.C)+run = (`State.runN` Crc32.initial)++complement ::+ forall nm -> U.Member (State.Named nm Crc32.C) es => Eff.E es i o ()+complement nm = State.modifyN nm Crc32.complement++crc32 :: forall nm -> (+ MonoFoldable mono, Element mono ~ Word8,+ U.Member Pipe.P es, U.Member (State.Named nm Crc32.C) es ) =>+ Eff.E es mono mono r+crc32 nm = do+ State.putN nm Crc32.initial+ forever $ Pipe.await >>= \s ->+ State.modifyN nm (`step` s) >> Pipe.yield s++crc32' :: forall nm -> (+ MonoFoldable mono, Element mono ~ Word8,+ U.Member Pipe.P es, U.Member (State.Named nm Crc32.C) es ) =>+ Eff.E es mono mono ()+crc32' nm = do+ State.putN nm Crc32.initial+ fix \go -> Pipe.awaitMaybe >>= \case+ Nothing -> pure ()+ Just bs -> (>> go)+ $ State.modifyN nm (`step` bs) >> Pipe.yield bs++step :: (MonoFoldable mono, Element mono ~ Word8) => Crc32.C -> mono -> Crc32.C+step = ofoldl' Crc32.step
+ test/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"
+ yaftee-conduit-mono-traversable.cabal view
@@ -0,0 +1,69 @@+cabal-version: 2.2++-- This file has been generated from package.yaml by hpack version 0.38.1.+--+-- see: https://github.com/sol/hpack++name: yaftee-conduit-mono-traversable+version: 0.1.0.0+synopsis: Mono traversable tools for Yaftee Conduit+description: Please see the README on GitHub at <https://github.com/YoshikuniJujo/yaftee-conduit-mono-traversable#readme>+category: Control+homepage: https://github.com/YoshikuniJujo/yaftee-conduit-mono-traversable#readme+bug-reports: https://github.com/YoshikuniJujo/yaftee-conduit-mono-traversable/issues+author: Yoshikuni Jujo+maintainer: yoshikuni.jujo@gmail.com+copyright: (c) 2025 Yoshikuni Jujo+license: BSD-3-Clause+license-file: LICENSE+build-type: Simple+extra-source-files:+ README.md+extra-doc-files:+ CHANGELOG.md++source-repository head+ type: git+ location: https://github.com/YoshikuniJujo/yaftee-conduit-mono-traversable++library+ exposed-modules:+ Control.Monad.Yaftee.Pipe.MonoTraversable+ Control.Monad.Yaftee.Pipe.MonoTraversable.Crc32+ other-modules:+ Paths_yaftee_conduit_mono_traversable+ autogen-modules:+ Paths_yaftee_conduit_mono_traversable+ hs-source-dirs:+ src+ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints+ build-depends:+ base >=4.7 && <5+ , higher-order-open-union ==0.1.*+ , mono-traversable ==1.0.*+ , tools-yj ==0.1.*+ , yaftee ==0.1.*+ , yaftee-basic-monads ==0.1.*+ , yaftee-conduit ==0.1.*+ default-language: Haskell2010++test-suite yaftee-conduit-mono-traversable-test+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ other-modules:+ Paths_yaftee_conduit_mono_traversable+ autogen-modules:+ Paths_yaftee_conduit_mono_traversable+ hs-source-dirs:+ test+ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ base >=4.7 && <5+ , higher-order-open-union ==0.1.*+ , mono-traversable ==1.0.*+ , tools-yj ==0.1.*+ , yaftee ==0.1.*+ , yaftee-basic-monads ==0.1.*+ , yaftee-conduit ==0.1.*+ , yaftee-conduit-mono-traversable+ default-language: Haskell2010