Copyright | (c) Naoto Shimazaki 2017 |
---|---|
License | MIT (see the file LICENSE) |
Maintainer | https://github.com/nshimaza |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Space efficient set of Word8
and some pre-canned sets useful for parsing HTTP related ByteString
.
This packaged is intended to provide O(1) membership test on any subset of ASCII and Latin-1 character set
in order to write efficient HTTP related parser.
Creating your own set
You can create your own set by fromList
.
myCharSet :: BitSetWord8 myCharSet = fromList [Y
,y
,N
,n
]
You can create pre-evaluated set using Template Haskell.
import Language.Haskell.TH.Syntax (Lift, lift) myPreEvaluatedCharSet :: BitSetWord8 myPreEvaluatedCharSet = $(lift myCharSet)
Example Usage
import Data.Attoparsec.ByteString -- | Parse RFC7230 token. token :: Parser ByteString token = takeWhile1 (member rfc7230TChar)
Synopsis
- data BitSetWord8
- rfc3986UriReference :: BitSetWord8
- rfc7230TChar :: BitSetWord8
- rfc7230QDText :: BitSetWord8
- rfc7230QuotedPair :: BitSetWord8
- rfc3986UriReference' :: [Char]
- rfc7230QDText' :: [Char]
- rfc7230QuotedPair' :: [Char]
- rfc5234Digit' :: [Char]
- rfc2616UpAlpha' :: [Char]
- rfc2616LoAlpha' :: [Char]
- rfc5234Alpha' :: [Char]
- rfc5234HexDig' :: [Char]
- rfc5234VChar' :: [Char]
- rfc5324Wsp' :: [Char]
- rfc3986SubDelims' :: [Char]
- rfc3986GenDelims' :: [Char]
- rfc3986Reserved' :: [Char]
- rfc3986Unreserved' :: [Char]
- rfc3986PctEncodedChar' :: [Char]
- rfc3986PChar' :: [Char]
- rfc7230TChar' :: [Char]
- rfc7230ObsText' :: [Char]
- fromList :: [Char] -> BitSetWord8
- member :: BitSetWord8 -> Word8 -> Bool
Types
data BitSetWord8 Source #
Bitwise set of Word8. Space efficient backend and O(1) membership test.
Instances
Eq BitSetWord8 Source # | |
Defined in Data.BitSetWord8.Internal (==) :: BitSetWord8 -> BitSetWord8 -> Bool # (/=) :: BitSetWord8 -> BitSetWord8 -> Bool # | |
Show BitSetWord8 Source # | |
Defined in Data.BitSetWord8.Internal showsPrec :: Int -> BitSetWord8 -> ShowS # show :: BitSetWord8 -> String # showList :: [BitSetWord8] -> ShowS # | |
Lift BitSetWord8 Source # | |
Defined in Data.BitSetWord8.Internal lift :: BitSetWord8 -> Q Exp # |
Useful charset constants in BitSetWord8
rfc3986UriReference :: BitSetWord8 Source #
URI-Reference of RFC3986 in BitSetWord8. Evaluated at compile time.
rfc7230TChar :: BitSetWord8 Source #
tcher of RFC7230 in BitSetWord8. Evaluated at compile time.
rfc7230QDText :: BitSetWord8 Source #
qdtext of RFC7230 in BitSetWord8. Evaluated at compile time.
rfc7230QuotedPair :: BitSetWord8 Source #
quoted-string of RFC7230 in BitSetWord8. Evaluated at compile time.
Source Constants
rfc3986UriReference' :: [Char] Source #
URI-Reference of RFC3986 in Char
list.
rfc7230QDText' :: [Char] Source #
qdtext of RFC7230 in Char
list.
rfc7230QuotedPair' :: [Char] Source #
quoted-pair of RFC7230 in Char
list.
rfc5234Digit' :: [Char] Source #
DIGIT of RFC5324 in Char
list.
rfc2616UpAlpha' :: [Char] Source #
UPALPHA of RFC2616 in Char
list.
Note that RFC2616 has been obsoleted by RFC7230 and RFC7230 doesn't define UPALPHA.
rfc2616LoAlpha' :: [Char] Source #
LOALPHA of RFC2616 in Char
list.
Note that RFC2616 has been obsoleted by RFC7230 and RFC7230 doesn't define LOALPHA.
rfc5234Alpha' :: [Char] Source #
ALPHA of RFC5324 in Char
list.
rfc5234HexDig' :: [Char] Source #
HEXDIG of RFC5324 in Char
list.
rfc5234VChar' :: [Char] Source #
VCHAR of RFC5324 in Char
list.
rfc5324Wsp' :: [Char] Source #
WSP (aka white space) of RFC5324 in Char
list.
rfc3986SubDelims' :: [Char] Source #
sub-delim of RFC3986 in Char
list.
rfc3986GenDelims' :: [Char] Source #
gen-delim of RFC3986 in Char
list.
rfc3986Reserved' :: [Char] Source #
reserved of RFC3986 in Char
list.
rfc3986Unreserved' :: [Char] Source #
unreserved of RFC3986 in Char
list.
rfc3986PctEncodedChar' :: [Char] Source #
pct-encoded of RFC3986 in Char
list.
rfc3986PChar' :: [Char] Source #
pchar of RFC3986 in Char
list.
rfc7230TChar' :: [Char] Source #
tchar of RFC7230 in Char
list.
rfc7230ObsText' :: [Char] Source #
obs-text of RFC7230 in Char
list.
Functions
fromList :: [Char] -> BitSetWord8 Source #
member :: BitSetWord8 -> Word8 -> Bool Source #
O(1). Return True
if given Word8
is a member of given BitSetWord8
.