regex-wrapper-0.1.0.0: Types that can only be constructed if they match a regular expression

Safe HaskellNone
LanguageHaskell2010

Text.Regex.Wrapper

Synopsis

Documentation

data Matched str (pat :: Symbol) Source #

A wrapper type that can only be constructed if the underlying string type matches the regular expression in pat.

Instances
Eq str => Eq (Matched str pat) Source # 
Instance details

Defined in Text.Regex.Wrapper

Methods

(==) :: Matched str pat -> Matched str pat -> Bool #

(/=) :: Matched str pat -> Matched str pat -> Bool #

Ord str => Ord (Matched str pat) Source # 
Instance details

Defined in Text.Regex.Wrapper

Methods

compare :: Matched str pat -> Matched str pat -> Ordering #

(<) :: Matched str pat -> Matched str pat -> Bool #

(<=) :: Matched str pat -> Matched str pat -> Bool #

(>) :: Matched str pat -> Matched str pat -> Bool #

(>=) :: Matched str pat -> Matched str pat -> Bool #

max :: Matched str pat -> Matched str pat -> Matched str pat #

min :: Matched str pat -> Matched str pat -> Matched str pat #

(KnownSymbol pat, RegexLike Regex str, Read str) => Read (Matched str pat) Source # 
Instance details

Defined in Text.Regex.Wrapper

Methods

readsPrec :: Int -> ReadS (Matched str pat) #

readList :: ReadS [Matched str pat] #

readPrec :: ReadPrec (Matched str pat) #

readListPrec :: ReadPrec [Matched str pat] #

Show str => Show (Matched str pat) Source # 
Instance details

Defined in Text.Regex.Wrapper

Methods

showsPrec :: Int -> Matched str pat -> ShowS #

show :: Matched str pat -> String #

showList :: [Matched str pat] -> ShowS #

Hashable str => Hashable (Matched str pat) Source # 
Instance details

Defined in Text.Regex.Wrapper

Methods

hashWithSalt :: Int -> Matched str pat -> Int

hash :: Matched str pat -> Int

(KnownSymbol pat, Show str, FromJSON str, RegexLike Regex str) => FromJSON (Matched str pat) Source # 
Instance details

Defined in Text.Regex.Wrapper

Methods

parseJSON :: Value -> Parser (Matched str pat)

parseJSONList :: Value -> Parser [Matched str pat]

ToJSON str => ToJSON (Matched str pat) Source # 
Instance details

Defined in Text.Regex.Wrapper

Methods

toJSON :: Matched str pat -> Value

toEncoding :: Matched str pat -> Encoding

toJSONList :: [Matched str pat] -> Value

toEncodingList :: [Matched str pat] -> Encoding

FoldCase str => FoldCase (Matched str pat) Source # 
Instance details

Defined in Text.Regex.Wrapper

Methods

foldCase :: Matched str pat -> Matched str pat

foldCaseList :: [Matched str pat] -> [Matched str pat]

parseMatched :: forall str pat. (KnownSymbol pat, RegexLike Regex str) => str -> Maybe (Matched str pat) Source #

Convert a str into a Matched str pat if possible.

parseMatchedEither :: forall pat str. (Show str, KnownSymbol pat, RegexLike Regex str) => str -> Either (RegexError str) (Matched str pat) Source #

Same as parseMatched but provides a slightly helpful error message on failure. This requires that your str type is an instance of Show.

parseMatchedM :: forall pat str m. (KnownSymbol pat, RegexLike Regex str, MonadFail m, Show str) => str -> m (Matched str pat) Source #

Like parseMatchedEither except that it calls fail instead.

asStr :: Matched str pat -> str Source #

Extract the wrapped str type.

asText :: Matched Text p -> Text Source #

Same as asStr but with a fixed type.

asString :: Matched String p -> String Source #

Same as asStr but with a fixed type.

asByteString :: Matched ByteString p -> ByteString Source #

Same as asStr but with a fixed type.

compile :: forall pat m. KnownSymbol pat => Either String (RegexPat pat) Source #

Create a Regex that can be used to construct Matched values when used with parseMatchedWith. This allows you to compile the pattern once, and use it multiple times.

parseMatchedWith :: RegexLike Regex str => RegexPat pat -> str -> Maybe (Matched str pat) Source #

Use a precompiled Regex to create Matched values.

parseMatchedEitherWith :: forall pat str m. (RegexLike Regex str, Show str, KnownSymbol pat) => RegexPat pat -> str -> Either (MatchError str) (Matched str pat) Source #

Like parseMatchedWith, but calls returns a useful error message.

data RegexPat (pat :: Symbol) Source #

A compiled regular expression that can produce Matched str pat values.