bitset-word8-0.1.1.1: Space efficient set of Word8 and some pre-canned sets useful for parsing HTTP

Copyright(c) Naoto Shimazaki 2017
LicenseMIT (see the file LICENSE)
Maintainerhttps://github.com/nshimaza
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.BitSetWord8

Contents

Description

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

Types

data BitSetWord8 Source #

Bitwise set of Word8. Space efficient backend and O(1) membership test.

Instances
Eq BitSetWord8 Source # 
Instance details

Defined in Data.BitSetWord8.Internal

Show BitSetWord8 Source # 
Instance details

Defined in Data.BitSetWord8.Internal

Lift BitSetWord8 Source # 
Instance details

Defined in Data.BitSetWord8.Internal

Methods

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 #

Convert given List of Char into packed bitwise set of Word64. Any Char having code point greater than 0xff is ignored.

member :: BitSetWord8 -> Word8 -> Bool Source #

O(1). Return True if given Word8 is a member of given BitSetWord8.