License | BSD-3-Clause |
---|---|
Maintainer | Jamie Willis |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Extensions |
|
This module contains the translation from user input type to the underlying parsley representation of it, as well as some miscellaneous functions for working with specific types of input (these do not appear in the rest of the machinery, but in Parsley.Internal.Backend.Machine.InputOps and potentially the generated code).
Since: 1.0.0.0
Synopsis
- type family Rep input where ...
- type family RepKind input where ...
- intSame :: Code Int# -> Code Int# -> Code Bool
- intLess :: Code Int# -> Code Int# -> Code Bool
- min# :: Int# -> Int# -> Int#
- max# :: Int# -> Int# -> Int#
- type OffWith ts = (# Int#, ts #)
- offWith :: Code ts -> Code (OffWith ts)
- offWithSame :: Code (OffWith ts) -> Code (OffWith ts) -> Code Bool
- offWithShiftRight :: Code (Int -> ts -> ts) -> Code (OffWith ts) -> Code Int# -> Code (OffWith ts)
- type UnpackedLazyByteString = (# Int#, Addr#, ForeignPtrContents, Int#, Int#, ByteString #)
- emptyUnpackedLazyByteString :: Code Int# -> Code UnpackedLazyByteString
- data Stream
- dropStream :: Int -> Stream -> Stream
- offsetText :: Code Text -> Code Int
- textShiftRight :: Text -> Int -> Text
- textShiftLeft :: Text -> Int -> Text
- byteStringShiftRight :: UnpackedLazyByteString -> Int# -> UnpackedLazyByteString
- byteStringShiftLeft :: UnpackedLazyByteString -> Int# -> UnpackedLazyByteString
Representation Type-Families
type family Rep input where ... Source #
This type family relates a user input type with the underlying parsley
representation, which is significantly more efficient to work with.
Most parts of the machine work with Rep
.
Since: 1.0.0.0
type family RepKind input where ... Source #
The representation type of an input Rep
, does not have to be a lifted type. To match a
representation of an input with the correct kind, this type family must be used.
Since: 1.0.0.0
RepKind [Char] = IntRep | |
RepKind (UArray Int Char) = IntRep | |
RepKind Text16 = IntRep | |
RepKind ByteString = IntRep | |
RepKind Text = LiftedRep | |
RepKind ByteString = 'TupleRep '[IntRep, AddrRep, LiftedRep, IntRep, IntRep, LiftedRep] | |
RepKind CharList = 'TupleRep '[IntRep, LiftedRep] | |
RepKind Stream = 'TupleRep '[IntRep, LiftedRep] |
Int#
Operations
intSame :: Code Int# -> Code Int# -> Code Bool Source #
Verifies that two Int#
s are equal.
Since: 1.0.0.0
intLess :: Code Int# -> Code Int# -> Code Bool Source #
Is the first argument is less than the second?
Since: 1.0.0.0
Offwith
Operations
type OffWith ts = (# Int#, ts #) Source #
This allows types like String
and Stream
to be manipulated
more efficiently by packaging them along with an offset which can
be used for quicker comparisons.
Since: 1.0.0.0
offWith :: Code ts -> Code (OffWith ts) Source #
Initialises an OffWith
type, with a starting offset of 0
.
Since: 1.0.0.0
offWithSame :: Code (OffWith ts) -> Code (OffWith ts) -> Code Bool Source #
Compares the bundled offsets of two OffWith
s are equal: does not
need to inspect the corresponding input.
Since: 1.0.0.0
:: Code (Int -> ts -> ts) | A |
-> Code (OffWith ts) | The |
-> Code Int# | How much to shift by. |
-> Code (OffWith ts) |
Shifts an OffWith
to the right, taking care to also drop tokens from the
companion input.
Since: 1.0.0.0
LazyByteString
Operations
type UnpackedLazyByteString = (# Int#, Addr#, ForeignPtrContents, Int#, Int#, ByteString #) Source #
This type unpacks lazy ByteString
s for efficiency.
Since: 1.0.0.0
emptyUnpackedLazyByteString :: Code Int# -> Code UnpackedLazyByteString Source #
Initialises an UnpackedLazyByteString
with a specified offset.
This offset varies as each lazy chunk is consumed.
Since: 1.0.0.0
Stream
Operations
An input type that represents an infinite stream of input characters.
Since: 0.1.0.0
Instances
Text
Operations
Crucial Exposed Functions
These functions must be exposed, since they can appear in the generated code.
textShiftLeft :: Text -> Int -> Text Source #
Rewinds input consumption on Text
where the input is still available (i.e. in the same chunk).
Since: 1.0.0.0
byteStringShiftRight :: UnpackedLazyByteString -> Int# -> UnpackedLazyByteString Source #
Drops tokens off of a lazy ByteString
.
Since: 1.0.0.0
byteStringShiftLeft :: UnpackedLazyByteString -> Int# -> UnpackedLazyByteString Source #
Rewinds input consumption on a lazy ByteString
if input is still available (within the same chunk).
Since: 1.0.0.0