"      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ None Convert a  to a + with the encoding for the current locale.$convertStringToRawByteString "hello""hello"Open a  in .On success, return a  :"openFilePathForReading "README.md"Right {handle: README.md}On error, return a  :,openFilePathForReading "thisfiledoesntexist"<Left thisfiledoesntexist: openBinaryFile: does not exist ...Combine values in two s with .2combineApplicatives (Just "hello") (Just " world")Just "hello world"*combineApplicatives (Just "hello") NothingNothing Handle an ! that occurs when reading from a . Check if the  is an EOF exception ( ). If so, then just close the . Otherwise, throw the  that is passed in.Call  with die 10 "message"ERROR: message*** Exception: ExitFailure 10*Perform an action when a list is non-null.&whenNonNull [1,2,3] $ putStrLn "hello"hellowhenNonNull [] $ putStrLn "bye" A variant of modify6 in which the computation is strict in the new state.  f =  >>= (()  . f)This is used because  is not available in the tranformers-0.3.0.0 package. exit code!error message to print to consoleNoneOTRead input from a <, split it into lines, and return each of those lines as a  in a Producer.This function will close the b if the end of the file is reached. However, if an error was thrown while reading input from the , the  is not closed.Setup for examples:import Pipes.Prelude (toListM)3import System.IO (IOMode(ReadMode), openBinaryFile)1let goodFilePath = "test/golden/test-files/file2" Examples:.handle <- openBinaryFile goodFilePath ReadMode,fmap head . toListM $ fromHandleLines handleJ"Proud Pour is a wine company that funds solutions to local environmental"Call  on .  Try calling  on the  obtained from .Setup for examples:import Pipes (Producer)import Pipes.Prelude (toListM)Blet t a = a :: IO (Either IOException (Producer ByteString IO ()))1let goodFilePath = "test/golden/test-files/file2"(let badFilePath = "thisfiledoesnotexist"Flet handleErr err = error $ "got following error: " `mappend` show errExample:0eitherProducer <- t $ fromFileLines goodFilePath1let producer = either handleErr id eitherProducerfmap head $ toListM producerJ"Proud Pour is a wine company that funds solutions to local environmental"Returns - if there was an error when opening the file./eitherProducer <- t $ fromFileLines badFilePath/either print (const $ return ()) eitherProducer8thisfiledoesnotexist: openBinaryFile: does not exist ... Output s to .If an  error is thrown, then just  ()4. If any other error is thrown, rethrow the error.Setup for examples::set -XOverloadedStringsimport Pipes ((>->), runEffect)Example:,runEffect $ yield "hello" >-> stderrConsumerhello ?Select all immediate children of the given directory, ignoring "." and "..". Throws an ` 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  Vhttps://hackage.haskell.org/package/dirstream-1.0.3/docs/Data-DirStream.html#v:childOfchildOf function.    None-6I-A set of options that are common to both the  highlight and hrep applications.8An input file passed in on the command line by the user.TThe raw, pre-compiled regular expression passed in on the command line by the user. AWhether or not files should be searched recursively. Similar to grep's  --recursive option.%OWhether or not the case of a regular expression should be ignored. Similar to grep's  --ignore-case option.-A default set of . Defined as the following::{ let opts = CommonOptions3 { commonOptionsIgnoreCase = DoNotIgnoreCase/ , commonOptionsRecursive = NotRecursive> , commonOptionsRawRegex = RawRegex { unRawRegex = "" }* , commonOptionsInputFilenames = [] }:}opts == defaultCommonOptionsTrue'  !"#$%&'()*+,-./012"  !"#$%&'()*+,-+%&'#$$( !")*+ 210/.,-   !"#$$%&'()*+,-./012None-L,Whether or not to color filenames output by grep when reading in from stdin.DEFGHIJKLMNOPQRSTUVWX%  !#$%&',-DEFGHIJKLMNOPQLMNOJKFGHIQPDEDEFGHIJKLMNOPQRSTUVWXNone-:OT\_QThis data type specifies how printing filenames will be handled, along with the  function.`$Do not print the filename on stdout.aPrint the filename on stdout.b(This wraps up two pieces of information.One is the value of _f. This signals as to whether or not we need to print the filename when printing each line of output.This other is a  of d s. This is a " for each line of each input file.)The main job of this module is to define m, which produces b. b3 is what is processed to figure out what to output.d%This is used in two different places. One is in , where a becomes 9. This represents a single file that has been opened. e contains the g and the . f contains the g7 and any errors that occurred when trying to open the .The other is in  and b, where a becomes . This represents a single K line from a file, or an error that occurred when trying to read the file.d is usually wrapped in a . This is a stream of either s or , lines (with any errors that have occurred).g(Place where a file originally came from.h3File was specified on the command line by the user.i@File was found recursively (not directly specified by the user).j@Standard input. It was either specified on the command line as -A, or used as default because the user did not specify any files.Get a  from a g.;getFilePathFromFileOrigin $ FileSpecifiedByUser "hello.txt"Just "hello.txt":getFilePathFromFileOrigin $ FileFoundRecursively "bye.txt"Just "bye.txt"getFilePathFromFileOrigin StdinNothingkGet a g from a d.1let fileOrigin1 = FileSpecifiedByUser "hello.txt";let fileReader1 = FileReaderSuccess fileOrigin1 "some line"'getFileOriginFromFileReader fileReader1FileSpecifiedByUser "hello.txt"0let fileOrigin2 = FileFoundRecursively "bye.txt"Elet fileReader2 = FileReaderErr fileOrigin2 (userError "err") Nothing'getFileOriginFromFileReader fileReader2FileFoundRecursively "bye.txt"lThis is just   k.let fileOrigin1 = Stdin;let fileReader1 = FileReaderSuccess fileOrigin1 "some line"%getFilePathFromFileReader fileReader1Nothing0let fileOrigin2 = FileFoundRecursively "bye.txt"Elet fileReader2 = FileReaderErr fileOrigin2 (userError "err") Nothing%getFilePathFromFileReader fileReader2Just "bye.txt"mCreate b based  list.Setup for examples::set -XOverloadedStrings>import Highlight.Common.Options (InputFilename(InputFilename))9import Highlight.Common.Options (Recursive(NotRecursive))If the  list is empty, just create an b with ` and the standard input  passed in.-let stdinProd = yield ("hello" :: ByteString)6let create = createInputData NotRecursive [] stdinProd#InputData NoFilename prod <- create toListM prod![FileReaderSuccess Stdin "hello"]If the  list is not empty, create an b6 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 <- createPipes.head prodVJust (FileReaderSuccess (FileSpecifiedByUser "test/golden/test-files/file1") "The...")Change a given  into a d  with the g set to j.<You can think of this function as having the following type:   ::  m =>  a m r ->  (d a) m r 6Pipes.head . stdinProducerToFileReader $ yield "hello"&Just (FileReaderSuccess Stdin "hello") Convert a  of d  into a  of d , where each line from the  is ed.<You can think of this function as having the following type:   ::  m =>  (d  ) m r ->  (d ) m r Clet fileOrigin = FileSpecifiedByUser "test/golden/test-files/file2"4let producer = fileListProducer Recursive fileOrigin,Pipes.head $ fileReaderHandleToLine producerSJust (FileReaderSuccess (FileSpecifiedByUser "test/golden/test-files/file2") "Pr... Create a  of d  for a given g.Setup for examples:Dimport Highlight.Common.Options (Recursive(NotRecursive, Recursive))If  NoRecursive is specified, just try to read g as a file.Dlet fileOrigin1 = FileSpecifiedByUser "test/golden/test-files/file2"3toListM $ fileListProducer NotRecursive fileOrigin1S[FileReaderSuccess (FileSpecifiedByUser "test/.../file2") {handle: test/.../file2}],If the file cannot be read, return an error.<let fileOrigin2 = FileSpecifiedByUser "thisfiledoesnotexist"3toListM $ fileListProducer NotRecursive fileOrigin2[FileReaderErr (FileSpecifiedByUser "thisfiledoesnotexist") thisfiledoesnotexist: openBinaryFile: does not exist (No such file or directory) Nothing]If   is specified, then try to read g as a directory'.Clet fileOrigin3 = FileSpecifiedByUser "test/golden/test-files/dir2"0toListM $ fileListProducer Recursive fileOrigin3^[FileReaderSuccess (FileFoundRecursively "test/.../dir2/file6") {handle: test/.../dir2/file6}]1If the directory cannot be read, return an error.;let fileOrigin4 = FileSpecifiedByUser "thisdirdoesnotexist"0toListM $ fileListProducer Recursive fileOrigin4[FileReaderErr (FileSpecifiedByUser "thisdirdoesnotexist") thisdirdoesnotexist: openBinaryFile: does not exist (No such file or directory) (Just ...)]Given a  of dQs, figure out whether or not we should print the filename of the file to stdout.AThe following examples walk through possible command lines using  highlight7, and the corresponding return values of this function.  $ highlight expression 0We want to read from stdin. There should be no  FileReaders in the . Do not print the filename.let producerStdin = each []>(fhStdin, _) <- computeFilenameHandlingFromFiles producerStdinfhStdin NoFilename  $ highlight expression file1 DWe want to highlight a single file. There should only be a single d in the , and it should be h. Do not print the filename.6let fileOriginSingleFile = FileSpecifiedByUser "file1"Ilet fileReaderSingleFile = FileReaderSuccess fileOriginSingleFile "hello"4let producerSingleFile = each [fileReaderSingleFile]H(fhSingleFile, _) <- computeFilenameHandlingFromFiles producerSingleFile fhSingleFile NoFilename % $ highlight expression file1 file2 4We want to highlight two files. Print the filename.2let fileOriginMulti1 = FileSpecifiedByUser "file1"Alet fileReaderMulti1 = FileReaderSuccess fileOriginMulti1 "hello"2let fileOriginMulti2 = FileSpecifiedByUser "file2"?let fileReaderMulti2 = FileReaderSuccess fileOriginMulti2 "bye"Alet producerMultiFile = each [fileReaderMulti1, fileReaderMulti2]F(fhMultiFile, _) <- computeFilenameHandlingFromFiles producerMultiFile fhMultiFile PrintFilename ! $ highlight -r expression dir1 (We want to highlight all files found in dir1/. Print filenames.5let fileOriginRec = FileFoundRecursively "dir1/file1"9let fileReaderRec = FileReaderSuccess fileOriginRec "cat"&let producerRec = each [fileReaderRec]:(fhRec, _) <- computeFilenameHandlingFromFiles producerRecfhRec PrintFilename_`abcdefghijklm,Whether or not to recursively read in files.,List of files passed in on the command line.A producer for standard input_`abcdfeghijklmghijdefklbcm_`a _`abcdefghijklmNone-:OT\v$Sum-type to represent where a given 3 should be output, whether it is stdout or stderr.;The state for which number file we are outputting with its g.[The current number of the file we are outputting. This is increased by one for each file.Initial value for . Defined as the following:defFileColorStateFileColorState Nothing 0yConvert b to v.When the list of  is not [], convert them to w and return them in a . Call  with the passed-in g.When the list of  is not [], convert them to x and return them in a . Do not call .Call  with the current value of .$Based on the value of the passed in g and the g in  , update the  in .Setup for examples:Eimport Highlight.Common.Monad.Input (FileOrigin(FileSpecifiedByUser))If  is passed in, then update the g.0let fileOrigin = FileSpecifiedByUser "hello.txt"+updateColorNum fileOrigin defFileColorState9FileColorState (Just (FileSpecifiedByUser "hello.txt")) 0If the g is different from the one in , then increment the .3let oldFileOrigin = FileSpecifiedByUser "hello.txt"1let newFileOrigin = FileSpecifiedByUser "bye.txt">let fileColorStateDiff = FileColorState (Just oldFileOrigin) 5/updateColorNum newFileOrigin fileColorStateDiff7FileColorState (Just (FileSpecifiedByUser "bye.txt")) 6If the g is the same as the one in , then do not increment the .4let sameFileOrigin = FileSpecifiedByUser "hello.txt"?let fileColorStateDiff = FileColorState (Just sameFileOrigin) 50updateColorNum sameFileOrigin fileColorStateDiff9FileColorState (Just (FileSpecifiedByUser "hello.txt")) 5 This called  and returns the new value of , but it doesn't update the  FileColorNum in  .  This is just toOutputWithNewLine x.  This is just toOutputWithNewLine w. Convert a list of  to v with the given function.Setup for examples::set -XOverloadedStringsimport Pipes.Prelude (toListM)If the list of  is empty, then do nothing.-toListM $ toOutputWithNewline OutputStdout [][]If the list of  is not empty, then convert to v and add an ending newline.;toListM $ toOutputWithNewline OutputStderr ["hello", "bye"];[OutputStderr "hello",OutputStderr "bye",OutputStderr "\n"]  Write each v to either  or  .Setup for tests:import Pipes (runEffect)Send w to .IrunEffect $ yield (OutputStdout "this goes to stdout") >-> outputConsumerthis goes to stdoutSend x to  .IrunEffect $ yield (OutputStderr "this goes to stderr") >-> outputConsumerthis goes to stderrzRun a  v by connecting it to  .vwxy5Function to use for conversion for a line from stdin.=Function to use for conversion for a line from a normal file./Function to use for conversion for an io error.All of the input lines.   Function to use to convert the  to v.List of s to convert to v. zvxwyzvwxyzvwxy    zNoneHSum-type representing all errors that can be thrown by this application.!Error when trying to compile the  into a regular expression.Call  with an error message based on .None-:IOT\ "This is the common monad for both  highlight and hrepI. 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. Given an r and s, run .Get the % option.Get the   option.Get the  option.Get a list of the .Throw a .Throw a .Call  . Throw a " if the regex cannot be compiled.Try compiling a  into a .Setup for examples:import Data.Maybe (isJust)Return  for a proper regex:AisJust $ compileHighlightRegex IgnoreCase (RawRegex "good regex")TrueReturn  for an improper regex:BisJust $ compileHighlightRegex IgnoreCase (RawRegex "bad regex (")False _`abmvxwyz  None-:OT\ is just  specialized for  highlight.KThe internal state that is used to figure out how to color filenames from grep.Call 8 and return the new file number after doing the update.Update the file number in  if the / filename passed in is different from that in .Get the value of the L option. _`abmvyz  None-:T\ is just  specialized for hrep._`abmvyz Safe /Find the corresponding color for the number in , taking the mod of the .colorForFileNumber 0"\ESC[1m\ESC[94m"colorForFileNumber 1"\ESC[1m\ESC[92m"colorForFileNumber 4"\ESC[1m\ESC[94m" turned into an  for faster lookup. of .@List of all the colors that are used for highlighting filenames.Change the intensity to ." the console color back to normal. Empty string.Helper for creating a / for an ANSI escape sequence color based on a  and a .Convert a list of  to a .)))) None:OT Dennis Gosnell 2017BSD3(Dennis Gosnell (cdep.illabout@gmail.com) experimentalunknownNoneNone:OT None !"#$%%&'())*+,--./01123456789:;<=>?@ABCDEFGHIJKLMNOPQQRSTUVVWXYZ[\]^_`abcdefghijkklmnopqrstuvwxyz{|}~           !"#$%&'()*+,-./0./1./2./3./45(highlight-1.0.0.0-FzE2Sx1Y15JGjfZFAUYUwXHighlight.UtilHighlight.PipesHighlight.Common.OptionsHighlight.Highlight.OptionsHighlight.Common.Monad.InputHighlight.Common.Monad.OutputHighlight.Common.ErrorHighlight.Common.MonadHighlight.Highlight.MonadHighlight.Hrep.MonadHighlight.Common.ColorHighlight.Highlight.RunHighlight.HighlightHighlight.Hrep.RunHighlight.HrepconvertStringToRawByteStringopenFilePathForReadingcombineApplicativescloseHandleIfEOFOrThrowdie whenNonNullmodify'fromHandleLines stdinLines fromFileLinesstderrConsumerchildOfHasCommonOptionscommonOptionsLens CommonOptionscommonOptionsIgnoreCasecommonOptionsRecursivecommonOptionsRawRegexcommonOptionsInputFilenamesHasInputFilenamesinputFilenamesLens InputFilenameunInputFilename HasRawRegex rawRegexLensRawRegex unRawRegex HasRecursive recursiveLens Recursive NotRecursive HasIgnoreCaseignoreCaseLens IgnoreCaseDoNotIgnoreCaseignoreCaseParserrecursiveParserrawRegexParserinputFilenamesParsercommonOptionsParserdefaultCommonOptions $fHasInputFilenamesCommonOptions$fHasRawRegexCommonOptions$fHasRecursiveCommonOptions$fHasIgnoreCaseCommonOptions$fHasCommonOptionsCommonOptions$fEqIgnoreCase$fReadIgnoreCase$fShowIgnoreCase $fEqRecursive$fReadRecursive$fShowRecursive $fEqRawRegex$fIsStringRawRegex$fReadRawRegex$fShowRawRegex$fEqInputFilename$fIsStringInputFilename$fReadInputFilename$fShowInputFilename$fEqCommonOptions$fReadCommonOptions$fShowCommonOptions HasOptions optionsLensOptionsoptionsColorGrepFilenamesoptionsCommonOptionsHasColorGrepFilenamescolorGrepFilenamesLensColorGrepFilenamesDoNotColorGrepFileNamescolorGrepFilenamesParser optionsParserdefaultOptions$fHasInputFilenamesOptions$fHasRawRegexOptions$fHasRecursiveOptions$fHasIgnoreCaseOptions$fHasCommonOptionsOptions$fHasColorGrepFilenamesOptions$fHasOptionsOptions$fEqColorGrepFilenames$fReadColorGrepFilenames$fShowColorGrepFilenames $fEqOptions $fReadOptions $fShowOptionsFilenameHandlingFromFiles NoFilename PrintFilename InputData FileReaderFileReaderSuccess FileReaderErr FileOriginFileSpecifiedByUserFileFoundRecursivelyStdingetFileOriginFromFileReadergetFilePathFromFileReadercreateInputData$fEqFileOrigin$fReadFileOrigin$fShowFileOrigin$fEqFileReader$fShowFileReader$fEqFilenameHandlingFromFiles$fReadFilenameHandlingFromFiles$fShowFilenameHandlingFromFilesOutput OutputStdout OutputStderrhandleInputDatarunOutputProducer$fEqFileColorState$fReadFileColorState$fShowFileColorState $fEqOutput $fReadOutput $fShowOutput HighlightErrHighlightRegexCompileErr handleErr$fShowHighlightErrCommonHighlightMunCommonHighlightMrunCommonHighlightMgetIgnoreCaseM getRecursiveM getRawRegexMgetInputFilenamesMthrowHighlightErrthrowRegexCompileErrcompileHighlightRegexWithErrcompileHighlightRegex$fFunctorCommonHighlightM$fApplicativeCommonHighlightM$fMonadCommonHighlightM$fMonadErrorCommonHighlightM$fMonadIOCommonHighlightM$fMonadReaderCommonHighlightM$fMonadStateCommonHighlightM HighlightMFromGrepFilenameState fromGrepFilenameStatePrevFileNum!fromGrepFilenameStatePrevFilenameinitFromGrepFilenameStateupdateFilenameMupdateFilename runHighlightMgetColorGrepFilenamesMHrepMrunHrepMcolorForFileNumber allColorsMapallColorsLength allColorsListcolorVividBlackBoldcolorVividBlueBoldcolorVividCyanBoldcolorVividGreenBoldcolorVividMagentaBoldcolorVividRedBoldcolorVividWhiteBoldcolorVividYellowBoldcolorDullBlackBoldcolorDullBlueBoldcolorDullCyanBoldcolorDullGreenBoldcolorDullMagentaBoldcolorDullRedBoldcolorDullWhiteBoldcolorDullYellowBoldcolorVividBlackcolorVividBluecolorVividCyancolorVividGreencolorVividMagenta colorVividRedcolorVividWhitecolorVividYellowcolorDullBlack colorDullBlue colorDullCyancolorDullGreencolorDullMagenta colorDullRedcolorDullWhitecolorDullYellow colorBold colorReset colorNull colorHelpersetSGRCodeBuilderrunproghighlightOutputProducerhandleStdinInputformatLineWithFilenameformatNormalLinehandleFileInput handleErrorhighlightMatchInRedreplaceInRedByteString defaultMainhrepOutputProducerbaseGHC.BaseStringbytestring-0.10.8.1Data.ByteString.Internal ByteStringGHC.IOFilePath GHC.IO.IOModeReadMode Data.EitherRightGHC.IO.Handle.TypesHandleLeftGHC.IO.Exception IOException ApplicativeData.Semigroup<> GHC.IO.HandlehIsEOF System.ExitexitWith ExitFailure mtl-2.2.1-BLKBelFsPB3BoFeSWSOYj6Control.Monad.State.Classget$!putGHC.IO.Handle.FDstdinstderrForeign.C.ErrorePIPEreturn computeFilenameHandlingFromFiles"pipes-4.3.4-15Ul1roIBHW4TZnmZKIxZM Pipes.CoreProducerfileListProducerfileReaderHandleToLinegetFilePathFromFileOrigin.stdinProducerToFileReaderMonadPipesyieldControl.Monad.IO.ClassMonadIOFileColorStateColorNumdefFileColorStatetoStdoutWhenNonNullupdateColorNumtoStderrWhenNonNullupdateColorNumMgetColorNumIfNewFileM MonadStatetoStderrWithNewlinetoStdoutWithNewlinetoOutputWithNewlineoutputConsumer-pipes-bytestring-2.1.5-5dpuULNNe2x75EP9ph5ZzkPipes.ByteStringstdout.regex-with-pcre-1.0.1.3-JE6WwxBf0OR8iQQPvFpj0GText.RE.ZeInternals.PCREREJustNothingghc-prim GHC.TypesIntcontainers-0.5.7.1Data.IntMap.BaseIntMap Data.Foldablelength,ansi-terminal-0.6.3.1-59sjf9WqHYuFAo9gQw9BhpSystem.Console.ANSI.Types BoldIntensityResetColorIntensityColorSGR