-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Command line tool for highlighting parts of files matching a regex. -- -- Please see README.md. @package highlight @version 1.0.0.2 module Highlight.Common.Color -- | Find the corresponding color for the number in allColorsList, -- taking the mod of the Int. -- --
--   >>> colorForFileNumber 0
--   "\ESC[1m\ESC[94m"
--   
--   >>> colorForFileNumber 1
--   "\ESC[1m\ESC[92m"
--   
--   >>> colorForFileNumber 4
--   "\ESC[1m\ESC[94m"
--   
colorForFileNumber :: Int -> ByteString -- | allColorsList turned into an IntMap for faster lookup. allColorsMap :: IntMap ByteString -- | length of allColorsList. allColorsLength :: Int -- | List of all the colors that are used for highlighting filenames. allColorsList :: [ByteString] colorVividBlackBold :: ByteString colorVividBlueBold :: ByteString colorVividCyanBold :: ByteString colorVividGreenBold :: ByteString colorVividMagentaBold :: ByteString colorVividRedBold :: ByteString colorVividWhiteBold :: ByteString colorVividYellowBold :: ByteString colorDullBlackBold :: ByteString colorDullBlueBold :: ByteString colorDullCyanBold :: ByteString colorDullGreenBold :: ByteString colorDullMagentaBold :: ByteString colorDullRedBold :: ByteString colorDullWhiteBold :: ByteString colorDullYellowBold :: ByteString colorVividBlack :: ByteString colorVividBlue :: ByteString colorVividCyan :: ByteString colorVividGreen :: ByteString colorVividMagenta :: ByteString colorVividRed :: ByteString colorVividWhite :: ByteString colorVividYellow :: ByteString colorDullBlack :: ByteString colorDullBlue :: ByteString colorDullCyan :: ByteString colorDullGreen :: ByteString colorDullMagenta :: ByteString colorDullRed :: ByteString colorDullWhite :: ByteString colorDullYellow :: ByteString -- | Change the intensity to BoldIntensity. colorBold :: ByteString -- | Reset the console color back to normal. colorReset :: ByteString -- | Empty string. colorNull :: ByteString -- | Helper for creating a ByteString for an ANSI escape sequence -- color based on a ColorIntensity and a Color. colorHelper :: ColorIntensity -> Color -> ByteString -- | Convert a list of SGR to a ByteString. setSGRCodeBuilder :: [SGR] -> ByteString module Highlight.Common.Options -- | Whether or not the case of a regular expression should be ignored. -- Similar to grep's --ignore-case option. data IgnoreCase IgnoreCase :: IgnoreCase DoNotIgnoreCase :: IgnoreCase class HasIgnoreCase r ignoreCaseLens :: HasIgnoreCase r => Lens' r IgnoreCase ignoreCaseLens :: (HasIgnoreCase r, HasCommonOptions r) => Lens' r IgnoreCase ignoreCaseParser :: Parser IgnoreCase -- | Whether or not files should be searched recursively. Similar to -- grep's --recursive option. data Recursive Recursive :: Recursive NotRecursive :: Recursive class HasRecursive r recursiveLens :: HasRecursive r => Lens' r Recursive recursiveLens :: (HasRecursive r, HasCommonOptions r) => Lens' r Recursive recursiveParser :: Parser Recursive -- | The raw, pre-compiled regular expression passed in on the command line -- by the user. newtype RawRegex RawRegex :: String -> RawRegex [unRawRegex] :: RawRegex -> String class HasRawRegex r rawRegexLens :: HasRawRegex r => Lens' r RawRegex rawRegexLens :: (HasRawRegex r, HasCommonOptions r) => Lens' r RawRegex rawRegexParser :: Parser RawRegex -- | An input file passed in on the command line by the user. newtype InputFilename InputFilename :: FilePath -> InputFilename [unInputFilename] :: InputFilename -> FilePath class HasInputFilenames r inputFilenamesLens :: HasInputFilenames r => Lens' r [InputFilename] inputFilenamesLens :: (HasInputFilenames r, HasCommonOptions r) => Lens' r [InputFilename] inputFilenamesParser :: Parser [InputFilename] -- | A set of options that are common to both the highlight and -- hrep applications. data CommonOptions CommonOptions :: IgnoreCase -> Recursive -> RawRegex -> [InputFilename] -> CommonOptions [commonOptionsIgnoreCase] :: CommonOptions -> IgnoreCase [commonOptionsRecursive] :: CommonOptions -> Recursive [commonOptionsRawRegex] :: CommonOptions -> RawRegex [commonOptionsInputFilenames] :: CommonOptions -> [InputFilename] class HasCommonOptions r commonOptionsLens :: HasCommonOptions r => Lens' r CommonOptions commonOptionsParser :: Parser CommonOptions -- | A default set of CommonOptions. Defined as the following: -- --
--   >>> :{
--   let opts =
--         CommonOptions
--           { commonOptionsIgnoreCase = DoNotIgnoreCase
--           , commonOptionsRecursive = NotRecursive
--           , commonOptionsRawRegex = RawRegex { unRawRegex = "" }
--           , commonOptionsInputFilenames = []
--           }
--   :}
--   
-- --
--   >>> opts == defaultCommonOptions
--   True
--   
defaultCommonOptions :: CommonOptions instance GHC.Show.Show Highlight.Common.Options.IgnoreCase instance GHC.Read.Read Highlight.Common.Options.IgnoreCase instance GHC.Classes.Eq Highlight.Common.Options.IgnoreCase instance GHC.Show.Show Highlight.Common.Options.Recursive instance GHC.Read.Read Highlight.Common.Options.Recursive instance GHC.Classes.Eq Highlight.Common.Options.Recursive instance GHC.Show.Show Highlight.Common.Options.RawRegex instance GHC.Read.Read Highlight.Common.Options.RawRegex instance Data.String.IsString Highlight.Common.Options.RawRegex instance GHC.Classes.Eq Highlight.Common.Options.RawRegex instance GHC.Show.Show Highlight.Common.Options.InputFilename instance GHC.Read.Read Highlight.Common.Options.InputFilename instance Data.String.IsString Highlight.Common.Options.InputFilename instance GHC.Classes.Eq Highlight.Common.Options.InputFilename instance GHC.Show.Show Highlight.Common.Options.CommonOptions instance GHC.Read.Read Highlight.Common.Options.CommonOptions instance GHC.Classes.Eq Highlight.Common.Options.CommonOptions instance Highlight.Common.Options.HasIgnoreCase Highlight.Common.Options.CommonOptions instance Highlight.Common.Options.HasRecursive Highlight.Common.Options.CommonOptions instance Highlight.Common.Options.HasRawRegex Highlight.Common.Options.CommonOptions instance Highlight.Common.Options.HasInputFilenames Highlight.Common.Options.CommonOptions instance Highlight.Common.Options.HasCommonOptions Highlight.Common.Options.CommonOptions module Highlight.Highlight.Options -- | Whether or not to color filenames output by grep when reading -- in from stdin. data ColorGrepFilenames ColorGrepFilenames :: ColorGrepFilenames DoNotColorGrepFileNames :: ColorGrepFilenames colorGrepFilenamesParser :: Parser ColorGrepFilenames class HasColorGrepFilenames r colorGrepFilenamesLens :: HasColorGrepFilenames r => Lens' r ColorGrepFilenames data Options Options :: ColorGrepFilenames -> CommonOptions -> Options [optionsColorGrepFilenames] :: Options -> ColorGrepFilenames [optionsCommonOptions] :: Options -> CommonOptions defaultOptions :: Options optionsParser :: Parser Options class HasOptions r optionsLens :: HasOptions r => Lens' r Options class HasCommonOptions r commonOptionsLens :: HasCommonOptions r => Lens' r CommonOptions -- | A set of options that are common to both the highlight and -- hrep applications. data CommonOptions class HasInputFilenames r inputFilenamesLens :: HasInputFilenames r => Lens' r [InputFilename] inputFilenamesLens :: (HasInputFilenames r, HasCommonOptions r) => Lens' r [InputFilename] -- | An input file passed in on the command line by the user. newtype InputFilename InputFilename :: FilePath -> InputFilename [unInputFilename] :: InputFilename -> FilePath class HasRawRegex r rawRegexLens :: HasRawRegex r => Lens' r RawRegex rawRegexLens :: (HasRawRegex r, HasCommonOptions r) => Lens' r RawRegex -- | The raw, pre-compiled regular expression passed in on the command line -- by the user. newtype RawRegex RawRegex :: String -> RawRegex class HasRecursive r recursiveLens :: HasRecursive r => Lens' r Recursive recursiveLens :: (HasRecursive r, HasCommonOptions r) => Lens' r Recursive -- | Whether or not files should be searched recursively. Similar to -- grep's --recursive option. data Recursive Recursive :: Recursive class HasIgnoreCase r ignoreCaseLens :: HasIgnoreCase r => Lens' r IgnoreCase ignoreCaseLens :: (HasIgnoreCase r, HasCommonOptions r) => Lens' r IgnoreCase -- | Whether or not the case of a regular expression should be ignored. -- Similar to grep's --ignore-case option. data IgnoreCase IgnoreCase :: IgnoreCase DoNotIgnoreCase :: IgnoreCase commonOptionsParser :: Parser CommonOptions -- | A default set of CommonOptions. Defined as the following: -- --
--   >>> :{
--   let opts =
--         CommonOptions
--           { commonOptionsIgnoreCase = DoNotIgnoreCase
--           , commonOptionsRecursive = NotRecursive
--           , commonOptionsRawRegex = RawRegex { unRawRegex = "" }
--           , commonOptionsInputFilenames = []
--           }
--   :}
--   
-- --
--   >>> opts == defaultCommonOptions
--   True
--   
defaultCommonOptions :: CommonOptions instance GHC.Show.Show Highlight.Highlight.Options.ColorGrepFilenames instance GHC.Read.Read Highlight.Highlight.Options.ColorGrepFilenames instance GHC.Classes.Eq Highlight.Highlight.Options.ColorGrepFilenames instance GHC.Show.Show Highlight.Highlight.Options.Options instance GHC.Read.Read Highlight.Highlight.Options.Options instance GHC.Classes.Eq Highlight.Highlight.Options.Options instance Highlight.Highlight.Options.HasOptions Highlight.Highlight.Options.Options instance Highlight.Highlight.Options.HasColorGrepFilenames Highlight.Highlight.Options.Options instance Highlight.Common.Options.HasCommonOptions Highlight.Highlight.Options.Options instance Highlight.Common.Options.HasIgnoreCase Highlight.Highlight.Options.Options instance Highlight.Common.Options.HasRecursive Highlight.Highlight.Options.Options instance Highlight.Common.Options.HasRawRegex Highlight.Highlight.Options.Options instance Highlight.Common.Options.HasInputFilenames Highlight.Highlight.Options.Options module Highlight.Util -- | Convert a String to a ByteString with the encoding for -- the current locale. -- --
--   >>> convertStringToRawByteString "hello"
--   "hello"
--   
convertStringToRawByteString :: MonadIO m => String -> m ByteString -- | Open a FilePath in ReadMode. -- -- On success, return a Right Handle: -- --
--   >>> openFilePathForReading "README.md"
--   Right {handle: README.md}
--   
-- -- On error, return a Left IOException: -- --
--   >>> openFilePathForReading "thisfiledoesntexist"
--   Left thisfiledoesntexist: openBinaryFile: does not exist ...
--   
openFilePathForReading :: MonadIO m => FilePath -> m (Either IOException Handle) -- | Combine values in two Applicatives with <>. -- --
--   >>> combineApplicatives (Just "hello") (Just " world")
--   Just "hello world"
--   
-- --
--   >>> combineApplicatives (Just "hello") Nothing
--   Nothing
--   
combineApplicatives :: (Applicative f, Semigroup a) => f a -> f a -> f a -- | Handle an IOException that occurs when reading from a -- Handle. Check if the IOException is an EOF exception -- (hIsEOF). If so, then just close the Handle. Otherwise, -- throw the IOException that is passed in. closeHandleIfEOFOrThrow :: MonadIO m => Handle -> IOException -> m () -- | Call exitWith with ExitFailure -- --
--   >>> die 10 "message"
--   ERROR: message
--   *** Exception: ExitFailure 10
--   
die :: Int -> String -> IO a -- | Perform an action when a list is non-null. -- --
--   >>> whenNonNull [1,2,3] $ putStrLn "hello"
--   hello
--   
--   >>> whenNonNull [] $ putStrLn "bye"
--   
whenNonNull :: Monad m => [a] -> m () -> m () -- | A variant of modify in which the computation is strict in the -- new state. -- -- -- -- This is used because modify' is not available in the -- tranformers-0.3.0.0 package. modify' :: MonadState s m => (s -> s) -> m () module Highlight.Pipes -- | Read input from a Handle, split it into lines, and return each -- of those lines as a ByteString in a Producer. -- -- This function will close the Handle if the end of the file is -- reached. However, if an error was thrown while reading input from the -- Handle, the Handle is not closed. -- -- Setup for examples: -- --
--   >>> import Pipes.Prelude (toListM)
--   
--   >>> import System.IO (IOMode(ReadMode), openBinaryFile)
--   
--   >>> let goodFilePath = "test/golden/test-files/file2"
--   
-- -- Examples: -- --
--   >>> handle <- openBinaryFile goodFilePath ReadMode
--   
--   >>> fmap head . toListM $ fromHandleLines handle
--   "Proud Pour is a wine company that funds solutions to local environmental"
--   
fromHandleLines :: forall m. MonadIO m => Handle -> Producer' ByteString m () -- | Call fromHandleLines on stdin. stdinLines :: forall m. MonadIO m => Producer' ByteString m () -- | Try calling fromHandleLines on the Handle obtained from -- openFilePathForReading. -- -- Setup for examples: -- --
--   >>> import Pipes (Producer)
--   
--   >>> import Pipes.Prelude (toListM)
--   
-- --
--   >>> let t a = a :: IO (Either IOException (Producer ByteString IO ()))
--   
--   >>> let goodFilePath = "test/golden/test-files/file2"
--   
--   >>> let badFilePath = "thisfiledoesnotexist"
--   
--   >>> let handleErr err = error $ "got following error: " `mappend` show err
--   
-- -- Example: -- --
--   >>> eitherProducer <- t $ fromFileLines goodFilePath
--   
--   >>> let producer = either handleErr id eitherProducer
--   
--   >>> fmap head $ toListM producer
--   "Proud Pour is a wine company that funds solutions to local environmental"
--   
-- -- Returns IOException if there was an error when opening the -- file. -- --
--   >>> eitherProducer <- t $ fromFileLines badFilePath
--   
--   >>> either print (const $ return ()) eitherProducer
--   thisfiledoesnotexist: openBinaryFile: does not exist ...
--   
fromFileLines :: forall m n x' x. (MonadIO m, MonadIO n) => FilePath -> m (Either IOException (Proxy x' x () ByteString n ())) -- | Output ByteStrings to stderr. -- -- If an ePIPE error is thrown, then just return -- (). If any other error is thrown, rethrow the error. -- -- Setup for examples: -- --
--   >>> :set -XOverloadedStrings
--   
--   >>> import Pipes ((>->), runEffect)
--   
-- -- Example: -- --
--   >>> runEffect $ yield "hello" >-> stderrConsumer
--   hello
--   
stderrConsumer :: forall m. MonadIO m => Consumer' ByteString m () -- | Select all immediate children of the given directory, ignoring -- "." and "..". -- -- Throws an IOException if the directory is not readable or (on -- Windows) if the directory is actually a reparse point. -- -- Setup for examples: -- --
--   >>> import Data.List (sort)
--   
--   >>> import Pipes.Prelude (toListM)
--   
-- -- Examples: -- --
--   >>> fmap (head . sort) . toListM $ childOf "test/golden/test-files"
--   "test/golden/test-files/dir1"
--   
-- -- TODO: This could be rewritten to be faster by using the Windows- and -- Linux-specific functions to only read one file from a directory at a -- time like the actual childOf function. childOf :: MonadIO m => FilePath -> Producer' FilePath m () module Highlight.Common.Monad.Input -- | Place where a file originally came from. data FileOrigin -- | File was specified on the command line by the user. FileSpecifiedByUser :: FilePath -> FileOrigin -- | File was found recursively (not directly specified by the user). FileFoundRecursively :: FilePath -> FileOrigin -- | Standard input. It was either specified on the command line as -- -, or used as default because the user did not specify any -- files. Stdin :: FileOrigin -- | This is used in two different places. -- -- One is in fileListProducer, where a becomes -- Handle. This represents a single file that has been opened. -- FileReaderSuccess contains the FileOrigin and the -- Handle. FileReaderErr contains the FileOrigin and -- any errors that occurred when trying to open the Handle. -- -- The other is in fileReaderHandleToLine and InputData, -- where a becomes ByteString. This represents a single -- ByteString line from a file, or an error that occurred when -- trying to read the file. -- -- FileReader is usually wrapped in a Producer. This is a -- stream of either Handles or ByteString lines (with any -- errors that have occurred). data FileReader a FileReaderSuccess :: !FileOrigin -> !a -> FileReader a FileReaderErr :: !FileOrigin -> !IOException -> !Maybe IOException -> FileReader a -- | Get a FileOrigin from a FileReader. -- --
--   >>> let fileOrigin1 = FileSpecifiedByUser "hello.txt"
--   
--   >>> let fileReader1 = FileReaderSuccess fileOrigin1 "some line"
--   
--   >>> getFileOriginFromFileReader fileReader1
--   FileSpecifiedByUser "hello.txt"
--   
-- --
--   >>> let fileOrigin2 = FileFoundRecursively "bye.txt"
--   
--   >>> let fileReader2 = FileReaderErr fileOrigin2 (userError "err") Nothing
--   
--   >>> getFileOriginFromFileReader fileReader2
--   FileFoundRecursively "bye.txt"
--   
getFileOriginFromFileReader :: FileReader a -> FileOrigin -- | This is just getFilePathFromFileOrigin . -- getFileOriginFromFileReader. -- --
--   >>> let fileOrigin1 = Stdin
--   
--   >>> let fileReader1 = FileReaderSuccess fileOrigin1 "some line"
--   
--   >>> getFilePathFromFileReader fileReader1
--   Nothing
--   
-- --
--   >>> let fileOrigin2 = FileFoundRecursively "bye.txt"
--   
--   >>> let fileReader2 = FileReaderErr fileOrigin2 (userError "err") Nothing
--   
--   >>> getFilePathFromFileReader fileReader2
--   Just "bye.txt"
--   
getFilePathFromFileReader :: FileReader a -> Maybe FilePath -- | This wraps up two pieces of information. -- -- One is the value of FilenameHandlingFromFiles. This signals as -- to whether or not we need to print the filename when printing each -- line of output. -- -- This other is a Producer of FileReader -- ByteStrings. This is a Producer for each line of each -- input file. -- -- The main job of this module is to define createInputData, which -- produces InputData. InputData is what is processed to -- figure out what to output. data InputData m a InputData :: !FilenameHandlingFromFiles -> !Producer (FileReader ByteString) m a -> InputData m a -- | Create InputData based InputFilename list. -- -- Setup for examples: -- --
--   >>> :set -XOverloadedStrings
--   
--   >>> import Highlight.Common.Options (InputFilename(InputFilename))
--   
--   >>> import Highlight.Common.Options (Recursive(NotRecursive))
--   
-- -- If the InputFilename list is empty, just create an -- InputData with NoFilename and the standard input -- Producer passed in. -- --
--   >>> let stdinProd = yield ("hello" :: ByteString)
--   
--   >>> let create = createInputData NotRecursive [] stdinProd
--   
--   >>> InputData NoFilename prod <- create
--   
--   >>> toListM prod
--   [FileReaderSuccess Stdin "hello"]
--   
-- -- If the InputFilename list is not empty, create an -- InputData with lines from each file found on the command line. -- --
--   >>> let inFiles = [InputFilename "test/golden/test-files/file1"]
--   
--   >>> let create = createInputData NotRecursive inFiles stdinProd
--   
--   >>> InputData NoFilename prod <- create
--   
--   >>> Pipes.head prod
--   Just (FileReaderSuccess (FileSpecifiedByUser "test/golden/test-files/file1") "The...")
--   
createInputData :: forall m. MonadIO m => Recursive -> [InputFilename] -> Producer ByteString m () -> m (InputData m ()) -- | This data type specifies how printing filenames will be handled, along -- with the computeFilenameHandlingFromFiles function. data FilenameHandlingFromFiles -- | Do not print the filename on stdout. NoFilename :: FilenameHandlingFromFiles -- | Print the filename on stdout. PrintFilename :: FilenameHandlingFromFiles instance GHC.Show.Show Highlight.Common.Monad.Input.FileOrigin instance GHC.Read.Read Highlight.Common.Monad.Input.FileOrigin instance GHC.Classes.Eq Highlight.Common.Monad.Input.FileOrigin instance GHC.Show.Show a => GHC.Show.Show (Highlight.Common.Monad.Input.FileReader a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Highlight.Common.Monad.Input.FileReader a) instance GHC.Show.Show Highlight.Common.Monad.Input.FilenameHandlingFromFiles instance GHC.Read.Read Highlight.Common.Monad.Input.FilenameHandlingFromFiles instance GHC.Classes.Eq Highlight.Common.Monad.Input.FilenameHandlingFromFiles module Highlight.Common.Monad.Output -- | Sum-type to represent where a given ByteString should be -- output, whether it is stdout or stderr. data Output OutputStdout :: !ByteString -> Output OutputStderr :: !ByteString -> Output -- | Convert InputData to Output. handleInputData :: forall m. MonadIO m => (ByteString -> m [ByteString]) -> (FilenameHandlingFromFiles -> ByteString -> Int -> ByteString -> m [ByteString]) -> (ByteString -> IOException -> Maybe IOException -> m [ByteString]) -> InputData m () -> Producer Output m () -- | Run a Producer Output by connecting it to -- outputConsumer. runOutputProducer :: forall m. MonadIO m => Producer Output m () -> m () instance GHC.Show.Show Highlight.Common.Monad.Output.FileColorState instance GHC.Read.Read Highlight.Common.Monad.Output.FileColorState instance GHC.Classes.Eq Highlight.Common.Monad.Output.FileColorState instance GHC.Show.Show Highlight.Common.Monad.Output.Output instance GHC.Read.Read Highlight.Common.Monad.Output.Output instance GHC.Classes.Eq Highlight.Common.Monad.Output.Output module Highlight.Common.Error -- | Sum-type representing all errors that can be thrown by this -- application. data HighlightErr -- | Error when trying to compile the RawRegex into a regular -- expression. HighlightRegexCompileErr :: RawRegex -> HighlightErr -- | Call die with an error message based on HighlightErr. handleErr :: HighlightErr -> IO a instance GHC.Show.Show Highlight.Common.Error.HighlightErr module Highlight.Common.Monad -- | 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. newtype CommonHighlightM r s e a CommonHighlightM :: ReaderT r (StateT s (ExceptT e IO)) a -> CommonHighlightM r s e a [unCommonHighlightM] :: CommonHighlightM r s e a -> ReaderT r (StateT s (ExceptT e IO)) a -- | Given an r and s, run CommonHighlightM. runCommonHighlightM :: r -> s -> CommonHighlightM r s e a -> IO (Either e a) -- | Get the IgnoreCase option. getIgnoreCaseM :: (HasIgnoreCase r, MonadReader r m) => m IgnoreCase -- | Get the Recursive option. getRecursiveM :: (HasRecursive r, MonadReader r m) => m Recursive -- | Get the RawRegex option. getRawRegexM :: (HasRawRegex r, MonadReader r m) => m RawRegex -- | Get a list of the InputFilename. getInputFilenamesM :: (HasInputFilenames r, MonadReader r m) => m [InputFilename] -- | Throw a HighlightErr. throwHighlightErr :: HighlightErr -> CommonHighlightM r s HighlightErr a -- | Throw a HighlightRegexCompileErr. throwRegexCompileErr :: RawRegex -> CommonHighlightM r s HighlightErr a -- | Call compileHighlightRegex. Throw a HighlightErr if the -- regex cannot be compiled. compileHighlightRegexWithErr :: (HasIgnoreCase r, HasRawRegex r) => CommonHighlightM r s HighlightErr RE -- | 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
--   
compileHighlightRegex :: IgnoreCase -> RawRegex -> Maybe RE -- | This data type specifies how printing filenames will be handled, along -- with the computeFilenameHandlingFromFiles function. data FilenameHandlingFromFiles -- | Do not print the filename on stdout. NoFilename :: FilenameHandlingFromFiles -- | Print the filename on stdout. PrintFilename :: FilenameHandlingFromFiles -- | This wraps up two pieces of information. -- -- One is the value of FilenameHandlingFromFiles. This signals as -- to whether or not we need to print the filename when printing each -- line of output. -- -- This other is a Producer of FileReader -- ByteStrings. This is a Producer for each line of each -- input file. -- -- The main job of this module is to define createInputData, which -- produces InputData. InputData is what is processed to -- figure out what to output. data InputData m a -- | Create InputData based InputFilename list. -- -- Setup for examples: -- --
--   >>> :set -XOverloadedStrings
--   
--   >>> import Highlight.Common.Options (InputFilename(InputFilename))
--   
--   >>> import Highlight.Common.Options (Recursive(NotRecursive))
--   
-- -- If the InputFilename list is empty, just create an -- InputData with NoFilename and the standard input -- Producer passed in. -- --
--   >>> let stdinProd = yield ("hello" :: ByteString)
--   
--   >>> let create = createInputData NotRecursive [] stdinProd
--   
--   >>> InputData NoFilename prod <- create
--   
--   >>> toListM prod
--   [FileReaderSuccess Stdin "hello"]
--   
-- -- If the InputFilename list is not empty, create an -- InputData with lines from each file found on the command line. -- --
--   >>> let inFiles = [InputFilename "test/golden/test-files/file1"]
--   
--   >>> let create = createInputData NotRecursive inFiles stdinProd
--   
--   >>> InputData NoFilename prod <- create
--   
--   >>> Pipes.head prod
--   Just (FileReaderSuccess (FileSpecifiedByUser "test/golden/test-files/file1") "The...")
--   
createInputData :: forall m. MonadIO m => Recursive -> [InputFilename] -> Producer ByteString m () -> m (InputData m ()) -- | Sum-type to represent where a given ByteString should be -- output, whether it is stdout or stderr. data Output OutputStdout :: !ByteString -> Output OutputStderr :: !ByteString -> Output -- | Convert InputData to Output. handleInputData :: forall m. MonadIO m => (ByteString -> m [ByteString]) -> (FilenameHandlingFromFiles -> ByteString -> Int -> ByteString -> m [ByteString]) -> (ByteString -> IOException -> Maybe IOException -> m [ByteString]) -> InputData m () -> Producer Output m () -- | Run a Producer Output by connecting it to -- outputConsumer. runOutputProducer :: forall m. MonadIO m => Producer Output m () -> m () instance Control.Monad.State.Class.MonadState s (Highlight.Common.Monad.CommonHighlightM r s e) instance Control.Monad.Reader.Class.MonadReader r (Highlight.Common.Monad.CommonHighlightM r s e) instance Control.Monad.IO.Class.MonadIO (Highlight.Common.Monad.CommonHighlightM r s e) instance Control.Monad.Error.Class.MonadError e (Highlight.Common.Monad.CommonHighlightM r s e) instance GHC.Base.Monad (Highlight.Common.Monad.CommonHighlightM r s e) instance GHC.Base.Applicative (Highlight.Common.Monad.CommonHighlightM r s e) instance GHC.Base.Functor (Highlight.Common.Monad.CommonHighlightM r s e) module Highlight.Hrep.Monad -- | HrepM is just CommonHighlightM specialized for -- hrep. type HrepM = CommonHighlightM CommonOptions () HighlightErr runHrepM :: CommonOptions -> HrepM a -> IO (Either HighlightErr a) -- | This data type specifies how printing filenames will be handled, along -- with the computeFilenameHandlingFromFiles function. data FilenameHandlingFromFiles -- | Do not print the filename on stdout. NoFilename :: FilenameHandlingFromFiles -- | Print the filename on stdout. PrintFilename :: FilenameHandlingFromFiles -- | This wraps up two pieces of information. -- -- One is the value of FilenameHandlingFromFiles. This signals as -- to whether or not we need to print the filename when printing each -- line of output. -- -- This other is a Producer of FileReader -- ByteStrings. This is a Producer for each line of each -- input file. -- -- The main job of this module is to define createInputData, which -- produces InputData. InputData is what is processed to -- figure out what to output. data InputData m a -- | Create InputData based InputFilename list. -- -- Setup for examples: -- --
--   >>> :set -XOverloadedStrings
--   
--   >>> import Highlight.Common.Options (InputFilename(InputFilename))
--   
--   >>> import Highlight.Common.Options (Recursive(NotRecursive))
--   
-- -- If the InputFilename list is empty, just create an -- InputData with NoFilename and the standard input -- Producer passed in. -- --
--   >>> let stdinProd = yield ("hello" :: ByteString)
--   
--   >>> let create = createInputData NotRecursive [] stdinProd
--   
--   >>> InputData NoFilename prod <- create
--   
--   >>> toListM prod
--   [FileReaderSuccess Stdin "hello"]
--   
-- -- If the InputFilename list is not empty, create an -- InputData with lines from each file found on the command line. -- --
--   >>> let inFiles = [InputFilename "test/golden/test-files/file1"]
--   
--   >>> let create = createInputData NotRecursive inFiles stdinProd
--   
--   >>> InputData NoFilename prod <- create
--   
--   >>> Pipes.head prod
--   Just (FileReaderSuccess (FileSpecifiedByUser "test/golden/test-files/file1") "The...")
--   
createInputData :: forall m. MonadIO m => Recursive -> [InputFilename] -> Producer ByteString m () -> m (InputData m ()) -- | Sum-type to represent where a given ByteString should be -- output, whether it is stdout or stderr. data Output -- | Convert InputData to Output. handleInputData :: forall m. MonadIO m => (ByteString -> m [ByteString]) -> (FilenameHandlingFromFiles -> ByteString -> Int -> ByteString -> m [ByteString]) -> (ByteString -> IOException -> Maybe IOException -> m [ByteString]) -> InputData m () -> Producer Output m () -- | Run a Producer Output by connecting it to -- outputConsumer. runOutputProducer :: forall m. MonadIO m => Producer Output m () -> m () -- | 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. data CommonHighlightM r s e a -- | Given an r and s, run CommonHighlightM. runCommonHighlightM :: r -> s -> CommonHighlightM r s e a -> IO (Either e a) -- | Get the Recursive option. getRecursiveM :: (HasRecursive r, MonadReader r m) => m Recursive -- | Get a list of the InputFilename. getInputFilenamesM :: (HasInputFilenames r, MonadReader r m) => m [InputFilename] -- | Call compileHighlightRegex. Throw a HighlightErr if the -- regex cannot be compiled. compileHighlightRegexWithErr :: (HasIgnoreCase r, HasRawRegex r) => CommonHighlightM r s HighlightErr RE module Highlight.Hrep.Run run :: CommonOptions -> IO () prog :: HrepM () hrepOutputProducer :: Producer ByteString HrepM () -> HrepM (Producer Output HrepM ()) handleStdinInput :: Monad m => RE -> ByteString -> m [ByteString] formatNormalLine :: RE -> ByteString -> [ByteString] handleFileInput :: Monad m => RE -> FilenameHandlingFromFiles -> ByteString -> Int -> ByteString -> m [ByteString] formatLineWithFilename :: RE -> Int -> ByteString -> ByteString -> [ByteString] handleError :: Monad m => ByteString -> IOException -> Maybe IOException -> m [ByteString] highlightMatchInRed :: RE -> ByteString -> Maybe ByteString replaceInRedByteString :: ByteString module Highlight.Hrep defaultMain :: IO () module Highlight.Highlight.Monad -- | HighlightM is just CommonHighlightM specialized for -- highlight. type HighlightM = CommonHighlightM Options FromGrepFilenameState HighlightErr -- | The internal state that is used to figure out how to color filenames -- from grep. data FromGrepFilenameState FromGrepFilenameState :: {-# UNPACK #-} !Int -> !Maybe ByteString -> FromGrepFilenameState [fromGrepFilenameStatePrevFileNum] :: FromGrepFilenameState -> {-# UNPACK #-} !Int [fromGrepFilenameStatePrevFilename] :: FromGrepFilenameState -> !Maybe ByteString initFromGrepFilenameState :: FromGrepFilenameState -- | Call updateFilename and return the new file number after doing -- the update. updateFilenameM :: MonadState FromGrepFilenameState m => ByteString -> m Int -- | Update the file number in FromGrepFilenameState if the -- ByteString filename passed in is different from that in -- FromGrepFilenameState. updateFilename :: ByteString -> FromGrepFilenameState -> FromGrepFilenameState runHighlightM :: Options -> HighlightM a -> IO (Either HighlightErr a) -- | Get the value of the ColorGrepFilenames option. getColorGrepFilenamesM :: (HasColorGrepFilenames r, MonadReader r m) => m ColorGrepFilenames -- | This data type specifies how printing filenames will be handled, along -- with the computeFilenameHandlingFromFiles function. data FilenameHandlingFromFiles -- | Do not print the filename on stdout. NoFilename :: FilenameHandlingFromFiles -- | Print the filename on stdout. PrintFilename :: FilenameHandlingFromFiles -- | This wraps up two pieces of information. -- -- One is the value of FilenameHandlingFromFiles. This signals as -- to whether or not we need to print the filename when printing each -- line of output. -- -- This other is a Producer of FileReader -- ByteStrings. This is a Producer for each line of each -- input file. -- -- The main job of this module is to define createInputData, which -- produces InputData. InputData is what is processed to -- figure out what to output. data InputData m a -- | Create InputData based InputFilename list. -- -- Setup for examples: -- --
--   >>> :set -XOverloadedStrings
--   
--   >>> import Highlight.Common.Options (InputFilename(InputFilename))
--   
--   >>> import Highlight.Common.Options (Recursive(NotRecursive))
--   
-- -- If the InputFilename list is empty, just create an -- InputData with NoFilename and the standard input -- Producer passed in. -- --
--   >>> let stdinProd = yield ("hello" :: ByteString)
--   
--   >>> let create = createInputData NotRecursive [] stdinProd
--   
--   >>> InputData NoFilename prod <- create
--   
--   >>> toListM prod
--   [FileReaderSuccess Stdin "hello"]
--   
-- -- If the InputFilename list is not empty, create an -- InputData with lines from each file found on the command line. -- --
--   >>> let inFiles = [InputFilename "test/golden/test-files/file1"]
--   
--   >>> let create = createInputData NotRecursive inFiles stdinProd
--   
--   >>> InputData NoFilename prod <- create
--   
--   >>> Pipes.head prod
--   Just (FileReaderSuccess (FileSpecifiedByUser "test/golden/test-files/file1") "The...")
--   
createInputData :: forall m. MonadIO m => Recursive -> [InputFilename] -> Producer ByteString m () -> m (InputData m ()) -- | Sum-type to represent where a given ByteString should be -- output, whether it is stdout or stderr. data Output -- | Convert InputData to Output. handleInputData :: forall m. MonadIO m => (ByteString -> m [ByteString]) -> (FilenameHandlingFromFiles -> ByteString -> Int -> ByteString -> m [ByteString]) -> (ByteString -> IOException -> Maybe IOException -> m [ByteString]) -> InputData m () -> Producer Output m () -- | Run a Producer Output by connecting it to -- outputConsumer. runOutputProducer :: forall m. MonadIO m => Producer Output m () -> m () -- | 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. data CommonHighlightM r s e a -- | Given an r and s, run CommonHighlightM. runCommonHighlightM :: r -> s -> CommonHighlightM r s e a -> IO (Either e a) -- | Get the Recursive option. getRecursiveM :: (HasRecursive r, MonadReader r m) => m Recursive -- | Get a list of the InputFilename. getInputFilenamesM :: (HasInputFilenames r, MonadReader r m) => m [InputFilename] -- | Call compileHighlightRegex. Throw a HighlightErr if the -- regex cannot be compiled. compileHighlightRegexWithErr :: (HasIgnoreCase r, HasRawRegex r) => CommonHighlightM r s HighlightErr RE module Highlight.Highlight.Run run :: Options -> IO () prog :: HighlightM () highlightOutputProducer :: Producer ByteString HighlightM () -> HighlightM (Producer Output HighlightM ()) handleStdinInput :: (HasColorGrepFilenames r, MonadState FromGrepFilenameState m, MonadReader r m) => RE -> ByteString -> m [ByteString] formatLineWithFilename :: RE -> Int -> ByteString -> ByteString -> [ByteString] formatNormalLine :: RE -> ByteString -> [ByteString] handleFileInput :: Monad m => RE -> FilenameHandlingFromFiles -> ByteString -> Int -> ByteString -> m [ByteString] handleError :: Monad m => ByteString -> IOException -> Maybe IOException -> m [ByteString] highlightMatchInRed :: RE -> ByteString -> ByteString replaceInRedByteString :: ByteString -- | This module contains the defaultMain function for the -- highlight program. module Highlight.Highlight defaultMain :: IO ()