
Conal Elliott wrote:
Is there a simpler model of Enumerator? My intuition is that it's simply a stream:
[[Enumerator a]] = String
Oddly, 'a' doesn't show up on the RHS. Maybe the representation ought to be
type Enumerator = forall a. Iteratee a -> Iteratee a
so
[[Enumerator]] = String
I concur, that seems to be all there is to it. There is a small nuance in the Iteratee implementation, namely: if an Enumerator is something that provides a complete input stream to an Iteratee, why isn't it simply defined as type Enumerator = forall a. Iteratee a -> a i.e. as a function that runs an Iteratee on an input stream and extracts the result? I think the purpose of the implementation type Enumerator = forall a. Iteratee a -> Iteratee a is that it allows us to concatenate different input streams. In other words fromString (xs ++ ys) = fromString ys . fromString xs assuming a function fromString :: String -> Enumerator To get an actual result from an Iteratee, we only need a way to run it on the empty stream. runOnEmptyString :: Iteratee a -> Maybe a Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com