-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Types that can only be constructed if they match a regular expression -- -- Provides tooling for working with types whose values must match a -- regular expression provided in the type. @package regex-wrapper @version 0.1.0.0 module Text.Regex.Wrapper -- | A wrapper type that can only be constructed if the underlying string -- type matches the regular expression in pat. data Matched str (pat :: Symbol) -- | Convert a str into a Matched str pat if -- possible. parseMatched :: forall str pat. (KnownSymbol pat, RegexLike Regex str) => str -> Maybe (Matched str pat) -- | Same as parseMatched but provides a slightly helpful -- error message on failure. This requires that your str type is -- an instance of Show. parseMatchedEither :: forall pat str. (Show str, KnownSymbol pat, RegexLike Regex str) => str -> Either (RegexError str) (Matched str pat) -- | Like parseMatchedEither except that it calls -- fail instead. parseMatchedM :: forall pat str m. (KnownSymbol pat, RegexLike Regex str, MonadFail m, Show str) => str -> m (Matched str pat) -- | Extract the wrapped str type. asStr :: Matched str pat -> str -- | Same as asStr but with a fixed type. asText :: Matched Text p -> Text -- | Same as asStr but with a fixed type. asString :: Matched String p -> String -- | Same as asStr but with a fixed type. asByteString :: Matched ByteString p -> ByteString -- | 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. compile :: forall pat m. KnownSymbol pat => Either String (RegexPat pat) -- | Use a precompiled Regex to create -- Matched values. parseMatchedWith :: RegexLike Regex str => RegexPat pat -> str -> Maybe (Matched str pat) -- | Like parseMatchedWith, but calls returns a useful -- error message. parseMatchedEitherWith :: forall pat str m. (RegexLike Regex str, Show str, KnownSymbol pat) => RegexPat pat -> str -> Either (MatchError str) (Matched str pat) -- | A compiled regular expression that can produce Matched str -- pat values. data RegexPat (pat :: Symbol) instance Data.CaseInsensitive.Internal.FoldCase str => Data.CaseInsensitive.Internal.FoldCase (Text.Regex.Wrapper.Matched str pat) instance Data.Hashable.Class.Hashable str => Data.Hashable.Class.Hashable (Text.Regex.Wrapper.Matched str pat) instance GHC.Classes.Ord str => GHC.Classes.Ord (Text.Regex.Wrapper.Matched str pat) instance GHC.Classes.Eq str => GHC.Classes.Eq (Text.Regex.Wrapper.Matched str pat) instance GHC.Show.Show str => GHC.Show.Show (Text.Regex.Wrapper.Matched str pat) instance GHC.Show.Show str => GHC.Show.Show (Text.Regex.Wrapper.RegexError str) instance GHC.Show.Show str => GHC.Show.Show (Text.Regex.Wrapper.MatchError str) instance (GHC.TypeLits.KnownSymbol pat, Text.Regex.Base.RegexLike.RegexLike Text.Regex.TDFA.Common.Regex str, GHC.Read.Read str) => GHC.Read.Read (Text.Regex.Wrapper.Matched str pat) instance Data.Aeson.Types.ToJSON.ToJSON str => Data.Aeson.Types.ToJSON.ToJSON (Text.Regex.Wrapper.Matched str pat) instance (GHC.TypeLits.KnownSymbol pat, GHC.Show.Show str, Data.Aeson.Types.FromJSON.FromJSON str, Text.Regex.Base.RegexLike.RegexLike Text.Regex.TDFA.Common.Regex str) => Data.Aeson.Types.FromJSON.FromJSON (Text.Regex.Wrapper.Matched str pat)