{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FunctionalDependencies #-}-- |Monadic Iteratees:-- incremental input parsers, processors and transformers---- Support for IO enumeratorsmoduleData.Iteratee.Base.ReadableChunk(ReadableChunk(..))whereimportPreludehiding(head,tail,dropWhile,length,splitAt)importqualifiedData.ByteStringasBimportqualifiedData.ByteString.LazyasLimportData.WordimportControl.Monad.IO.ClassimportForeign.CimportForeign.PtrimportForeign.StorableimportForeign.Marshal.Array-- |Class of streams which can be filled from a 'Ptr'. Typically these-- are streams which can be read from a file, @Handle@, or similar resource.----class(Storableel)=>ReadableChunksel|s->elwherereadFromPtr::MonadIOm=>Ptrel->Int-- ^ The pointer must not be used after @readFromPtr@ completes.->ms-- ^ The Int parameter is the length of the data in *bytes*.instanceReadableChunk[Char]CharwherereadFromPtrbufl=liftIO$peekCAStringLen(castPtrbuf,l)instanceReadableChunk[Word8]Word8wherereadFromPtrbufl=liftIO$peekArraylbufinstanceReadableChunk[Word16]Word16wherereadFromPtrbufl=liftIO$peekArraylbufinstanceReadableChunk[Word32]Word32wherereadFromPtrbufl=liftIO$peekArraylbufinstanceReadableChunk[Word]WordwherereadFromPtrbufl=liftIO$peekArraylbufinstanceReadableChunkB.ByteStringWord8wherereadFromPtrbufl=liftIO$B.packCStringLen(castPtrbuf,l)instanceReadableChunkL.ByteStringWord8wherereadFromPtrbufl=liftIO$return.L.fromChunks.(:[])=<<readFromPtrbufl