Skip to content

Commit

Permalink
producer branch of conduit
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Feb 13, 2013
1 parent 5dc344f commit 0d91880
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Text/HTML/TagStream/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ showToken _ (Incomplete s) = B.fromByteString s
-- {{{ Stream
tokenStream :: Monad m
#if MIN_VERSION_conduit(1, 0, 0)
=> MonadConduit ByteString m Token
=> Conduit ByteString m Token
#else
=> GInfConduit ByteString m Token
#endif
Expand Down
16 changes: 5 additions & 11 deletions Text/HTML/TagStream/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import qualified Data.Attoparsec.ByteString.Char8 as S
import Data.Attoparsec.Text
import Data.Conduit
#if MIN_VERSION_conduit(1, 0, 0)
import Data.Conduit.Internal (streamFromPipe, unConduitM)
import Data.Conduit.Internal (unConduitM)
#else
import Data.Conduit.Internal (pipeL)
#endif
Expand Down Expand Up @@ -226,7 +226,7 @@ showToken _ (Incomplete s) = B.fromText s
-- {{{ Stream
tokenStream :: Monad m
#if MIN_VERSION_conduit(1, 0, 0)
=> MonadConduit Text m Token
=> Conduit Text m Token
#else
=> GInfConduit Text m Token
#endif
Expand All @@ -253,7 +253,7 @@ tokenStream =
-- Only support utf-8 and iso8859 for now.
tokenStreamBS :: MonadThrow m
#if MIN_VERSION_conduit(1, 0, 0)
=> MonadConduit ByteString m Token
=> Conduit ByteString m Token
#else
=> GLInfConduit ByteString m Token
#endif
Expand All @@ -269,16 +269,10 @@ tokenStreamBS = do

let codec = fromMaybe C.utf8 (mencoding >>= getCodec . CI.mk)

when yieldToken $
#if MIN_VERSION_conduit(1, 0, 0)
liftStreamMonad
#else
lift
#endif
(mapM (decodeBS codec) tk) >>= yield
when yieldToken $ lift (mapM (decodeBS codec) tk) >>= yield

#if MIN_VERSION_conduit(1, 0, 0)
streamFromPipe $ unConduitM $ C.decode codec =$= tokenStream
C.decode codec =$= tokenStream
#else
C.decode codec `pipeL` tokenStream
#endif
Expand Down

0 comments on commit 0d91880

Please sign in to comment.