Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype CommonHighlightM r s e a = CommonHighlightM {
- unCommonHighlightM :: ReaderT r (StateT s (ExceptT e IO)) a
- runCommonHighlightM :: r -> s -> CommonHighlightM r s e a -> IO (Either e a)
- getIgnoreCaseM :: (HasIgnoreCase r, MonadReader r m) => m IgnoreCase
- getRecursiveM :: (HasRecursive r, MonadReader r m) => m Recursive
- getRawRegexM :: (HasRawRegex r, MonadReader r m) => m RawRegex
- getInputFilenamesM :: (HasInputFilenames r, MonadReader r m) => m [InputFilename]
- throwHighlightErr :: HighlightErr -> CommonHighlightM r s HighlightErr a
- throwRegexCompileErr :: RawRegex -> CommonHighlightM r s HighlightErr a
- compileHighlightRegexWithErr :: (HasIgnoreCase r, HasRawRegex r) => CommonHighlightM r s HighlightErr RE
- compileHighlightRegex :: IgnoreCase -> RawRegex -> Maybe RE
- module Highlight.Common.Monad.Input
- module Highlight.Common.Monad.Output
Documentation
newtype CommonHighlightM r s e a Source #
This is the common monad for both highlight
and hrep
. It has been
kept polymorphic here so it can be easily specialized by highlight
and
hrep
.
r
is the options or config type. s
is the state. e
is the error.
CommonHighlightM | |
|
MonadState s (CommonHighlightM r s e) Source # | |
MonadReader r (CommonHighlightM r s e) Source # | |
MonadError e (CommonHighlightM r s e) Source # | |
Monad (CommonHighlightM r s e) Source # | |
Functor (CommonHighlightM r s e) Source # | |
Applicative (CommonHighlightM r s e) Source # | |
MonadIO (CommonHighlightM r s e) Source # | |
runCommonHighlightM :: r -> s -> CommonHighlightM r s e a -> IO (Either e a) Source #
Given an r
and s
, run CommonHighlightM
.
getIgnoreCaseM :: (HasIgnoreCase r, MonadReader r m) => m IgnoreCase Source #
Get the IgnoreCase
option.
getRecursiveM :: (HasRecursive r, MonadReader r m) => m Recursive Source #
Get the Recursive
option.
getRawRegexM :: (HasRawRegex r, MonadReader r m) => m RawRegex Source #
Get the RawRegex
option.
getInputFilenamesM :: (HasInputFilenames r, MonadReader r m) => m [InputFilename] Source #
Get a list of the InputFilename
.
throwHighlightErr :: HighlightErr -> CommonHighlightM r s HighlightErr a Source #
Throw a HighlightErr
.
throwRegexCompileErr :: RawRegex -> CommonHighlightM r s HighlightErr a Source #
Throw a HighlightRegexCompileErr
.
compileHighlightRegexWithErr :: (HasIgnoreCase r, HasRawRegex r) => CommonHighlightM r s HighlightErr RE Source #
Call compileHighlightRegex
. Throw a HighlightErr
if the regex cannot
be compiled.
compileHighlightRegex :: IgnoreCase -> RawRegex -> Maybe RE Source #
Try compiling a RawRegex
into a RE
.
Setup for examples:
>>>
import Data.Maybe (isJust)
Return Just
for a proper regex:
>>>
isJust $ compileHighlightRegex IgnoreCase (RawRegex "good regex")
True
Return Nothing
for an improper regex:
>>>
isJust $ compileHighlightRegex IgnoreCase (RawRegex "bad regex (")
False
module Highlight.Common.Monad.Input