-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Binary utilities for the machines library -- -- Binary utilities for the machines library @package machines-binary @version 7.0.0.0 module Data.Binary.Machine -- | Construct a Plan that run a Get until it fails or it return a -- parsed result. This plan automatically manages the pushback of unused -- input. -- -- You can use this function to construct a machine and run a Get -- on the provided input. With stack you can convert the created -- machine to a normal machine -- --
-- -- construct the machine -- myMachine :: Machine (Stack ByteString) (Either DecodingError Word8) -- myMachine = construct $ processGet getWord8 -- -- -- run the machine -- run $ stack (source ["abc", "d", "efgh"]) myMachine ---- -- You can combine machines created in this way with the facilities -- provided by the machines package. -- --
-- --run m2 after m1 -- myMachine = m1 <> m2 -- where -- m1 = construct $ processGet (getByteString 5) -- m2 = construct $ processGet (getByteString 1) -- -- run $ stack (source ["abc", "d", "efgh"]) myMachine -- > [Right "abcde",Right "f"] --processGet :: Get a -> Plan (Stack ByteString) (Either DecodingError a) () -- | Same as processGet with additional information about the number -- of bytes consumed by the Get processGetL :: Get a -> Plan (Stack ByteString) (Either DecodingError (ByteOffset, a)) () -- | Run a Get multiple times and stream its results -- --
-- run $ source ["abc", "d", "efgh"] ~> streamGet (getByteString 2) -- > [Right "ab",Right "cd",Right "ef",Right "gh"] --streamGet :: Get a -> Process ByteString (Either DecodingError a) -- | Same as streamGet with additional information about the number -- of bytes consumed by the Get streamGetL :: Get a -> Process ByteString (Either DecodingError (ByteOffset, a)) -- | Encode evrery input object with a Put processPut :: Monad m => (a -> Put) -> ProcessT m a ByteString -- | A Get decoding error. data DecodingError DecodingError :: {-# UNPACK #-} !ByteOffset -> !String -> DecodingError -- | Number of bytes consumed before the error [deConsumed] :: DecodingError -> {-# UNPACK #-} !ByteOffset -- | Error message [deMessage] :: DecodingError -> !String instance GHC.Classes.Eq Data.Binary.Machine.DecodingError instance GHC.Read.Read Data.Binary.Machine.DecodingError instance GHC.Show.Show Data.Binary.Machine.DecodingError