anchor.diff:  2. The iteratee does not pull data but receives chunks of data from an "enumerator". It returns a continuation to receive and process the next chunk. This means that an iteratee may be paused at any time, either by neglecting to pass it any additional data or by passing an Empty chunk.
   
   *)
  +
  +/// A stream of chunks of data generated by an Enumerator.
  +/// The stream can be composed of chunks of 'a, empty blocks indicating a wait, or an EOF marker.
  +/// Be aware that when using #seq<_> types, you will need to check for both Seq.empty ([]) and Empty.
  +type Stream<'a> =
  +    | Chunk of 'a
  +    | Empty
  +    | EOF
  +
  +/// The iteratee is a stream consumer that will consume a stream of data until either 
  +/// it receives an EOF or meets its own requirements for consuming data. The iteratee
  +/// will return Continue whenever it is ready to receive the next chunk. An iteratee
  +/// is fed data by an Enumerator, which generates a Stream. 
  +type Iteratee<'el,'a> =
  +    | Done of 'a * Stream<'el>
  +    | Error of exn
  +    | Continue of (Stream<'el> -> Iteratee<'el,'a>)
  +
  +/// An enumerator generates a stream of data and feeds an iteratee, returning a new iteratee.
  +type Enumerator<'el,'a> = Iteratee<'el,'a> -> Iteratee<'el,'a>
  +
  +/// An enumeratee is an enumerator that produces an iteratee using another iteratee as input.
  +/// Enumeratees can be used for tasks such as encoding or encrypting data.
  +type Enumeratee<'elo,'eli,'a> = Iteratee<'eli,'a> -> Iteratee<'elo, Iteratee<'eli,'a>>
  +
  +[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
   module Iteratee =
       open FSharpx
       
  -    /// A stream of chunks of data generated by an Enumerator.
  -    /// The stream can be composed of chunks of 'a, empty blocks indicating a wait, or an EOF marker.
  -    /// Be aware that when using #seq<_> types, you will need to check for both Seq.empty ([]) and Empty.
  -    type Stream<'a> =
  -        | Chunk of 'a
  -        | Empty
  -        | EOF
  +    let returnI x = Done(x,Empty)
  +    let empty<'a> : Iteratee<'a,_> = Done((),Empty)
  +    let doneI x s = Done(x,s)
  +    let continueI k = Continue k
  +    let throw e = Error e
  +
  +    let bind f i =
  +        let inner bind = function
  +            | Done(x, extra) ->
  +                match f x with
  +                | Done(x',_) -> Done(x', extra)
  +                | Error e    -> Error e
  +                | Continue k -> k extra
  +            | Error e    -> Error e
  +            | Continue k -> Continue(bind << k)
  +        fix inner i
  +
  +    let opt i =
  +        let inner opt = function
  +            | Done(x, s) -> Done(Some x, s)
  +            | Error e    -> Done(None, Empty)
  +            | Continue k -> Continue(opt << k)
  +        fix inner i
  +
  +    let catchError h i =
  +        let rec step = function
  +            | Error e    -> h e
  +            | Continue k -> Continue <| fun s -> step (k s)
  +            | i          -> i
  +        in step i
  +
  +    let tryFinally compensation i =
  +        let rec step = function 
  +            | Continue k -> Continue <| fun s -> step (k s)
  +            | i          -> compensation(); i
  +        in step i
  +
  +    let rec enumEOF = function 
  +        | Done(x,_)  -> Done(x, EOF)
  +        | Error e    -> Error e
  +        | Continue k ->
  +            match k EOF with
  +            | Continue _ -> failwith "enumEOF: divergent iteratee"
  +            | i          -> enumEOF i
  +
  +    let enumErr e = function _ -> Error e
  +
  +    let run_ i =
  +        match enumEOF i with
  +        | Done(x,_)  -> Choice1Of2 x
  +        | Error e    -> Choice2Of2 e
  +        | Continue _ -> failwith "run: divergent iteratee"
       
  -    /// The iteratee is a stream consumer that will consume a stream of data until either 
  -    /// it receives an EOF or meets its own requirements for consuming data. The iteratee
  -    /// will return Continue whenever it is ready to receive the next chunk. An iteratee
  -    /// is fed data by an Enumerator, which generates a Stream. 
  -    type Iteratee<'el,'a> =
  -        | Done of 'a * Stream<'el>
  -        | Error of exn
  -        | Continue of (Stream<'el> -> Iteratee<'el,'a>)
  -    
  -    /// An enumerator generates a stream of data and feeds an iteratee, returning a new iteratee.
  -    type Enumerator<'el,'a> = Iteratee<'el,'a> -> Iteratee<'el,'a>
  -    
  -    /// An enumeratee is an enumerator that produces an iteratee using another iteratee as input.
  -    /// Enumeratees can be used for tasks such as encoding or encrypting data.
  -    type Enumeratee<'elo,'eli,'a> = Iteratee<'eli,'a> -> Iteratee<'elo, Iteratee<'eli,'a>>
  -    
  -    [<AutoOpen>]
  -    module Primitives =
  -    
  -        let returnI x = Done(x,Empty)
  -        let empty<'a> : Iteratee<'a,_> = Done((),Empty)
  -        let doneI x s = Done(x,s)
  -        let continueI k = Continue k
  -        let throw e = Error e
  -    
  -        let bind f i =
  -            let inner bind = function
  -                | Done(x, extra) ->
  -                    match f x with
  -                    | Done(x',_) -> Done(x', extra)
  -                    | Error e    -> Error e
  -                    | Continue k -> k extra
  -                | Error e    -> Error e
  -                | Continue k -> Continue(bind << k)
  -            fix inner i
  -
  -        let opt i =
  -            let inner opt = function
  -                | Done(x, s) -> Done(Some x, s)
  -                | Error e    -> Done(None, Empty)
  -                | Continue k -> Continue(opt << k)
  -            fix inner i
  -
  -        let catchError h i =
  -            let rec step = function
  -                | Error e    -> h e
  -                | Continue k -> Continue <| fun s -> step (k s)
  -                | i          -> i
  -            in step i
  -    
  -        let tryFinally compensation i =
  -            let rec step = function 
  -                | Continue k -> Continue <| fun s -> step (k s)
  -                | i          -> compensation(); i
  -            in step i
  -
  -        let rec enumEOF = function 
  -            | Done(x,_)  -> Done(x, EOF)
  -            | Error e    -> Error e
  -            | Continue k ->
  -                match k EOF with
  -                | Continue _ -> failwith "enumEOF: divergent iteratee"
  -                | i          -> enumEOF i
  -
  -        let enumErr e = function _ -> Error e
  -
  -        let run_ i =
  -            match enumEOF i with
  -            | Done(x,_)  -> Choice1Of2 x
  -            | Error e    -> Choice2Of2 e
  -            | Continue _ -> failwith "run: divergent iteratee"
  -        
  -        let run i =
  -            match run_ i with
  -            | Choice1Of2 x -> x
  -            | Choice2Of2 e -> raise e
  +    let run i =
  +        match run_ i with
  +        | Choice1Of2 x -> x
  +        | Choice2Of2 e -> raise e
           
       type IterateeBuilder() =
           member this.Return(x) = Done(x, Empty)
  
positive.code:                  | Continue k -> let x, xs = ByteString.head str, ByteString.tail str in enumerate xs (k (Chunk (ByteString.singleton x)))
                   | _ -> i
  
          let enumStream bufferSize (stream:#System.IO.Stream) i =
              let buffer = Array.zeroCreate<byte> bufferSize
              let rec step = function Continue k -> read k | i -> i
              and read k =
                  let result = stream.Read(buffer, 0, bufferSize) in
                  if result = 0 then Continue k
                  else step (k (Chunk(BS(buffer,0,result))))
              step i
  
          let enumStreamReader (reader:#System.IO.TextReader) i =
              let rec step i =
                  match i with
                  | Done(_,_) -> i
                  | Continue k ->
                      let line = reader.ReadLine()
                      if line = null then i
                      else step (k (Chunk(ByteString.ofString line)))
                  | _ -> i
              step i
  
negative.code: open System
  open System.Collections
  open System.Collections.Generic
  open FSharp.Control
  
  (*
  # Iteratee
  