| 3. Why Seek FileOffset is error message? Are you talking about John Lato's implementation [1]?
Well, `Seek' is not an error message. It is one of constructors for ErrMsg, and ErrMsg is [2] > -- -- a message to the stream producer (e.g., to rewind the stream) > -- or an error indication. You know the overall idea behind Seek, don't you? It is an instrument to implement random IO [3]. Compare Oleg's code [4] > data SeekException = SeekException FileOffset > deriving Show > > instance Typeable SeekException where > typeOf _ = mkTyConApp (mkTyCon "SeekException") [] > > instance Exception SeekException and [2] > type ErrMsg = SomeException > data Stream el = EOF (Maybe ErrMsg) | Chunk [el] deriving Show with John Lato's implementation [1]: > data StreamG c el = > EOF (Maybe ErrMsg) > | Chunk (c el) > data ErrMsg = Err String > | Seek FileOffset > deriving (Show, Eq) John makes Err and Seek to be the distinct constructors of ErrMsg. Errors (Err) in `iteratee' package are always Strings. Oleg's ErrMsg is SomeException. One of its instances (SeekException) is a ``rewind the stream'' message to the stream producer. And the user is free to have as many different ErrMsg'es as he needs to do the job. [1] http://inmachina.net/~jwlato/haskell/iteratee/src/Data/Iteratee/Base.hs [2] http://okmij.org/ftp/Haskell/Iteratee/IterateeM.hs [3] http://okmij.org/ftp/Streams.html#random-bin-IO [4] http://okmij.org/ftp/Haskell/Iteratee/RandomIO.hs -- vvv _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
