From 91d911675268e836372ef1241ca67c70f91f9089 Mon Sep 17 00:00:00 2001 From: Torgeir Strand Henriksen Date: Thu, 5 Jun 2014 15:52:04 +0200 Subject: [PATCH] Added function for upgrading Word8 isomorphisms to work with ByteString Producers --- src/Pipes/ByteString.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Pipes/ByteString.hs b/src/Pipes/ByteString.hs index e6b8994..a92fad3 100644 --- a/src/Pipes/ByteString.hs +++ b/src/Pipes/ByteString.hs @@ -129,6 +129,9 @@ module Pipes.ByteString ( , lines , words + -- * Utilities + , pipeIso + -- * Re-exports -- $reexports , module Data.ByteString @@ -988,6 +991,14 @@ words = Data.Profunctor.dimap _words (fmap _unwords) _unwords = PG.intercalates (yield $ BS.singleton $ fromIntegral $ ord ' ') {-# INLINABLE words #-} +-- | Upgrade a 'Word8' isomorphism to work with 'ByteString' 'Producer's +pipeIso + :: Monad m + => Iso' Word8 Word8 + -> Iso' (Proxy x' x () ByteString m r) (Proxy x' x () ByteString m r) +pipeIso = PP.mapIso $ (<-<) . map +{-# INLINABLE pipeIso #-} + {- $parse The following parsing utilities are single-byte analogs of the ones found in @pipes-parse@.