[Haskell-cafe] ANNOUNCE: enumerator 0.4.8

Michael Snoyman michael at snoyman.com
Tue Mar 29 21:00:56 CEST 2011


Thanks, I look forward to being able to use these new operators!

On Tue, Mar 29, 2011 at 8:22 PM, John Millikin <jmillikin at gmail.com> wrote:
> 0.4.9 has been uploaded to cabal, with the new operators. Changes are in the
> replied-to post (and also quoted below), plus the new operators proposed by
> Kazu Yamamoto.
>
> Here's the corresponding docs (they have examples!)
>
> ------------------------------------------------------------------------------------------------------
> -- | @enum =$ iter = 'joinI' (enum $$ iter)@
> --
> -- &#x201c;Wraps&#x201d; an iteratee /inner/ in an enumeratee /wrapper/.
> -- The resulting iteratee will consume /wrapper/&#x2019;s input type and
> -- yield /inner/&#x2019;s output type.
> --
> -- Note: if the inner iteratee yields leftover input when it finishes,
> -- that extra will be discarded.
> --
> -- As an example, consider an iteratee that converts a stream of
> UTF8-encoded
> -- bytes into a single 'TL.Text':
> --
> -- > consumeUTF8 :: Monad m => Iteratee ByteString m Text
> --
> -- It could be written with either 'joinI' or '(=$)':
> --
> -- > import Data.Enumerator.Text as ET
> -- >
> -- > consumeUTF8 = joinI (decode utf8 $$ ET.consume)
> -- > consumeUTF8 = decode utf8 =$ ET.consume
> --
> -- Since: 0.4.9
>
> -- | @enum $= enee = 'joinE' enum enee@
> --
> -- &#x201c;Wraps&#x201d; an enumerator /inner/ in an enumeratee /wrapper/.
> -- The resulting enumerator will generate /wrapper/&#x2019;s output type.
> --
> -- As an example, consider an enumerator that yields line character counts
> -- for a text file (e.g. for source code readability checking):
> --
> -- > enumFileCounts :: FilePath -> Enumerator Int IO b
> --
> -- It could be written with either 'joinE' or '($=)':
> --
> -- > import Data.Text as T
> -- > import Data.Enumerator.List as EL
> -- > import Data.Enumerator.Text as ET
> -- >
> -- > enumFileCounts path = joinE (enumFile path) (EL.map T.length)
> -- > enumFileCounts path = enumFile path $= EL.map T.length
> --
> -- Since: 0.4.9
> ------------------------------------------------------------------------------------------------------
>
> Minor release note -- 0.4.9 and 0.4.9.1 are the exact same code; I just
> forgot a @ in one of the new docs and had to re-upload so Hackage would
> haddock properly. There is no difference in behavior.
>
> On Monday, March 28, 2011 10:50:45 PM UTC-7, John Millikin wrote:
>>
>> Since the release, a couple people have sent in feature requests, so I'm
>> going to put out 0.4.9 in a day or so.
>>
>> New features will be:
>>
>> - tryIO: runs an IO computation, and converts any exceptions into
>> ``throwError`` calls (requested by Kazu Yamamoto)
>>
>> - checkContinue: encapsulates a common pattern (loop (Continue k) = ...)
>> when defining enumerators
>>
>> - mapAccum and mapAccum: sort of like map and mapM, except the step
>> function is stateful (requested by Long Huynh Huu)
>>
>> Anyone else out there sitting on a request? Please send them in -- I am
>> always happy to receive them, even if they must be declined.
>>
>> ---
>>
>> Also, I would like to do a quick poll regarding operators.
>>
>> 1. It has been requested that I add operator aliases for joinI and joinE.
>>
>> 2. There have been complaints that the library defines too many operators
>> (currently, 5).
>>
>> Do any existing enumerator users, or anyone for that matter, have an
>> opinion either way?
>>
>> The proposed operators are:
>>
>> ----------------------------------------------------------------------
>> infixr 0 =$
>> infixr 0 $=
>>
>> (=$) :: Monad m => Enumeratee ao ai m b -> Iteratee ai m b -> Iteratee ao
>> m b
>> enum =$ iter = joinI (enum $$ iter)
>>
>> ($=) :: Monad m => Enumerator ao m (Step ai m b) -> Enumeratee ao ai m b
>> -> Enumerator ai m b
>> ($=) = joinE
>> ----------------------------------------------------------------------
>>
>



More information about the Haskell-Cafe mailing list