h*ݖ       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                                                                                                                                                                                                       "(c) The University of Glasgow 2015/BSD-style (see the file libraries/base/LICENSE)libraries@haskell.org experimentalportableSafe Safe4  (c) Neil Mitchell 2005-2014BSD3ndmitchell@gmail.comstableportable Safe-Inferredrk9 template-haskell*Is the operating system Unix or Linux like template-haskell$Is the operating system Windows like template-haskellThe character that separates directories. In the case where more than one character is possible,   is the 'ideal' one. Windows: pathSeparator == '\\' Posix: pathSeparator == '/' isPathSeparator pathSeparator template-haskell$The list of all possible separators. Windows: pathSeparators == ['\\', '/'] Posix: pathSeparators == ['/'] pathSeparator `elem` pathSeparators template-haskellRather than using (==  )5, use this. Test if something is a path separator. .isPathSeparator a == (a `elem` pathSeparators) template-haskellThe character that is used to separate the entries in the $PATH environment variable. Windows: searchPathSeparator == ';' Posix: searchPathSeparator == ':' template-haskell"Is the character a file separator? 5isSearchPathSeparator a == (a == searchPathSeparator) template-haskellFile extension character extSeparator == '.' template-haskell(Is the character an extension character? 'isExtSeparator a == (a == extSeparator) template-haskellTake a string, split it on the   character. Blank items are ignored on Windows, and converted to .> on Posix. On Windows path elements are stripped of quotes."Follows the recommendations in http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html Posix: splitSearchPath "File1:File2:File3" == ["File1","File2","File3"] Posix: splitSearchPath "File1::File2:File3" == ["File1",".","File2","File3"] Windows: splitSearchPath "File1;File2;File3" == ["File1","File2","File3"] Windows: splitSearchPath "File1;;File2;File3" == ["File1","File2","File3"] Windows: splitSearchPath "File1;\"File2\";File3" == ["File1","File2","File3"] template-haskellGet a list of  s in the $PATH variable. template-haskellSplit on the extension.   is the inverse. splitExtension "/directory/path.ext" == ("/directory/path",".ext") uncurry (++) (splitExtension x) == x Valid x => uncurry addExtension (splitExtension x) == x splitExtension "file.txt" == ("file",".txt") splitExtension "file" == ("file","") splitExtension "file/file.txt" == ("file/file",".txt") splitExtension "file.txt/boris" == ("file.txt/boris","") splitExtension "file.txt/boris.ext" == ("file.txt/boris",".ext") splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred") splitExtension "file/path.txt/" == ("file/path.txt/","") template-haskell%Get the extension of a file, returns "" for no extension, .ext otherwise. takeExtension "/directory/path.ext" == ".ext" takeExtension x == snd (splitExtension x) Valid x => takeExtension (addExtension x "ext") == ".ext" Valid x => takeExtension (replaceExtension x "ext") == ".ext" template-haskell "ext" == "/directory/path.ext" "/directory/path.txt" -<.> ".ext" == "/directory/path.ext" "foo.o" -<.> "c" == "foo.c" template-haskellSet the extension of a file, overwriting one if already present, equivalent to  . replaceExtension "/directory/path.txt" "ext" == "/directory/path.ext" replaceExtension "/directory/path.txt" ".ext" == "/directory/path.ext" replaceExtension "file.txt" ".bob" == "file.bob" replaceExtension "file.txt" "bob" == "file.bob" replaceExtension "file" ".bob" == "file.bob" replaceExtension "file.txt" "" == "file" replaceExtension "file.fred.bob" "txt" == "file.fred.txt" replaceExtension x y == addExtension (dropExtension x) y template-haskellAdd an extension, even if there is already one there, equivalent to  . "/directory/path" <.> "ext" == "/directory/path.ext" "/directory/path" <.> ".ext" == "/directory/path.ext" template-haskell0Remove last extension, and the "." preceding it. dropExtension "/directory/path.ext" == "/directory/path" dropExtension x == fst (splitExtension x) template-haskellAdd an extension, even if there is already one there, equivalent to  . addExtension "/directory/path" "ext" == "/directory/path.ext" addExtension "file.txt" "bib" == "file.txt.bib" addExtension "file." ".bib" == "file..bib" addExtension "file" ".bib" == "file.bib" addExtension "/" "x" == "/.x" addExtension x "" == x Valid x => takeFileName (addExtension (addTrailingPathSeparator x) "ext") == ".ext" Windows: addExtension "\\\\share" ".txt" == "\\\\share\\.txt" template-haskell*Does the given filename have an extension? hasExtension "/directory/path.ext" == True hasExtension "/directory/path" == False null (takeExtension x) == not (hasExtension x) template-haskell5Does the given filename have the specified extension? "png" `isExtensionOf` "/directory/file.png" == True ".png" `isExtensionOf` "/directory/file.png" == True ".tar.gz" `isExtensionOf` "bar/foo.tar.gz" == True "ar.gz" `isExtensionOf` "bar/foo.tar.gz" == False "png" `isExtensionOf` "/directory/file.png.jpg" == False "csv/table.csv" `isExtensionOf` "/data/csv/table.csv" == False template-haskell2Drop the given extension from a FilePath, and the "." preceding it. Returns  : if the FilePath does not have the given extension, or  . and the part before the extension if it does.+This function can be more predictable than  5, especially if the filename might itself contain . characters. stripExtension "hs.o" "foo.x.hs.o" == Just "foo.x" stripExtension "hi.o" "foo.x.hs.o" == Nothing dropExtension x == fromJust (stripExtension (takeExtension x) x) dropExtensions x == fromJust (stripExtension (takeExtensions x) x) stripExtension ".c.d" "a.b.c.d" == Just "a.b" stripExtension ".c.d" "a.b..c.d" == Just "a.b." stripExtension "baz" "foo.bar" == Nothing stripExtension "bar" "foobar" == Nothing stripExtension "" x == Just x template-haskellSplit on all extensions. splitExtensions "/directory/path.ext" == ("/directory/path",".ext") splitExtensions "file.tar.gz" == ("file",".tar.gz") uncurry (++) (splitExtensions x) == x Valid x => uncurry addExtension (splitExtensions x) == x splitExtensions "file.tar.gz" == ("file",".tar.gz") template-haskellDrop all extensions. dropExtensions "/directory/path.ext" == "/directory/path" dropExtensions "file.tar.gz" == "file" not $ hasExtension $ dropExtensions x not $ any isExtSeparator $ takeFileName $ dropExtensions x template-haskellGet all extensions. takeExtensions "/directory/path.ext" == ".ext" takeExtensions "file.tar.gz" == ".tar.gz" template-haskellReplace all extensions of a file with a new extension. Note that   and   both work for adding multiple extensions, so only required when you need to drop all extensions first. replaceExtensions "file.fred.bob" "txt" == "file.txt" replaceExtensions "file.fred.bob" "tar.gz" == "file.tar.gz" template-haskellIs the given character a valid drive letter? only a-z and A-Z are letters, not isAlpha which is more unicodey template-haskellSplit a path into a drive and a path. On Posix, / is a Drive. uncurry (++) (splitDrive x) == x Windows: splitDrive "file" == ("","file") Windows: splitDrive "c:/file" == ("c:/","file") Windows: splitDrive "c:\\file" == ("c:\\","file") Windows: splitDrive "\\\\shared\\test" == ("\\\\shared\\","test") Windows: splitDrive "\\\\shared" == ("\\\\shared","") Windows: splitDrive "\\\\?\\UNC\\shared\\file" == ("\\\\?\\UNC\\shared\\","file") Windows: splitDrive "\\\\?\\UNCshared\\file" == ("\\\\?\\","UNCshared\\file") Windows: splitDrive "\\\\?\\d:\\file" == ("\\\\?\\d:\\","file") Windows: splitDrive "/d" == ("","/d") Posix: splitDrive "/test" == ("/","test") Posix: splitDrive "//test" == ("//","test") Posix: splitDrive "test/file" == ("","test/file") Posix: splitDrive "file" == ("","file") template-haskell&Join a drive and the rest of the path. Valid x => uncurry joinDrive (splitDrive x) == x Windows: joinDrive "C:" "foo" == "C:foo" Windows: joinDrive "C:\\" "bar" == "C:\\bar" Windows: joinDrive "\\\\share" "foo" == "\\\\share\\foo" Windows: joinDrive "/:" "foo" == "/:\\foo" template-haskellGet the drive from a filepath. !takeDrive x == fst (splitDrive x) template-haskellDelete the drive, if it exists. !dropDrive x == snd (splitDrive x) template-haskellDoes a path have a drive. not (hasDrive x) == null (takeDrive x) Posix: hasDrive "/foo" == True Windows: hasDrive "C:\\foo" == True Windows: hasDrive "C:foo" == True hasDrive "foo" == False hasDrive "" == False template-haskellIs an element a drive Posix: isDrive "/" == True Posix: isDrive "/foo" == False Windows: isDrive "C:\\" == True Windows: isDrive "C:\\foo" == False isDrive "" == False template-haskell*Split a filename into directory and file.   is the inverse. The first component will often end with a trailing slash. splitFileName "/directory/file.ext" == ("/directory/","file.ext") Valid x => uncurry () (splitFileName x) == x || fst (splitFileName x) == "./" Valid x => isValid (fst (splitFileName x)) splitFileName "file/bob.txt" == ("file/", "bob.txt") splitFileName "file/" == ("file/", "") splitFileName "bob" == ("./", "bob") Posix: splitFileName "/" == ("/","") Windows: splitFileName "c:" == ("c:","") template-haskellSet the filename. replaceFileName "/directory/other.txt" "file.ext" == "/directory/file.ext" Valid x => replaceFileName x (takeFileName x) == x template-haskellDrop the filename. Unlike  , this function will leave a trailing path separator on the directory. dropFileName "/directory/file.ext" == "/directory/" dropFileName x == fst (splitFileName x) template-haskellGet the file name. takeFileName "/directory/file.ext" == "file.ext" takeFileName "test/" == "" takeFileName x `isSuffixOf` x takeFileName x == snd (splitFileName x) Valid x => takeFileName (replaceFileName x "fred") == "fred" Valid x => takeFileName (x "fred") == "fred" Valid x => isRelative (takeFileName x) template-haskell0Get the base name, without an extension or path. takeBaseName "/directory/file.ext" == "file" takeBaseName "file/test.txt" == "test" takeBaseName "dave.ext" == "dave" takeBaseName "" == "" takeBaseName "test" == "test" takeBaseName (addTrailingPathSeparator x) == "" takeBaseName "file/file.tar.gz" == "file.tar" template-haskellSet the base name. replaceBaseName "/directory/other.ext" "file" == "/directory/file.ext" replaceBaseName "file/test.txt" "bob" == "file/bob.txt" replaceBaseName "fred" "bill" == "bill" replaceBaseName "/dave/fred/bob.gz.tar" "new" == "/dave/fred/new.tar" Valid x => replaceBaseName x (takeBaseName x) == x template-haskellIs an item either a directory or the last character a path separator? hasTrailingPathSeparator "test" == False hasTrailingPathSeparator "test/" == True template-haskellAdd a trailing file path separator if one is not already present. hasTrailingPathSeparator (addTrailingPathSeparator x) hasTrailingPathSeparator x ==> addTrailingPathSeparator x == x Posix: addTrailingPathSeparator "test/rest" == "test/rest/" template-haskell#Remove any trailing path separators dropTrailingPathSeparator "file/test/" == "file/test" dropTrailingPathSeparator "/" == "/" Windows: dropTrailingPathSeparator "\\" == "\\" Posix: not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x template-haskell*Get the directory name, move up one level.  takeDirectory "/directory/other.ext" == "/directory" takeDirectory x `isPrefixOf` x || takeDirectory x == "." takeDirectory "foo" == "." takeDirectory "/" == "/" takeDirectory "/foo" == "/" takeDirectory "/foo/bar/baz" == "/foo/bar" takeDirectory "/foo/bar/baz/" == "/foo/bar/baz" takeDirectory "foo/bar/baz" == "foo/bar" Windows: takeDirectory "foo\\bar" == "foo" Windows: takeDirectory "foo\\bar\\\\" == "foo\\bar" Windows: takeDirectory "C:\\" == "C:\\" template-haskell1Set the directory, keeping the filename the same. replaceDirectory "root/file.ext" "/directory/" == "/directory/file.ext" Valid x => replaceDirectory x (takeDirectory x) `equalFilePath` x template-haskell An alias for  . template-haskell0Combine two paths, assuming rhs is NOT absolute. template-haskellCombine two paths with a path separator. If the second path starts with a path separator or a drive letter, then it returns the second. The intention is that readFile (dir   file)! will access the same file as &setCurrentDirectory dir; readFile file. Posix: "/directory" "file.ext" == "/directory/file.ext" Windows: "/directory" "file.ext" == "/directory\\file.ext" "directory" "/file.ext" == "/file.ext" Valid x => (takeDirectory x takeFileName x) `equalFilePath` x Combined: Posix: "/" "test" == "/test" Posix: "home" "bob" == "home/bob" Posix: "x:" "foo" == "x:/foo" Windows: "C:\\foo" "bar" == "C:\\foo\\bar" Windows: "home" "bob" == "home\\bob" Not combined: Posix: "home" "/bob" == "/bob" Windows: "home" "C:\\bob" == "C:\\bob"Not combined (tricky):On Windows, if a filepath starts with a single slash, it is relative to the root of the current drive. In [1], this is (confusingly) referred to as an absolute path. The current behavior of  ! is to never combine these forms. Windows: "home" "/bob" == "/bob" Windows: "home" "\\bob" == "\\bob" Windows: "C:\\home" "\\bob" == "\\bob"On Windows, from [1]: "If a file name begins with only a disk designator but not the backslash after the colon, it is interpreted as a relative path to the current directory on the drive with the specified letter." The current behavior of  ! is to never combine these forms. Windows: "D:\\foo" "C:bar" == "C:bar" Windows: "C:\\foo" "C:bar" == "C:bar" template-haskell(Split a path by the directory separator. splitPath "/directory/file.ext" == ["/","directory/","file.ext"] concat (splitPath x) == x splitPath "test//item/" == ["test//","item/"] splitPath "test/item/file" == ["test/","item/","file"] splitPath "" == [] Windows: splitPath "c:\\test\\path" == ["c:\\","test\\","path"] Posix: splitPath "/file/test" == ["/","file/","test"] template-haskellJust as  5, but don't add the trailing slashes to each element.  splitDirectories "/directory/file.ext" == ["/","directory","file.ext"] splitDirectories "test/file" == ["test","file"] splitDirectories "/test/file" == ["/","test","file"] Windows: splitDirectories "C:\\test\\file" == ["C:\\", "test", "file"] Valid x => joinPath (splitDirectories x) `equalFilePath` x splitDirectories "" == [] Windows: splitDirectories "C:\\test\\\\\\file" == ["C:\\", "test", "file"] splitDirectories "/test///file" == ["/","test","file"] template-haskell!Join path elements back together. joinPath a == foldr () "" a joinPath ["/","directory/","file.ext"] == "/directory/file.ext" Valid x => joinPath (splitPath x) == x joinPath [] == "" Posix: joinPath ["test","file","path"] == "test/file/path" template-haskellEquality of two  s. If you call !System.Directory.canonicalizePath first this has a much better chance of working. Note that this doesn't follow symlinks or DOSNAM~1s. Similar to  , this does not expand "..", because of symlinks.  x == y ==> equalFilePath x y normalise x == normalise y ==> equalFilePath x y equalFilePath "foo" "foo/" not (equalFilePath "/a/../c" "/c") not (equalFilePath "foo" "/foo") Posix: not (equalFilePath "foo" "FOO") Windows: equalFilePath "foo" "FOO" Windows: not (equalFilePath "C:" "C:/") template-haskellContract a filename, based on a relative path. Note that the resulting path will never introduce ..* paths, as the presence of symlinks means ../b may not reach a/b if it starts from a/c. For a worked example see  http://neilmitchell.blogspot.co.uk/2015/10/filepaths-are-subtle-symlinks-are-hard.htmlthis blog post.The corresponding  makeAbsolute function can be found in System.Directory.  makeRelative "/directory" "/directory/file.ext" == "file.ext" Valid x => makeRelative (takeDirectory x) x `equalFilePath` takeFileName x makeRelative x x == "." Valid x y => equalFilePath x y || (isRelative x && makeRelative y x == x) || equalFilePath (y makeRelative y x) x Windows: makeRelative "C:\\Home" "c:\\home\\bob" == "bob" Windows: makeRelative "C:\\Home" "c:/home/bob" == "bob" Windows: makeRelative "C:\\Home" "D:\\Home\\Bob" == "D:\\Home\\Bob" Windows: makeRelative "C:\\Home" "C:Home\\Bob" == "C:Home\\Bob" Windows: makeRelative "/Home" "/home/bob" == "bob" Windows: makeRelative "/" "//" == "//" Posix: makeRelative "/Home" "/home/bob" == "/home/bob" Posix: makeRelative "/home/" "/home/bob/foo/bar" == "bob/foo/bar" Posix: makeRelative "/fred" "bob" == "bob" Posix: makeRelative "/file/test" "/file/test/fred" == "fred" Posix: makeRelative "/file/test" "/file/test/fred/" == "fred/" Posix: makeRelative "some/path" "some/path/a/b/c" == "a/b/c" template-haskellNormalise a file)// outside of the drive can be made blank/ ->  ./ -> ""Does not remove "..", because of symlinks. Posix: normalise "/file/\\test////" == "/file/\\test/" Posix: normalise "/file/./test" == "/file/test" Posix: normalise "/test/file/../bob/fred/" == "/test/file/../bob/fred/" Posix: normalise "../bob/fred/" == "../bob/fred/" Posix: normalise "/a/../c" == "/a/../c" Posix: normalise "./bob/fred/" == "bob/fred/" Windows: normalise "c:\\file/bob\\" == "C:\\file\\bob\\" Windows: normalise "c:\\" == "C:\\" Windows: normalise "C:.\\" == "C:" Windows: normalise "\\\\server\\test" == "\\\\server\\test" Windows: normalise "//server/test" == "\\\\server\\test" Windows: normalise "c:/file" == "C:\\file" Windows: normalise "/file" == "\\file" Windows: normalise "\\" == "\\" Windows: normalise "/./" == "\\" normalise "." == "." Posix: normalise "./" == "./" Posix: normalise "./." == "./" Posix: normalise "/./" == "/" Posix: normalise "/" == "/" Posix: normalise "bob/fred/." == "bob/fred/" Posix: normalise "//home" == "/home" template-haskellIs a FilePath valid, i.e. could you create a file like it? This function checks for invalid names, and invalid characters, but does not check if length limits are exceeded, as these are typically filesystem dependent.  isValid "" == False isValid "\0" == False Posix: isValid "/random_ path:*" == True Posix: isValid x == not (null x) Windows: isValid "c:\\test" == True Windows: isValid "c:\\test:of_test" == False Windows: isValid "test*" == False Windows: isValid "c:\\test\\nul" == False Windows: isValid "c:\\test\\prn.txt" == False Windows: isValid "c:\\nul\\file" == False Windows: isValid "\\\\" == False Windows: isValid "\\\\\\foo" == False Windows: isValid "\\\\?\\D:file" == False Windows: isValid "foo\tbar" == False Windows: isValid "nul .txt" == False Windows: isValid " nul.txt" == True template-haskellTake a FilePath and make it valid; does not change already valid FilePaths. isValid (makeValid x) isValid x ==> makeValid x == x makeValid "" == "_" makeValid "file\0name" == "file_name" Windows: makeValid "c:\\already\\/valid" == "c:\\already\\/valid" Windows: makeValid "c:\\test:of_test" == "c:\\test_of_test" Windows: makeValid "test*" == "test_" Windows: makeValid "c:\\test\\nul" == "c:\\test\\nul_" Windows: makeValid "c:\\test\\prn.txt" == "c:\\test\\prn_.txt" Windows: makeValid "c:\\test/prn.txt" == "c:\\test/prn_.txt" Windows: makeValid "c:\\nul\\file" == "c:\\nul_\\file" Windows: makeValid "\\\\\\foo" == "\\\\drive" Windows: makeValid "\\\\?\\D:file" == "\\\\?\\D:\\file" Windows: makeValid "nul .txt" == "nul _.txt" template-haskell/Is a path relative, or is it fixed to the root? Windows: isRelative "path\\test" == True Windows: isRelative "c:\\test" == False Windows: isRelative "c:test" == True Windows: isRelative "c:\\" == False Windows: isRelative "c:/" == False Windows: isRelative "c:" == True Windows: isRelative "\\\\foo" == False Windows: isRelative "\\\\?\\foo" == False Windows: isRelative "\\\\?\\UNC\\foo" == False Windows: isRelative "/foo" == True Windows: isRelative "\\foo" == True Posix: isRelative "test/path" == True Posix: isRelative "/test" == False Posix: isRelative "/" == FalseAccording to [1]:/"A UNC name of any format [is never relative]."6"You cannot use the "\?" prefix with a relative path." template-haskell not .  "isAbsolute x == not (isRelative x) template-haskellThe stripSuffix function drops the given suffix from a list. It returns Nothing if the list did not end with the suffix given, or Just the list before the suffix, if it does.5  7 7 5 (c) Neil Mitchell 2005-2014BSD3ndmitchell@gmail.comstableportableSafesO5 "(c) The University of Glasgow 2003/BSD-style (see the file libraries/base/LICENSE)libraries@haskell.org experimentalportable Trustworthy%&)*0179<=template-haskellTurn a value into a Template Haskell expression, suitable for use in a splice.template-haskell0Generate a fresh name, which cannot be captured.For example, this: .f = $(do nm1 <- newName "x" let nm2 =  "x" return ( [ nm1] (LamE [VarP nm2] ( nm1))) )will produce the splice f = \x0 -> \x -> x0In particular, the occurrence VarE nm1 refers to the binding VarP nm1', and is not captured by the binding VarP nm2.Although names generated by newName cannot  be captured , they can capture other names. For example, this: g = $(do nm1 <- newName "x" let nm2 = mkName "x" return (LamE [VarP nm2] (LamE [VarP nm1] (VarE nm2))) )will produce the splice g = \x -> \x0 -> x0since the occurrence VarE nm2+ is captured by the innermost binding of x , namely VarP nm1.template-haskellGenerate a capturable name. Occurrences of such names will be resolved according to the Haskell scoping rules at the occurrence site. For example: =f = [| pi + $(varE (mkName "pi")) |] ... g = let pi = 3 in $fIn this case, g is desugared to g = Prelude.pi + 3 Note that mkName" may be used with qualified names: mkName "Prelude.pi" See also   for a useful combinator. The above example could be rewritten using   as f = [| pi + $(dyn "pi") |]template-haskellOnly used internally template-haskell.Underlying untyped Template Haskell expression template-haskellExtract the untyped representation from the typed representation template-haskellTurn a value into a Template Haskell typed expression, suitable for use in a typed splice. template-haskellUnsafely convert an untyped code representation into a typed code representation.template-haskellOnly used internallytemplate-haskellA  instance can have any of its values turned into a Template Haskell expression. This is needed when a value used within a Template Haskell quotation is bound outside the Oxford brackets ( [| ... |] or  [|| ... ||]*) but not at the top level. As an example: 2add1 :: Int -> Q (TExp Int) add1 x = [|| x + 1 ||]2Template Haskell has no way of knowing what value x: will take on at splice-time, so it requires the type of x to be an instance of .A  instance must satisfy  $(lift x) D x and $$(liftTyped x) D x for all x, where $(...) and $$(...) are Template Haskell splices. It is additionally expected that  x D  (  x).6 instances can be derived automatically by use of the  -XDeriveLift GHC language extension: {-# LANGUAGE DeriveLift #-} module Foo where import Language.Haskell.TH.Syntax data Bar a = Bar1 a (Bar a) | Bar2 String deriving Lift!Representation-polymorphic since template-haskell-2.16.0.0.template-haskellThe  class implements the minimal interface which is necessary for desugaring quotations.The Monad m superclass is needed to stitch together the different AST fragments. is used when desugaring binding structures such as lambdas to generate fresh names.Therefore the type of an untyped quotation in GHC is `Quote m => m Exp`For many years the type of a quotation was fixed to be `Q Exp` but by more precisely specifying the minimal interface it enables the  to be extracted purely from the quotation without interacting with .template-haskellPattern in Haskell given in {}template-haskellA single data constructor.The constructors for  can roughly be divided up into two categories: those for constructors with "vanilla" syntax (, , and 0), and those for constructors with GADT syntax ( and ). The  constructor, which quantifies additional type variables and class contexts, can surround either variety of constructor. However, the type variables that it quantifies are different depending on what constructor syntax is used:If a : surrounds a constructor with vanilla syntax, then the  will only quantify  existential type variables. For example: % data Foo a = forall b. MkFoo a b In MkFoo,  will quantify b , but not a.If a 7 surrounds a constructor with GADT syntax, then the  will quantify all8 type variables used in the constructor. For example: > data Bar a b where MkBar :: (a ~ b) => c -> MkBar a b In MkBar,  will quantify a, b, and c.Multiplicity annotations for data types are currently not supported in Template Haskell (i.e. all fields represented by Template Haskell will be linear).template-haskell7An abstract type representing names in the syntax tree.s can be constructed in several ways, which come with different name-capture guarantees (see &Language.Haskell.TH.Syntax#namecapture% for an explanation of name capture):the built-in syntax 'f and ''T4 can be used to construct names, The expression 'f gives a Name which refers to the value f currently in scope, and ''T gives a Name which refers to the type T7 currently in scope. These names can never be captured. and  are similar to 'f and ''T respectively, but the Names are looked up at the point where the current splice is being run. These names can never be captured. monadically generates a new name, which can never be captured. generates a capturable name.Names constructed using newName and mkName" may be used in bindings (such as  let x = ... or x -> ...), but names constructed using lookupValueName, lookupTypeName, 'f, ''T may not.template-haskellSince the advent of ConstraintKinds, constraints are really just types. Equality constraints use the  constructor. Constraints may also be tuples of other constraints.template-haskellOne equation of a type family instance or closed type family. The arguments are the left-hand-side type and the right-hand-side result.3For instance, if you had the following type family: type family Foo (a :: k) :: k where forall k (a :: k). Foo @k a = a The  Foo @k a = a* equation would be represented as follows:  (  [ k,  a ( k)]) ( ( ( ''Foo) ( k)) ( a)) ( a) template-haskellInjectivity annotationtemplate-haskellTo avoid duplication between kinds and types, they are defined to be the same. Naturally, you would never have a type be % and you would never have a kind be , but many of the other constructors are shared. Note that the kind Bool is denoted with , not '. Similarly, tuple kinds are made with , not .template-haskell&Varieties of allowed instance overlap.template-haskell A single deriving! clause at the end of a datatype.template-haskell. => template-haskell forall -> template-haskell T a btemplate-haskell T @k ttemplate-haskell t :: ktemplate-haskell atemplate-haskell Ttemplate-haskell 'Ttemplate-haskell T + Ttemplate-haskell T + TSee  Language.Haskell.TH.Syntax#infixtemplate-haskell T :+: Ttemplate-haskell T :+: TSee  Language.Haskell.TH.Syntax#infixtemplate-haskell (T)template-haskell(,), (,,), etc.template-haskell(#,#), (#,,#), etc.template-haskell(#|#), (#||#), etc.template-haskell ->template-haskell %n ->1Generalised arrow type with multiplicity argumenttemplate-haskell ~template-haskell []template-haskell'(), '(,), '(,,), etc.template-haskell '[]template-haskell '(:)template-haskell *template-haskell  Constrainttemplate-haskell0, 1, 2, etc.template-haskell _template-haskell ?x :: ttemplate-haskell"A pattern synonym's argument type.template-haskell pattern P {x y z} = ptemplate-haskell pattern {x P y} = ptemplate-haskell pattern P { {x,y,z} } = ptemplate-haskell#A pattern synonym's directionality.template-haskell pattern P x {<-} ptemplate-haskell pattern P x {=} ptemplate-haskell  pattern P x {<-} p where P x = etemplate-haskellAs of template-haskell-2.11.0.0,  has been replaced by .template-haskellAs of template-haskell-2.11.0.0,  has been replaced by .template-haskellAs of template-haskell-2.11.0.0,  has been replaced by .template-haskell C { {-# UNPACK #-} !}atemplate-haskell C Int atemplate-haskell C { v :: Int, w :: a }template-haskell Int :+ atemplate-haskell forall a. Eq a => C [a]template-haskell C :: a -> b -> T b Inttemplate-haskell C :: { v :: Int } -> T b Inttemplate-haskellUnlike  and ,  refers to the strictness annotations that the compiler chooses for a data constructor field, which may be different from what is written in source code.2Note that non-unpacked strict fields are assigned  when a bang would be inappropriate, such as the field of a newtype constructor and fields that have an unlifted type.See  for more information.template-haskell"Field inferred to not have a bang.template-haskellField inferred to have a bang.template-haskellField inferred to be unpacked.template-haskell corresponds to strictness annotations found in the source code.4This may not agree with the annotations returned by . See  for more information.template-haskell C atemplate-haskell C {~}atemplate-haskell C {!}atemplate-haskell< corresponds to unpack annotations found in the source code.4This may not agree with the annotations returned by . See  for more information.template-haskell C atemplate-haskell C { {-# NOUNPACK #-} } atemplate-haskell C { {-# UNPACK #-} } atemplate-haskell +{ {-# COMPLETE C_1, ..., C_i [ :: T ] #-} }template-haskellCommon elements of  and . By analogy with "head" for type classes and type class instances as defined in 0Type classes: an exploration of the design space, the TypeFamilyHead; is defined to be the elements of the declaration between  type family and where.template-haskell8A pattern synonym's type. Note that a pattern synonym's fully specified type has a peculiar shape coming with two forall quantifiers and two constraint contexts. For example, consider the pattern synonym 'pattern P x1 x2 ... xn = *P's complete type is of the following form pattern P :: forall universals. required constraints => forall existentials. provided constraints => t1 -> t2 -> ... -> tn -> tconsisting of four parts: the (possibly empty lists of) universally quantified type variables and required constraints on them.the (possibly empty lists of) existentially quantified type variables and the provided constraints on them. the types t1, t2, .., tn of x1, x2, .., xn, respectively the type t of , mentioning only universals.Pattern synonym types interact with TH when (a) reifying a pattern synonym, (b) pretty printing, or (c) specifying a pattern synonym's type signature explicitly:/Reification always returns a pattern synonym's fully( specified type in abstract syntax.Pretty printing via  abbreviates a pattern synonym's type unambiguously in concrete syntax: The rule of thumb is to print initial empty universals and the required context as () =>, if existentials and a provided context follow. If only universals and their required context, but no existentials are specified, only the universals and their required context are printed. If both or none are specified, so both (or none) are printed.>When specifying a pattern synonym's type explicitly with  either one of the universals, the existentials, or their contexts may be left empty.See the GHC user's guide for more information on pattern synonyms and their types:  https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#pattern-synonyms.template-haskellA "standard" derived instancetemplate-haskell -XDeriveAnyClasstemplate-haskell -XGeneralizedNewtypeDerivingtemplate-haskell  -XDerivingViatemplate-haskell { deriving stock (Eq, Ord) }template-haskell { f p1 p2 = b where decs }template-haskell { p = b where decs }template-haskell { data Cxt x => T x = A x | B (T x) deriving (Z,W) deriving stock Eq }template-haskell { newtype Cxt x => T x = A (B x) deriving (Z,W Q) deriving stock Eq }template-haskell !{ type data T x = A x | B (T x) }template-haskell { type T x = (x,x) }template-haskell  { class Eq a => Ord a where ds }template-haskell { instance {-# OVERLAPS #-} Show w => Show [w] where ds }template-haskell { length :: [a] -> Int }template-haskell { type TypeRep :: k -> Type }template-haskell -{ foreign import ... } { foreign export ... }template-haskell { infix 3 foo }template-haskell { default (Integer, Double) }template-haskellpragmastemplate-haskell+data families (may also appear in [Dec] of  and )template-haskell { data instance Cxt x => T [x] = A x | B (T x) deriving (Z,W) deriving stock Eq }template-haskell { newtype instance Cxt x => T [x] = A (B x) deriving (Z,W) deriving stock Eq }template-haskell { type instance ... }template-haskell0open type families (may also appear in [Dec] of  and )template-haskell 3{ type family F a b = (r :: *) | r -> a where ... }template-haskell ({ type role T nominal representational }template-haskell 0{ deriving stock instance Ord a => Ord (Foo a) }template-haskell &{ default size :: Data a => a -> Int }template-haskellPattern Synonymstemplate-haskell#A pattern synonym's type signature.template-haskell  { ?x = expr }Implicit parameter binding declaration. Can only be used in let and where clauses which consist entirely of implicit bindings.template-haskell p <- etemplate-haskell { let { x=e1; y=e2 } }template-haskell etemplate-haskellx <- e1 | s2, s3 | s4 (in )template-haskell rec { s1; s2 }template-haskell f x { | odd x } = xtemplate-haskell &f x { | Just y <- x, Just z <- y } = ztemplate-haskell +f p { | e1 = e2 | e3 = e4 } where dstemplate-haskell f p { = e } where dstemplate-haskell { x }template-haskell "data T1 = C1 t1 t2; p = {C1} e1 e2template-haskell  { 5 or 'c'}template-haskell { f x }template-haskell  { f @Int }template-haskell %{x + y} or {(x+)} or {(+ x)} or {(+)}template-haskell {x + y}See  Language.Haskell.TH.Syntax#infixtemplate-haskell { (e) }See  Language.Haskell.TH.Syntax#infixtemplate-haskell { \ p1 p2 -> e }template-haskell { \case m1; m2 }template-haskell { \cases m1; m2 }template-haskell  { (e1,e2) }The  + is necessary for handling tuple sections. (1,) translates to 'TupE [Just (LitE (IntegerL 1)),Nothing]template-haskell { (# e1,e2 #) }The  + is necessary for handling tuple sections.  (# 'c', #) translates to -UnboxedTupE [Just (LitE (CharL 'c')),Nothing]template-haskell  { (#|e|#) }template-haskell { if e1 then e2 else e3 }template-haskell { if | g1 -> e1 | g2 -> e2 }template-haskell { let { x=e1; y=e2 } in e3 }template-haskell { case e of m1; m2 }template-haskell{ do { p <- e1; e2 } }1 or a qualified do if the module name is presenttemplate-haskell!{ mdo { x <- e1 y; y <- e2 x; } }2 or a qualified mdo if the module name is presenttemplate-haskell  { [ (x,y) | x <- xs, y <- ys ] }3The result expression of the comprehension is the last of the s, and should be a .E.g. translation: [ f x | x <- xs ] CompE [BindS (VarP x) (VarE xs), NoBindS (AppE (VarE f) (VarE x))]template-haskell { [ 1 ,2 .. 10 ] }template-haskell  { [1,2,3] }template-haskell  { e :: t }template-haskell { T { x = y, z = w } }template-haskell { (f x) { z = w } }template-haskell  { static e }template-haskell { _x }This is used for holes or unresolved identifiers in AST quotes. Note that it could either have a variable name or constructor name.template-haskell{ #x } ( Overloaded label )template-haskell{ ?x } ( Implicit parameter )template-haskell { exp.field } ( Overloaded Record Dot )template-haskell(.x) or (.x.y) (Record projections)template-haskell f { p1 p2 = body where decs }template-haskell $case e of { pat -> body where decs }template-haskell  { 5 or 'c' }template-haskell { x }template-haskell  { (p1,p2) }template-haskell { (# p1,p2 #) }template-haskell  { (#|p|#) }template-haskell 'data T1 = C1 t1 t2; {C1 @ty1 p1 p2} = etemplate-haskell foo ({x :+ y}) = etemplate-haskell foo ({x :+ y}) = eSee  Language.Haskell.TH.Syntax#infixtemplate-haskell {(p)}See  Language.Haskell.TH.Syntax#infixtemplate-haskell { ~p }template-haskell { !p }template-haskell  { x @ p }template-haskell { _ }template-haskell f (Pt { pointx = x }) = g xtemplate-haskell  { [1,2,3] }template-haskell  { p :: t }template-haskell  { e -> p }template-haskell#Raw bytes embedded into the binary.Avoid using Bytes constructor directly as it is likely to change in the future. Use helpers such as mkBytes$ in Language.Haskell.TH.Lib instead.template-haskellPointer to the datatemplate-haskellOffset from the pointertemplate-haskellNumber of bytestemplate-haskellUsed for overloaded and non-overloaded literals. We don't have a good way to represent non-overloaded literals at the moment. Maybe that doesn't matter?template-haskell!A primitive C-style string, type  template-haskellSome raw bytes, type  :template-haskell describes a single instance of a class or type function. It is just a ,, but guaranteed to be one of the following: (with empty []) or  (with empty derived [])template-haskellIn #, is the type constructor unlifted?template-haskellIn , arity of the type constructortemplate-haskellIn , , and , the total number of s. For example, (#|#) has a  of 2.template-haskellIn  and =, the number associated with a particular data constructor. s are one-indexed and should never exceed the value of its corresponding . For example:(#_|#) has  1 (out of a total  of 2)(#|_#) has  2 (out of a total  of 2)template-haskellIn  and ", name of the parent class or typetemplate-haskellObtained from  in the  Monad.template-haskell'Contains the import list of the module.template-haskellObtained from  in the  Monad.template-haskell-A class, with a list of its visible instancestemplate-haskellA class methodtemplate-haskellA "plain" type constructor. "Fancier" type constructors are returned using  or  as appropriate. At present, this reified declaration will never have derived instances attached to it (if you wish to check for an instance, see ).template-haskellA type or data family, with a list of its visible instances. A closed type family is returned with 0 instances.template-haskellA "primitive" type constructor, which can't be expressed with a  . Examples: (->), Int#.template-haskellA data constructortemplate-haskellA pattern synonymtemplate-haskell7A "value" variable (as opposed to a type variable, see ).The  Maybe Dec field contains Just the declaration which defined the variable - including the RHS of the declaration - or else Nothing, in the case where the RHS is unavailable to the compiler. At present, this value is always Nothing: returning the RHS has not yet been implemented because of lack of interest.template-haskellA type variable.The Type field contains the type which underlies the variable. At present, this is always  theName5, but future changes may permit refinement of this.template-haskellUniq5 is used by GHC to distinguish names from each other.template-haskell Variablestemplate-haskellData constructorstemplate-haskellType constructors and classes; Haskell has them in the same name space for now.template-haskell&An unqualified name; dynamically boundtemplate-haskell#A qualified name; dynamically boundtemplate-haskellA unique local nametemplate-haskell&Local name bound outside of the TH ASTtemplate-haskellGlobal name bound outside of the TH AST: An original name (occurrences only, not binders) Need the namespace too to be sure which thing we are namingtemplate-haskellObtained from  and .template-haskellUnderlying monadic valuetemplate-haskell(Represents an expression which has type a. Built on top of 6, typed expressions allow for type-safe splicing via:typed quotes, written as  [|| ... ||] where ...4 is an expression; if that expression has type a#, then the quotation has type  ( a)1typed splices inside of typed quotes, written as $$(...) where ...) is an arbitrary expression of type  ( a)Traditional expression quotes and splices let us construct ill-typed expressions:.fmap ppr $ runQ [| True == $( [| "foo" |] ) |]#GHC.Types.True GHC.Classes.== "foo"#GHC.Types.True GHC.Classes.== "foo" error: @ Couldn't match expected type @Bool@ with actual type @[Char]@6 @ In the second argument of @(==)@, namely @"foo"@& In the expression: True == "foo"1 In an equation for @it@: it = True == "foo"3With typed expressions, the type error occurs when  constructing" the Template Haskell expression:3fmap ppr $ runQ [|| True == $$( [|| "foo" ||] ) ||] error:. @ Couldn't match type @[Char]@ with @Bool@" Expected type: Q (TExp Bool)$ Actual type: Q (TExp [Char])5 @ In the Template Haskell quotation [|| "foo" ||]& In the expression: [|| "foo" ||]6 In the Template Haskell splice $$([|| "foo" ||])!Representation-polymorphic since template-haskell-2.16.0.0.template-haskellDiscard the type annotation and produce a plain Template Haskell expression!Representation-polymorphic since template-haskell-2.16.0.0.template-haskell4Annotate the Template Haskell expression with a typeThis is unsafe because GHC cannot check for you that the expression really does have the type you claim it has.!Representation-polymorphic since template-haskell-2.16.0.0.template-haskell4Lift a monadic action producing code into the typed  representationtemplate-haskellModify the ambient monad used during code generation. For example, you can use  to handle a state effect:  handleState :: Code (StateT Int Q) a -> Code Q a handleState = hoistCode (flip runState 0) template-haskellVariant of (>>=) which allows effectful computations to be injected into code generation.template-haskellVariant of (>>) which allows effectful computations to be injected into code generation.template-haskell7A useful combinator for embedding monadic actions into   myCode :: ... => Code m a myCode = joinCode $ do x <- someSideEffect return (makeCodeWith x) template-haskell>Report an error (True) or warning (False), but carry on; use   to stop.template-haskellReport an error to the user, but allow the current splice's computation to carry on. To abort the computation, use  .template-haskell+Report a warning to the user, and carry on.template-haskellRecover from errors raised by  or  .template-haskellLook up the given name in the (type namespace of the) current splice's scope. See %Language.Haskell.TH.Syntax#namelookup for more details.template-haskellLook up the given name in the (value namespace of the) current splice's scope. See %Language.Haskell.TH.Syntax#namelookup for more details.template-haskell looks up information about the +. It will fail with a compile error if the  is not visible. A  is visible if it is imported or defined in a prior top-level declaration group. See the documentation for  for more details. Bool, and reifyType ''Bool returns Type. This works even if there's no explicit signature and the type or kind is inferred.template-haskellTemplate Haskell is capable of reifying information about types and terms defined in previous declaration groups. Top-level declaration splices break up declaration groups.For an example, consider this code block. We define a datatype X and then try to call  on the datatype. module Check where data X = X deriving Eq $(do info <- reify ''X runIO $ print info ) (This code fails to compile, noting that X1 is not available for reification at the site of . We can fix this by creating a new declaration group using an empty top-level splice: data X = X deriving Eq $(pure []) $(do info <- reify ''X runIO $ print info )  We provide  as a means of documenting this behavior and providing a name for the pattern.2Since top level splices infer the presence of the $( ... ) brackets, we can also write: data X = X deriving Eq newDeclarationGroup $(do info <- reify ''X runIO $ print info ) template-haskellreifyInstances nm tys returns a list of all visible instances (see below for "visible") of nm tys. That is, if nm is the name of a type class, then all instances of this class at the types tys! are returned. Alternatively, if nm is the name of a data family or type family, all instances of this family at the types tys are returned.Note that this is a "shallow" test; the declarations returned merely have instance heads which unify with nm tys(, they need not actually be satisfiable.reifyInstances ''Eq [  2 ``  ''A ``  ''B ] contains the "instance (Eq a, Eq b) => Eq (a, b) regardless of whether A and B themselves implement  reifyInstances ''Show [  ( "a") ]* produces every available instance of  There is one edge case: reifyInstances ''Typeable tys9 currently always produces an empty list (no matter what tys are given).In principle, the *visible* instances are * all instances defined in a prior top-level declaration group (see docs on newDeclarationGroup), or * all instances defined in any module transitively imported by the module being compiledHowever, actually searching all modules transitively below the one being compiled is unreasonably expensive, so reifyInstances will report only the instance for modules that GHC has had some cause to visit during this compilation. This is a shortcoming: reifyInstances might fail to report instances for a type that is otherwise unusued, or instances defined in a different component. You can work around this shortcoming by explicitly importing the modules whose instances you want to be visible. GHC issue  =https://gitlab.haskell.org/ghc/ghc/-/issues/20529#note_388980#20529! has some discussion around this.template-haskell reifyRoles nm returns the list of roles associated with the parameters (both visible and invisible) of the tycon nm . Fails if nm cannot be found or is not a tycon. The returned list should never contain .An invisible parameter to a tycon is often a kind parameter. For example, if we have 9type Proxy :: forall k. k -> Type data Proxy a = MkProxy and reifyRoles Proxy, we will get [, ]. The  is the role of the invisible k/ parameter. Kind parameters are always nominal.template-haskellreifyAnnotations target2 returns the list of annotations associated with target. Only the annotations that are appropriately typed is returned. So if you have Int and String annotations for the same target, you have to call this function twice.template-haskellreifyModule mod# looks up information about module mod. To look up the current module, call this function with the return value of .template-haskellreifyConStrictness nm looks up the strictness information for the fields of the constructor with the name nm-. Note that the strictness information that  returns may not correspond to what is written in the source code. For example, in the following data declaration: data Pair a = Pair a a  would return [, DecidedLazy]0 under most circumstances, but it would return [, DecidedStrict] if the  -XStrictData language extension was enabled.template-haskell%Is the list of instances returned by  nonempty?If you're confused by an instance not being visible despite being defined in the same module and above the splice in question, see the docs for  for a possible explanation.template-haskell2The location at which this computation is spliced.template-haskellThe 1 function lets you run an I/O computation in the  monad. Take care: you are guaranteed the ordering of calls to  within a single ? computation, but not about the order in which splices are run.Note: for various murky reasons, stdout and stderr handles are not necessarily flushed when the compiler finishes running, so you should flush them yourself.template-haskellGet the package root for the current package which is being compiled. This can be set explicitly with the -package-root flag but is normally just the current working directory.The motivation for this flag is to provide a principled means to remove the assumption from splices that they will be executed in the directory where the cabal file resides. Projects such as haskell-language-server can't and don't change directory when compiling files but instead set the -package-root flag appropiately.template-haskellThe input is a filepath, which if relative is offset by the package root.template-haskellRecord external files that runIO is using (dependent upon). The compiler can then recognize that it should re-compile the Haskell file when an external file changes.Expects an absolute file path.Notes:ghc -M does not know about these dependencies - it does not execute TH.The dependency is based on file content, not a modification timetemplate-haskellObtain a temporary file path with the given suffix. The compiler will delete this file after compilation.template-haskellAdd additional top-level declarations. The added declarations will be type checked along with the current declaration group.template-haskelltemplate-haskellEmit a foreign file which will be compiled and linked to the object for the current module. Currently only languages that can be compiled with the C compiler are supported, and the flags passed as part of -optc will be also applied to the C compiler invocation that will compile them.0Note that for non-C languages (for example C++) extern C directives must be used to get symbols that we can access from Haskell.To get better errors, it is recommended to use #line pragmas when emitting C files, e.g. {-# LANGUAGE CPP #-} ... addForeignSource LangC $ unlines [ "#line " ++ show (819 + 1) ++ " " ++ show "libraries/template-haskell/Language/Haskell/TH/Syntax.hs" , ... ]template-haskellSame as , but expects to receive a path pointing to the foreign file instead of a  ; of its contents. Consider using this in conjunction with .This is a good alternative to 9 when you are trying to directly link in an object file.template-haskellAdd a finalizer that will run in the Q monad after the current module has been type checked. This only makes sense when run within a top-level splice.The finalizer is given the local type environment at the splice point. Thus  is able to find the local definitions when executed inside the finalizer.template-haskell/Adds a core plugin to the compilation pipeline.addCorePlugin m' has almost the same effect as passing  -fplugin=m to ghc in the command line. The major difference is that the plugin module m must not belong to the current package. When TH executes, it is too late to tell the compiler that we needed to compile first a plugin module in the current package.template-haskellGet state from the  monad. Note that the state is local to the Haskell module in which the Template Haskell expression is executed.template-haskellReplace the state in the  monad. Note that the state is local to the Haskell module in which the Template Haskell expression is executed.template-haskellDetermine whether the given language extension is enabled in the  monad.template-haskell%List all enabled language extensions.template-haskellAdd Haddock documentation to the specified location. This will overwrite any documentation at the location if it already exists. This will reify the specified name, so it must be in scope when you call it. If you want to add documentation to something that you are currently splicing, you can use  e.g. do let nm = mkName "x" addModFinalizer $ putDoc (DeclDoc nm) "Hello" [d| $(varP nm) = 42 |]The helper functions  withDecDoc and  withDecsDoc$ will do this for you, as will the funD_doc and other _doc0 combinators. You most likely want to have the -haddock flag turned on when using this. Adding documentation to anything outside of the current module will cause an error.template-haskellRetreives the Haddock documentation at the specified location, if one exists. It can be used to read documentation on things defined outside of the current module, provided that those modules were compiled with the -haddock flag.template-haskell is an internal utility function for constructing generic conversion functions from types with   instances to various quasi-quoting representations. See the source of  and  for two example usages: mkCon, mkLit and appQ are overloadable to account for different syntax for expressions and patterns; antiQ allows you to override type-specific cases, a common usage is just  const Nothing#, which results in no overloading.template-haskell converts a value to a  representation of the same value, in the SYB style. It is generalized to take a function override type-specific cases; see # for a more commonly used variant.template-haskell is a variant of  in the - type class which works for any type with a   instance.template-haskell converts a value to a  representation of the same value, in the SYB style. It takes a function to handle type-specific cases, alternatively, pass  const Nothing to get default behavior.template-haskell#The name without its module prefix.ExamplesnameBase ''Data.Either.Either"Either"nameBase (mkName "foo")"foo"nameBase (mkName "Module.foo")"foo"template-haskell&Module prefix of a name, if it exists.ExamplesnameModule ''Data.Either.EitherJust "Data.Either"nameModule (mkName "foo")Nothing nameModule (mkName "Module.foo") Just "Module"template-haskellA name's package, if it exists.Examples namePackage ''Data.Either.Either Just "base"namePackage (mkName "foo")Nothing!namePackage (mkName "Module.foo")Nothingtemplate-haskellReturns whether a name represents an occurrence of a top-level variable (), data constructor (%), type constructor, or type class (#). If we can't be sure, it returns  .ExamplesnameSpace 'Prelude.id Just VarNamenameSpace (mkName "id")2Nothing -- only works for top-level variable namesnameSpace 'Data.Maybe.Just Just DataNamenameSpace ''Data.Maybe.MaybeJust TcClsNamenameSpace ''Data.Ord.OrdJust TcClsNametemplate-haskellOnly used internallytemplate-haskell4Used for 'x etc, but not available to the programmertemplate-haskellTuple data constructortemplate-haskellTuple type constructortemplate-haskellUnboxed tuple data constructortemplate-haskellUnboxed tuple type constructortemplate-haskellUnboxed sum data constructortemplate-haskellUnboxed sum type constructortemplate-haskell(Highest allowed operator precedence for  constructor (answer: 9)template-haskellDefault fixity: infixl 9template-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskell Produces an   literal from the NUL-terminated C-string starting at the given memory address.template-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskelltemplate-haskellIf the function passed to  ; inspects its argument, the resulting action will throw a  .template-haskelltemplate-haskell template-haskell  (Eq a, Ord b)template-haskell { {-# INLINE [1] foo #-} }template-haskell { data family T a b c :: * }template-haskell -{ type family T a b c = (r :: *) | r -> a b }template-haskell{ pattern P v1 v2 .. vn <- p }! unidirectional or { pattern P v1 v2 .. vn = p }! implicit bidirectional or ?{ pattern P v1 v2 .. vn <- p where P v1 v2 .. vn = e } explicit bidirectionalalso, besides prefix pattern synonyms, both infix and record pattern synonyms are supported. See  for detailstemplate-haskellLine and character positiontemplate-haskell Fresh namestemplate-haskellReport an error (True) or warning (False) ...but carry on; use   to stoptemplate-haskellthe error handlertemplate-haskellaction which may failtemplate-haskellRecover from the monadic  template-haskellhandler to invoke on failuretemplate-haskellcomputation to run        *Quasi-quoting support for Template HaskellSafe,(template-haskell5Quasi-quoter for expressions, invoked by quotes like lhs = $[q|...]template-haskell2Quasi-quoter for patterns, invoked by quotes like f $[q|...] = rhstemplate-haskell:Quasi-quoter for declarations, invoked by top-level quotestemplate-haskell/Quasi-quoter for types, invoked by quotes like  f :: $[q|...]template-haskellThe  type, a value q) of this type can be used in the syntax [q| ... string to parse ...|] . In fact, for convenience, a  actually defines multiple quasiquoters to be used in different splice contexts; if you are only interested in defining a quasiquoter to be used for expressions, you would define a  with only 6, and leave the other fields stubbed out with errors.template-haskell takes a  and lifts it into one that read the data out of a file. For example, suppose asmq is an assembly-language quoter, so that you can write [asmq| ld r1, r2 |] as an expression. Then if you define asmq_f = quoteFile asmq<, then the quote [asmq_f|foo.s|] will take input from file "foo.s" instead of the inline text  Safe2"template-haskellReturns   if the document is empty template-haskellAn empty document template-haskellA ';' character template-haskellA ',' character template-haskellA : character template-haskell A "::" string template-haskellA space character template-haskellA '=' character template-haskell A "->" string template-haskellA '(' character template-haskellA ')' character template-haskellA '[' character template-haskellA ']' character template-haskellA '{' character template-haskellA '}' character template-haskellWrap document in (...) template-haskellWrap document in [...] template-haskellWrap document in {...} template-haskellWrap document in '...' template-haskellWrap document in "..." template-haskellBeside template-haskellList version of  template-haskellBeside, separated by space template-haskellList version of  template-haskell5Above; if there is no overlap it "dovetails" the two template-haskellAbove, without dovetailing. template-haskellList version of  template-haskellEither hcat or vcat template-haskellEither hsep or vcat template-haskell"Paragraph fill" version of cat template-haskell"Paragraph fill" version of sep template-haskellNested template-haskell "hang d1 n d2 = sep [d1, nest n d2] template-haskell punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn]/ /  6 6 5 5Safe51 template-haskell.Pretty prints a pattern synonym type signature template-haskellPretty prints a pattern synonym's type; follows the usual conventions to print a pattern synonym type compactly, yet unambiguously. See the note on  and the section on pattern synonyms in the GHC user's guide for more information.  Trustworthy0C*template-haskell Use with >+template-haskell Use with Z6template-haskell Lambda-case (case)7template-haskellLambda-cases (cases)Itemplate-haskell staticE x = [| static x |]utemplate-haskellPattern synonym declarationvtemplate-haskellPattern synonym type signaturextemplate-haskellImplicit parameter binding declaration. Can only be used in let and where clauses which consist entirely of implicit bindings. template-haskell!Representation-polymorphic since template-haskell-2.17.0.0. template-haskell*Dynamically binding a variable (unhygenic) template-haskellSingle-arg lambda template-haskellpure the Module at the place of splicing. Can be used as an input for . template-haskellAttaches Haddock documentation to the declaration provided. Unlike , the names do not need to be in scope when calling this function so it can be used for quoted declarations and anything else currently being spliced. Not all declarations can have documentation attached to them. For those that can't,  3 will return it unchanged without any side effects. template-haskell Variant of   that applies the same documentation to multiple declarations. Useful for documenting quoted declarations. template-haskell Variant of Z% that attaches Haddock documentation. template-haskell Variant of \% that attaches Haddock documentation. template-haskell Variant of ]% that attaches Haddock documentation. template-haskell Variant of |% that attaches Haddock documentation. template-haskell Variant of k% that attaches Haddock documentation. template-haskell Variant of l% that attaches Haddock documentation. template-haskell Variant of u% that attaches Haddock documentation. template-haskell7Document a data/newtype constructor with its arguments. template-haskell#Documentation to attach to functiontemplate-haskell$Documentation to attach to arguments template-haskellList of constructors, documentation for the constructor, and documentation for the argumentstemplate-haskell/Documentation to attach to the data declaration template-haskellThe constructor, documentation for the constructor, and documentation for the argumentstemplate-haskell2Documentation to attach to the newtype declaration template-haskellList of constructors, documentation for the constructor, and documentation for the argumentstemplate-haskell/Documentation to attach to the data declaration template-haskellList of constructors, documentation for the constructor, and documentation for the argumentstemplate-haskell3Documentation to attach to the instance declaration template-haskellThe constructor, documentation for the constructor, and documentation for the argumentstemplate-haskell3Documentation to attach to the instance declaration template-haskell.Documentation to attach to the pattern synonymtemplate-haskell0Documentation to attach to the pattern arguments !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~         !"#$%&'()UVWXY RQ S T*+ ,-./0 12345 6789:;<=>?M@ EFGH PIJKLNOABCD[Z^\]|_ `aybopqzc{defgh wklmijnr stuvx}  ~    SafeG template-haskellCreate a Bytes datatype representing raw bytes to be embedded into the program/library binary. template-haskellPointer to the datatemplate-haskellOffset from the pointertemplate-haskellNumber of bytes       !"#$%&'()RQ S T*+ ,JKL-.I/0 12345 67 :;<=> EFGH PNOABCD @UVWXY   ~  }   [Z  `ay tr m  opqzbcdef h wuvx        !"#$%&'()RQ S T*+ ,JKL-.I/0 12345 67 :;<=> EFGH PNOABCD @UVWXY   ~  }   [Z  `ay tr m  opqzbcdef h wuvx  Safe-InferredK template-haskellModule over monad operator for   SafeK         !"#$%&'()RQ S T*+ ,JKL-.I/0 12345 67 :;<=> EFGH PNOABCD @UVWXY   ~  }   [Z  `ay tr m  opqzbcdef h wuvx    (c) Neil Mitchell 2005-2014BSD3ndmitchell@gmail.comstableportable Safe-InferredY9 template-haskell*Is the operating system Unix or Linux like template-haskell$Is the operating system Windows like template-haskellThe character that separates directories. In the case where more than one character is possible,   is the 'ideal' one. Windows: pathSeparator == '\\' Posix: pathSeparator == '/' isPathSeparator pathSeparator template-haskell$The list of all possible separators. Windows: pathSeparators == ['\\', '/'] Posix: pathSeparators == ['/'] pathSeparator `elem` pathSeparators template-haskellRather than using (==  )5, use this. Test if something is a path separator. .isPathSeparator a == (a `elem` pathSeparators) template-haskellThe character that is used to separate the entries in the $PATH environment variable. Windows: searchPathSeparator == ';' Posix: searchPathSeparator == ':' template-haskell"Is the character a file separator? 5isSearchPathSeparator a == (a == searchPathSeparator) template-haskellFile extension character extSeparator == '.' template-haskell(Is the character an extension character? 'isExtSeparator a == (a == extSeparator) template-haskellTake a string, split it on the   character. Blank items are ignored on Windows, and converted to .> on Posix. On Windows path elements are stripped of quotes."Follows the recommendations in http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html Posix: splitSearchPath "File1:File2:File3" == ["File1","File2","File3"] Posix: splitSearchPath "File1::File2:File3" == ["File1",".","File2","File3"] Windows: splitSearchPath "File1;File2;File3" == ["File1","File2","File3"] Windows: splitSearchPath "File1;;File2;File3" == ["File1","File2","File3"] Windows: splitSearchPath "File1;\"File2\";File3" == ["File1","File2","File3"] template-haskellGet a list of  s in the $PATH variable. template-haskellSplit on the extension.   is the inverse. splitExtension "/directory/path.ext" == ("/directory/path",".ext") uncurry (++) (splitExtension x) == x Valid x => uncurry addExtension (splitExtension x) == x splitExtension "file.txt" == ("file",".txt") splitExtension "file" == ("file","") splitExtension "file/file.txt" == ("file/file",".txt") splitExtension "file.txt/boris" == ("file.txt/boris","") splitExtension "file.txt/boris.ext" == ("file.txt/boris",".ext") splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred") splitExtension "file/path.txt/" == ("file/path.txt/","") template-haskell%Get the extension of a file, returns "" for no extension, .ext otherwise. takeExtension "/directory/path.ext" == ".ext" takeExtension x == snd (splitExtension x) Valid x => takeExtension (addExtension x "ext") == ".ext" Valid x => takeExtension (replaceExtension x "ext") == ".ext" template-haskell "ext" == "/directory/path.ext" "/directory/path.txt" -<.> ".ext" == "/directory/path.ext" "foo.o" -<.> "c" == "foo.c" template-haskellSet the extension of a file, overwriting one if already present, equivalent to  . replaceExtension "/directory/path.txt" "ext" == "/directory/path.ext" replaceExtension "/directory/path.txt" ".ext" == "/directory/path.ext" replaceExtension "file.txt" ".bob" == "file.bob" replaceExtension "file.txt" "bob" == "file.bob" replaceExtension "file" ".bob" == "file.bob" replaceExtension "file.txt" "" == "file" replaceExtension "file.fred.bob" "txt" == "file.fred.txt" replaceExtension x y == addExtension (dropExtension x) y template-haskellAdd an extension, even if there is already one there, equivalent to  . "/directory/path" <.> "ext" == "/directory/path.ext" "/directory/path" <.> ".ext" == "/directory/path.ext" template-haskell0Remove last extension, and the "." preceding it. dropExtension "/directory/path.ext" == "/directory/path" dropExtension x == fst (splitExtension x) template-haskellAdd an extension, even if there is already one there, equivalent to  . addExtension "/directory/path" "ext" == "/directory/path.ext" addExtension "file.txt" "bib" == "file.txt.bib" addExtension "file." ".bib" == "file..bib" addExtension "file" ".bib" == "file.bib" addExtension "/" "x" == "/.x" addExtension x "" == x Valid x => takeFileName (addExtension (addTrailingPathSeparator x) "ext") == ".ext" Windows: addExtension "\\\\share" ".txt" == "\\\\share\\.txt" template-haskell*Does the given filename have an extension? hasExtension "/directory/path.ext" == True hasExtension "/directory/path" == False null (takeExtension x) == not (hasExtension x) template-haskell5Does the given filename have the specified extension? "png" `isExtensionOf` "/directory/file.png" == True ".png" `isExtensionOf` "/directory/file.png" == True ".tar.gz" `isExtensionOf` "bar/foo.tar.gz" == True "ar.gz" `isExtensionOf` "bar/foo.tar.gz" == False "png" `isExtensionOf` "/directory/file.png.jpg" == False "csv/table.csv" `isExtensionOf` "/data/csv/table.csv" == False template-haskell2Drop the given extension from a FilePath, and the "." preceding it. Returns  : if the FilePath does not have the given extension, or  . and the part before the extension if it does.+This function can be more predictable than  5, especially if the filename might itself contain . characters. stripExtension "hs.o" "foo.x.hs.o" == Just "foo.x" stripExtension "hi.o" "foo.x.hs.o" == Nothing dropExtension x == fromJust (stripExtension (takeExtension x) x) dropExtensions x == fromJust (stripExtension (takeExtensions x) x) stripExtension ".c.d" "a.b.c.d" == Just "a.b" stripExtension ".c.d" "a.b..c.d" == Just "a.b." stripExtension "baz" "foo.bar" == Nothing stripExtension "bar" "foobar" == Nothing stripExtension "" x == Just x template-haskellSplit on all extensions. splitExtensions "/directory/path.ext" == ("/directory/path",".ext") splitExtensions "file.tar.gz" == ("file",".tar.gz") uncurry (++) (splitExtensions x) == x Valid x => uncurry addExtension (splitExtensions x) == x splitExtensions "file.tar.gz" == ("file",".tar.gz") template-haskellDrop all extensions. dropExtensions "/directory/path.ext" == "/directory/path" dropExtensions "file.tar.gz" == "file" not $ hasExtension $ dropExtensions x not $ any isExtSeparator $ takeFileName $ dropExtensions x template-haskellGet all extensions. takeExtensions "/directory/path.ext" == ".ext" takeExtensions "file.tar.gz" == ".tar.gz" template-haskellReplace all extensions of a file with a new extension. Note that   and   both work for adding multiple extensions, so only required when you need to drop all extensions first. replaceExtensions "file.fred.bob" "txt" == "file.txt" replaceExtensions "file.fred.bob" "tar.gz" == "file.tar.gz" template-haskellIs the given character a valid drive letter? only a-z and A-Z are letters, not isAlpha which is more unicodey template-haskellSplit a path into a drive and a path. On Posix, / is a Drive. uncurry (++) (splitDrive x) == x Windows: splitDrive "file" == ("","file") Windows: splitDrive "c:/file" == ("c:/","file") Windows: splitDrive "c:\\file" == ("c:\\","file") Windows: splitDrive "\\\\shared\\test" == ("\\\\shared\\","test") Windows: splitDrive "\\\\shared" == ("\\\\shared","") Windows: splitDrive "\\\\?\\UNC\\shared\\file" == ("\\\\?\\UNC\\shared\\","file") Windows: splitDrive "\\\\?\\UNCshared\\file" == ("\\\\?\\","UNCshared\\file") Windows: splitDrive "\\\\?\\d:\\file" == ("\\\\?\\d:\\","file") Windows: splitDrive "/d" == ("","/d") Posix: splitDrive "/test" == ("/","test") Posix: splitDrive "//test" == ("//","test") Posix: splitDrive "test/file" == ("","test/file") Posix: splitDrive "file" == ("","file") template-haskell&Join a drive and the rest of the path. Valid x => uncurry joinDrive (splitDrive x) == x Windows: joinDrive "C:" "foo" == "C:foo" Windows: joinDrive "C:\\" "bar" == "C:\\bar" Windows: joinDrive "\\\\share" "foo" == "\\\\share\\foo" Windows: joinDrive "/:" "foo" == "/:\\foo" template-haskellGet the drive from a filepath. !takeDrive x == fst (splitDrive x) template-haskellDelete the drive, if it exists. !dropDrive x == snd (splitDrive x) template-haskellDoes a path have a drive. not (hasDrive x) == null (takeDrive x) Posix: hasDrive "/foo" == True Windows: hasDrive "C:\\foo" == True Windows: hasDrive "C:foo" == True hasDrive "foo" == False hasDrive "" == False template-haskellIs an element a drive Posix: isDrive "/" == True Posix: isDrive "/foo" == False Windows: isDrive "C:\\" == True Windows: isDrive "C:\\foo" == False isDrive "" == False template-haskell*Split a filename into directory and file.   is the inverse. The first component will often end with a trailing slash. splitFileName "/directory/file.ext" == ("/directory/","file.ext") Valid x => uncurry () (splitFileName x) == x || fst (splitFileName x) == "./" Valid x => isValid (fst (splitFileName x)) splitFileName "file/bob.txt" == ("file/", "bob.txt") splitFileName "file/" == ("file/", "") splitFileName "bob" == ("./", "bob") Posix: splitFileName "/" == ("/","") Windows: splitFileName "c:" == ("c:","") template-haskellSet the filename. replaceFileName "/directory/other.txt" "file.ext" == "/directory/file.ext" Valid x => replaceFileName x (takeFileName x) == x template-haskellDrop the filename. Unlike  , this function will leave a trailing path separator on the directory. dropFileName "/directory/file.ext" == "/directory/" dropFileName x == fst (splitFileName x) template-haskellGet the file name. takeFileName "/directory/file.ext" == "file.ext" takeFileName "test/" == "" takeFileName x `isSuffixOf` x takeFileName x == snd (splitFileName x) Valid x => takeFileName (replaceFileName x "fred") == "fred" Valid x => takeFileName (x "fred") == "fred" Valid x => isRelative (takeFileName x) template-haskell0Get the base name, without an extension or path. takeBaseName "/directory/file.ext" == "file" takeBaseName "file/test.txt" == "test" takeBaseName "dave.ext" == "dave" takeBaseName "" == "" takeBaseName "test" == "test" takeBaseName (addTrailingPathSeparator x) == "" takeBaseName "file/file.tar.gz" == "file.tar" template-haskellSet the base name. replaceBaseName "/directory/other.ext" "file" == "/directory/file.ext" replaceBaseName "file/test.txt" "bob" == "file/bob.txt" replaceBaseName "fred" "bill" == "bill" replaceBaseName "/dave/fred/bob.gz.tar" "new" == "/dave/fred/new.tar" Valid x => replaceBaseName x (takeBaseName x) == x template-haskellIs an item either a directory or the last character a path separator? hasTrailingPathSeparator "test" == False hasTrailingPathSeparator "test/" == True template-haskellAdd a trailing file path separator if one is not already present. hasTrailingPathSeparator (addTrailingPathSeparator x) hasTrailingPathSeparator x ==> addTrailingPathSeparator x == x Posix: addTrailingPathSeparator "test/rest" == "test/rest/" template-haskell#Remove any trailing path separators dropTrailingPathSeparator "file/test/" == "file/test" dropTrailingPathSeparator "/" == "/" Windows: dropTrailingPathSeparator "\\" == "\\" Posix: not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x template-haskell*Get the directory name, move up one level.  takeDirectory "/directory/other.ext" == "/directory" takeDirectory x `isPrefixOf` x || takeDirectory x == "." takeDirectory "foo" == "." takeDirectory "/" == "/" takeDirectory "/foo" == "/" takeDirectory "/foo/bar/baz" == "/foo/bar" takeDirectory "/foo/bar/baz/" == "/foo/bar/baz" takeDirectory "foo/bar/baz" == "foo/bar" Windows: takeDirectory "foo\\bar" == "foo" Windows: takeDirectory "foo\\bar\\\\" == "foo\\bar" Windows: takeDirectory "C:\\" == "C:\\" template-haskell1Set the directory, keeping the filename the same. replaceDirectory "root/file.ext" "/directory/" == "/directory/file.ext" Valid x => replaceDirectory x (takeDirectory x) `equalFilePath` x template-haskell An alias for  . template-haskell0Combine two paths, assuming rhs is NOT absolute. template-haskellCombine two paths with a path separator. If the second path starts with a path separator or a drive letter, then it returns the second. The intention is that readFile (dir   file)! will access the same file as &setCurrentDirectory dir; readFile file. Posix: "/directory" "file.ext" == "/directory/file.ext" Windows: "/directory" "file.ext" == "/directory\\file.ext" "directory" "/file.ext" == "/file.ext" Valid x => (takeDirectory x takeFileName x) `equalFilePath` x Combined: Posix: "/" "test" == "/test" Posix: "home" "bob" == "home/bob" Posix: "x:" "foo" == "x:/foo" Windows: "C:\\foo" "bar" == "C:\\foo\\bar" Windows: "home" "bob" == "home\\bob" Not combined: Posix: "home" "/bob" == "/bob" Windows: "home" "C:\\bob" == "C:\\bob"Not combined (tricky):On Windows, if a filepath starts with a single slash, it is relative to the root of the current drive. In [1], this is (confusingly) referred to as an absolute path. The current behavior of  ! is to never combine these forms. Windows: "home" "/bob" == "/bob" Windows: "home" "\\bob" == "\\bob" Windows: "C:\\home" "\\bob" == "\\bob"On Windows, from [1]: "If a file name begins with only a disk designator but not the backslash after the colon, it is interpreted as a relative path to the current directory on the drive with the specified letter." The current behavior of  ! is to never combine these forms. Windows: "D:\\foo" "C:bar" == "C:bar" Windows: "C:\\foo" "C:bar" == "C:bar" template-haskell(Split a path by the directory separator. splitPath "/directory/file.ext" == ["/","directory/","file.ext"] concat (splitPath x) == x splitPath "test//item/" == ["test//","item/"] splitPath "test/item/file" == ["test/","item/","file"] splitPath "" == [] Windows: splitPath "c:\\test\\path" == ["c:\\","test\\","path"] Posix: splitPath "/file/test" == ["/","file/","test"] template-haskellJust as  5, but don't add the trailing slashes to each element.  splitDirectories "/directory/file.ext" == ["/","directory","file.ext"] splitDirectories "test/file" == ["test","file"] splitDirectories "/test/file" == ["/","test","file"] Windows: splitDirectories "C:\\test\\file" == ["C:\\", "test", "file"] Valid x => joinPath (splitDirectories x) `equalFilePath` x splitDirectories "" == [] Windows: splitDirectories "C:\\test\\\\\\file" == ["C:\\", "test", "file"] splitDirectories "/test///file" == ["/","test","file"] template-haskell!Join path elements back together. joinPath a == foldr () "" a joinPath ["/","directory/","file.ext"] == "/directory/file.ext" Valid x => joinPath (splitPath x) == x joinPath [] == "" Posix: joinPath ["test","file","path"] == "test/file/path" template-haskellEquality of two  s. If you call !System.Directory.canonicalizePath first this has a much better chance of working. Note that this doesn't follow symlinks or DOSNAM~1s. Similar to  , this does not expand "..", because of symlinks.  x == y ==> equalFilePath x y normalise x == normalise y ==> equalFilePath x y equalFilePath "foo" "foo/" not (equalFilePath "/a/../c" "/c") not (equalFilePath "foo" "/foo") Posix: not (equalFilePath "foo" "FOO") Windows: equalFilePath "foo" "FOO" Windows: not (equalFilePath "C:" "C:/") template-haskellContract a filename, based on a relative path. Note that the resulting path will never introduce ..* paths, as the presence of symlinks means ../b may not reach a/b if it starts from a/c. For a worked example see  http://neilmitchell.blogspot.co.uk/2015/10/filepaths-are-subtle-symlinks-are-hard.htmlthis blog post.The corresponding  makeAbsolute function can be found in System.Directory.  makeRelative "/directory" "/directory/file.ext" == "file.ext" Valid x => makeRelative (takeDirectory x) x `equalFilePath` takeFileName x makeRelative x x == "." Valid x y => equalFilePath x y || (isRelative x && makeRelative y x == x) || equalFilePath (y makeRelative y x) x Windows: makeRelative "C:\\Home" "c:\\home\\bob" == "bob" Windows: makeRelative "C:\\Home" "c:/home/bob" == "bob" Windows: makeRelative "C:\\Home" "D:\\Home\\Bob" == "D:\\Home\\Bob" Windows: makeRelative "C:\\Home" "C:Home\\Bob" == "C:Home\\Bob" Windows: makeRelative "/Home" "/home/bob" == "bob" Windows: makeRelative "/" "//" == "//" Posix: makeRelative "/Home" "/home/bob" == "/home/bob" Posix: makeRelative "/home/" "/home/bob/foo/bar" == "bob/foo/bar" Posix: makeRelative "/fred" "bob" == "bob" Posix: makeRelative "/file/test" "/file/test/fred" == "fred" Posix: makeRelative "/file/test" "/file/test/fred/" == "fred/" Posix: makeRelative "some/path" "some/path/a/b/c" == "a/b/c" template-haskellNormalise a file)// outside of the drive can be made blank/ ->  ./ -> ""Does not remove "..", because of symlinks. Posix: normalise "/file/\\test////" == "/file/\\test/" Posix: normalise "/file/./test" == "/file/test" Posix: normalise "/test/file/../bob/fred/" == "/test/file/../bob/fred/" Posix: normalise "../bob/fred/" == "../bob/fred/" Posix: normalise "/a/../c" == "/a/../c" Posix: normalise "./bob/fred/" == "bob/fred/" Windows: normalise "c:\\file/bob\\" == "C:\\file\\bob\\" Windows: normalise "c:\\" == "C:\\" Windows: normalise "C:.\\" == "C:" Windows: normalise "\\\\server\\test" == "\\\\server\\test" Windows: normalise "//server/test" == "\\\\server\\test" Windows: normalise "c:/file" == "C:\\file" Windows: normalise "/file" == "\\file" Windows: normalise "\\" == "\\" Windows: normalise "/./" == "\\" normalise "." == "." Posix: normalise "./" == "./" Posix: normalise "./." == "./" Posix: normalise "/./" == "/" Posix: normalise "/" == "/" Posix: normalise "bob/fred/." == "bob/fred/" Posix: normalise "//home" == "/home" template-haskellIs a FilePath valid, i.e. could you create a file like it? This function checks for invalid names, and invalid characters, but does not check if length limits are exceeded, as these are typically filesystem dependent.  isValid "" == False isValid "\0" == False Posix: isValid "/random_ path:*" == True Posix: isValid x == not (null x) Windows: isValid "c:\\test" == True Windows: isValid "c:\\test:of_test" == False Windows: isValid "test*" == False Windows: isValid "c:\\test\\nul" == False Windows: isValid "c:\\test\\prn.txt" == False Windows: isValid "c:\\nul\\file" == False Windows: isValid "\\\\" == False Windows: isValid "\\\\\\foo" == False Windows: isValid "\\\\?\\D:file" == False Windows: isValid "foo\tbar" == False Windows: isValid "nul .txt" == False Windows: isValid " nul.txt" == True template-haskellTake a FilePath and make it valid; does not change already valid FilePaths. isValid (makeValid x) isValid x ==> makeValid x == x makeValid "" == "_" makeValid "file\0name" == "file_name" Windows: makeValid "c:\\already\\/valid" == "c:\\already\\/valid" Windows: makeValid "c:\\test:of_test" == "c:\\test_of_test" Windows: makeValid "test*" == "test_" Windows: makeValid "c:\\test\\nul" == "c:\\test\\nul_" Windows: makeValid "c:\\test\\prn.txt" == "c:\\test\\prn_.txt" Windows: makeValid "c:\\test/prn.txt" == "c:\\test/prn_.txt" Windows: makeValid "c:\\nul\\file" == "c:\\nul_\\file" Windows: makeValid "\\\\\\foo" == "\\\\drive" Windows: makeValid "\\\\?\\D:file" == "\\\\?\\D:\\file" Windows: makeValid "nul .txt" == "nul _.txt" template-haskell/Is a path relative, or is it fixed to the root? Windows: isRelative "path\\test" == True Windows: isRelative "c:\\test" == False Windows: isRelative "c:test" == True Windows: isRelative "c:\\" == False Windows: isRelative "c:/" == False Windows: isRelative "c:" == True Windows: isRelative "\\\\foo" == False Windows: isRelative "\\\\?\\foo" == False Windows: isRelative "\\\\?\\UNC\\foo" == False Windows: isRelative "/foo" == True Windows: isRelative "\\foo" == True Posix: isRelative "test/path" == True Posix: isRelative "/test" == False Posix: isRelative "/" == FalseAccording to [1]:/"A UNC name of any format [is never relative]."6"You cannot use the "\?" prefix with a relative path." template-haskell not .  "isAbsolute x == not (isRelative x) template-haskellThe stripSuffix function drops the given suffix from a list. It returns Nothing if the list did not end with the suffix given, or Just the list before the suffix, if it does.5  7 7 5  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                                                                                                                                                                pnoqy}~{| JKQ_1                                                                       template-haskellLanguage.Haskell.TH.Syntax Language.Haskell.TH.Lib.InternalLanguage.Haskell.TH.Quote&Language.Haskell.TH.LanguageExtensionsLanguage.Haskell.TH.PprLibLanguage.Haskell.TH.PprLanguage.Haskell.TH.LibLanguage.Haskell.TH.CodeDoLanguage.Haskell.TH.Lib.MapSystem.FilePath.PosixSystem.FilePathdyn pprPatSynType thisModuleLanguage.Haskell.THSystem.FilePath.Windows sequenceQliftnewNamemkName mkNameG_v mkNameG_d mkNameG_tcmkNameLmkNameSunType unTypeCode liftTyped mkModNameunsafeCodeCoercemkNameQcharLstringLintegerLintPrimL wordPrimL floatPrimL doublePrimL rationalL stringPrimL charPrimL liftStringlitPvarPtupP unboxedTupP unboxedSumPconPinfixPtildePbangPasPwildPrecPlistPsigPviewPfieldPatmatchclausevarEconElitEappEappTypeEinfixEinfixAppsectionLsectionRlamElamCaseE lamCasesEtupE unboxedTupE unboxedSumEcondEmultiIfEletEcaseEdoEcompEfromE fromThenEfromToE fromThenToElistEsigErecConErecUpdEstaticE unboundVarElabelEimplicitParamVarEmdoE getFieldE projectionEfieldExpguardedBnormalBnormalGEpatGEbindSletSnoBindSparSrecSfunDvalDdataDnewtypeDtySynDclassDinstanceWithOverlapDsigDforImpDpragInlD pragSpecD pragSpecInlD pragSpecInstD pragRuleDpragAnnD dataFamilyDopenTypeFamilyD dataInstD newtypeInstD tySynInstDclosedTypeFamilyDinfixLDinfixRDinfixND roleAnnotDstandaloneDerivWithStrategyD defaultSigDpatSynD patSynSigD pragCompleteDimplicitParamBindDkiSigDdefaultD pragOpaqueD typeDataDcxtnoSourceUnpackednesssourceNoUnpack sourceUnpacknoSourceStrictness sourceLazy sourceStrictnormalCrecCinfixCforallCgadtCrecGadtCbangbangType varBangTypeunidir implBidir explBidir prefixPatSyn infixPatSyn recordPatSynforallT forallVisTvarTconTtupleT unboxedTupleT unboxedSumTarrowTlistTappTappKindTsigT equalityTlitT promotedTpromotedTupleT promotedNilT promotedConsT wildCardTimplicitParamTinfixTnumTyLitstrTyLit charTyLitplainTVkindedTVnominalRrepresentationalRphantomRinferRstarK constraintKnoSigkindSigtyVarSiginjectivityAnncCallstdCallcApiprim javaScriptunsafesafe interruptiblefunDep mulArrowTtySynEqnquoteExpquotePatquoteDec quoteTyperuleVar typedRuleVar plainInvisTV kindedInvisTVvalueAnnotationtypeAnnotationmoduleAnnotation derivClause specifiedSpec inferredSpecLiftQuoteExpMatchClauseQExpQPatStmtConTypeQTypeDecBangType VarBangTypeFieldExpFieldPatNamePatQFunDepPred TyVarBndrUnitDecsQRuleBndrTySynEqnRoleInjectivityAnnKindOverlap DerivClause DerivStrategyDecs TyVarBndrSpecCodeModNameNoInlineInline InlinableConLikeFunLike AllPhases FromPhase BeforePhase Overlappable OverlappingOverlaps Incoherent stockStrategyanyclassStrategynewtypeStrategy viaStrategyghc-boot-th-9.6.1GHC.ForeignSrcLang.TypeForeignSrcLangLangCLangCxxLangObjc LangObjcxxLangAsmLangJs RawObjectGHC.LanguageExtensions.Type ExtensionCppOverlappingInstancesUndecidableInstancesIncoherentInstancesUndecidableSuperClassesMonomorphismRestrictionMonoLocalBindsDeepSubsumptionRelaxedPolyRecExtendedDefaultRulesForeignFunctionInterfaceUnliftedFFITypesInterruptibleFFICApiFFIGHCForeignImportPrim JavaScriptFFIParallelArraysArrowsTemplateHaskellTemplateHaskellQuotes QualifiedDo QuasiQuotesImplicitParamsImplicitPreludeScopedTypeVariablesAllowAmbiguousTypes UnboxedTuples UnboxedSumsUnliftedNewtypesUnliftedDatatypes BangPatterns TypeFamiliesTypeFamilyDependencies TypeInTypeOverloadedStringsOverloadedLists NumDecimalsDisambiguateRecordFieldsRecordWildCardsNamedFieldPuns ViewPatternsGADTs GADTSyntaxNPlusKPatternsDoAndIfThenElseBlockArgumentsRebindableSyntaxConstraintKinds PolyKinds DataKindsTypeData InstanceSigs ApplicativeDo LinearTypesStandaloneDerivingDeriveDataTypeableAutoDeriveTypeable DeriveFunctorDeriveTraversableDeriveFoldable DeriveGenericDefaultSignaturesDeriveAnyClass DeriveLiftDerivingStrategies DerivingViaTypeSynonymInstancesFlexibleContextsFlexibleInstancesConstrainedClassMethodsMultiParamTypeClassesNullaryTypeClassesFunctionalDependencies UnicodeSyntaxExistentialQuantification MagicHashEmptyDataDeclsKindSignaturesRoleAnnotationsParallelListCompTransformListCompMonadComprehensionsGeneralizedNewtypeDeriving RecursiveDoPostfixOperators TupleSections PatternGuardsLiberalTypeSynonyms RankNTypesImpredicativeTypes TypeOperatorsExplicitNamespacesPackageImportsExplicitForAllAlternativeLayoutRule!AlternativeLayoutRuleTransitionalDatatypeContextsNondecreasingIndentation RelaxedLayoutTraditionalRecordSyntax LambdaCase MultiWayIfBinaryLiteralsNegativeLiteralsHexFloatLiteralsDuplicateRecordFieldsOverloadedLabels EmptyCasePatternSynonymsPartialTypeSignaturesNamedWildCardsStaticPointersTypeApplicationsStrict StrictDataEmptyDataDerivingNumericUnderscoresQuantifiedConstraints StarIsTypeImportQualifiedPostCUSKsStandaloneKindSignaturesLexicalNegationFieldSelectorsOverloadedRecordDotOverloadedRecordUpdateDocLoc ModuleDocDeclDocArgDocInstDoc AnnLookupAnnLookupModule AnnLookupNameNominalRRepresentationalRPhantomRInferRTyLitNumTyLitStrTyLit CharTyLitFamilyResultSigNoSigKindSigTyVarSig TyVarBndrPlainTVKindedTV Specificity SpecifiedSpec InferredSpecForallT ForallVisTAppTAppKindTSigTVarTConT PromotedTInfixTUInfixTPromotedInfixTPromotedUInfixTParensTTupleT UnboxedTupleT UnboxedSumTArrowT MulArrowT EqualityTListTPromotedTupleT PromotedNilT PromotedConsTStarT ConstraintTLitT WildCardTImplicitParamT PatSynArgs PrefixPatSyn InfixPatSyn RecordPatSyn PatSynDirUnidir ImplBidir ExplBidir VarStrictType StrictTypeBangNormalCRecCInfixCForallCGadtCRecGadtCDecidedStrictness DecidedLazy DecidedStrict DecidedUnpackSourceStrictnessNoSourceStrictness SourceLazy SourceStrictSourceUnpackednessNoSourceUnpackednessSourceNoUnpack SourceUnpackCxt AnnTargetModuleAnnotationTypeAnnotationValueAnnotationRuleVar TypedRuleVarPhases RuleMatchPragmaInlinePOpaqueP SpecialisePSpecialiseInstPRulePAnnPLineP CompletePSafetyUnsafeSafe InterruptibleCallconvCCallStdCallCApiPrim JavaScriptForeignImportFExportFTypeFamilyHead PatSynType StockStrategyAnyclassStrategyNewtypeStrategy ViaStrategyFunDValDDataDNewtypeD TypeDataDTySynDClassD InstanceDSigDKiSigDForeignDInfixDDefaultDPragmaD DataFamilyD DataInstD NewtypeInstD TySynInstDOpenTypeFamilyDClosedTypeFamilyD RoleAnnotDStandaloneDerivD DefaultSigDPatSynD PatSynSigDImplicitParamBindDRangeFromR FromThenRFromToR FromThenToRBindSLetSNoBindSParSRecSGuardNormalGPatGBodyGuardedBNormalBVarEConELitEAppEAppTypeEInfixEUInfixEParensELamELamCaseE LamCasesETupE UnboxedTupE UnboxedSumECondEMultiIfELetECaseEDoEMDoECompE ArithSeqEListESigERecConERecUpdEStaticE UnboundVarELabelEImplicitParamVarE GetFieldE ProjectionELitPVarPTupP UnboxedTupP UnboxedSumPConPInfixPUInfixPParensPTildePBangPAsPWildPRecPListPSigPViewPBytesbytesPtr bytesOffset bytesSizeLitCharLStringLIntegerL RationalLIntPrimL WordPrimL FloatPrimL DoublePrimL StringPrimL BytesPrimL CharPrimLFixityDirectionInfixLInfixRInfixNFixity InstanceDecUnliftedAritySumAritySumAlt ParentName ModuleInfoInfoClassIClassOpITyConIFamilyI PrimTyConIDataConIPatSynIVarITyVarICharPosLoc loc_filename loc_package loc_module loc_startloc_endNameIsAloneAppliedInfixUniq NameSpaceVarNameDataName TcClsName NameFlavourNameSNameQNameUNameLNameGOccNameModulePkgName examineCodeTExpunQQuasiqNewNameqReportqRecover qLookupNameqReify qReifyFixity qReifyTypeqReifyInstances qReifyRolesqReifyAnnotations qReifyModuleqReifyConStrictness qLocationqRunIOqGetPackageRootqAddDependentFile qAddTempFile qAddTopDeclsqAddForeignFilePathqAddModFinalizerqAddCorePluginqGetQqPutQ qIsExtEnabled qExtsEnabledqPutDocqGetDocmemcmp newNameIObadIOcounterrunQunTypeQunsafeTExpCoerceliftCode hoistCodebindCode bindCode_joinCodereport reportError reportWarningrecover lookupNamelookupTypeNamelookupValueNamereify reifyFixity reifyTypenewDeclarationGroupreifyInstances reifyRolesreifyAnnotations reifyModulereifyConStrictness isInstancelocationrunIOgetPackageRootmakeRelativeToProjectaddDependentFile addTempFile addTopDeclsaddForeignFileaddForeignSourceaddForeignFilePathaddModFinalizer addCorePlugingetQputQ isExtEnabled extsEnabledputDocgetDocaddrToByteArrayNameaddrToByteArraytrueName falseName nothingNamejustNameleftName rightName nonemptyNameoneNamemanyNamedataToQa dataToExpQliftData dataToPatQ modString mkPkgName pkgString mkOccName occStringnameBase nameModule namePackage nameSpacemkNameUmkNameGshowName showName' tupleDataName tupleTypeNameunboxedTupleDataNameunboxedTupleTypeName mk_tup_nameunboxedSumDataNameunboxedSumTypeName maxPrecedence defaultFixityeqBytes compareBytescmpEqthenCmp $fShowName $fOrdName $fQuoteIO $fOrdBytes $fEqBytes $fShowBytes$fLiftSumRep(# | | | | | | #)$fLiftSumRep(# | | | | | #)$fLiftSumRep(# | | | | #)$fLiftSumRep(# | | | #)$fLiftSumRep(# | | #)$fLiftSumRep(# | #)$fLiftTupleRep(#,,,,,,#)$fLiftTupleRep(#,,,,,#)$fLiftTupleRep(#,,,,#)$fLiftTupleRep(#,,,#)$fLiftTupleRep(#,,#)$fLiftTupleRep(#,#)$fLiftTupleRepSolo#$fLiftTupleRep(##)$fLiftBoxedRep(,,,,,,)$fLiftBoxedRep(,,,,,)$fLiftBoxedRep(,,,,)$fLiftBoxedRep(,,,)$fLiftBoxedRep(,,)$fLiftBoxedRep(,)$fLiftBoxedRep()$fLiftBoxedRepVoid$fLiftBoxedRepNonEmpty$fLiftBoxedRepList$fLiftBoxedRepEither$fLiftBoxedRepMaybe$fLiftBoxedRepByteArray$fLiftAddrRepAddr#$fLiftBoxedRepBool$fLiftWordRepChar#$fLiftBoxedRepChar$fLiftDoubleRepDouble#$fLiftBoxedRepDouble$fLiftFloatRepFloat#$fLiftBoxedRepFloat$fLiftBoxedRepRatio$fLiftBoxedRepNatural$fLiftBoxedRepWord64$fLiftBoxedRepWord32$fLiftBoxedRepWord16$fLiftBoxedRepWord8$fLiftBoxedRepWord$fLiftWordRepWord#$fLiftBoxedRepInt64$fLiftBoxedRepInt32$fLiftBoxedRepInt16$fLiftBoxedRepInt8$fLiftIntRepInt#$fLiftBoxedRepInt$fLiftBoxedRepInteger$fQuasiQ $fMonadIOQ$fQuoteQ $fMonadFixQ $fMonoidQ $fSemigroupQ$fApplicativeQ $fFunctorQ $fMonadFailQ$fMonadQ $fQuasiIO $fShowDocLoc $fEqDocLoc $fOrdDocLoc $fDataDocLoc$fGenericDocLoc $fShowInfo$fEqInfo $fOrdInfo $fDataInfo $fGenericInfo $fShowDec$fEqDec$fOrdDec $fDataDec $fGenericDec$fShowPatSynDir $fEqPatSynDir$fOrdPatSynDir$fDataPatSynDir$fGenericPatSynDir $fShowClause $fEqClause $fOrdClause $fDataClause$fGenericClause $fShowBody$fEqBody $fOrdBody $fDataBody $fGenericBody $fShowGuard $fEqGuard $fOrdGuard $fDataGuard$fGenericGuard $fShowStmt$fEqStmt $fOrdStmt $fDataStmt $fGenericStmt $fShowExp$fEqExp$fOrdExp $fDataExp $fGenericExp $fShowRange $fEqRange $fOrdRange $fDataRange$fGenericRange $fShowMatch $fEqMatch $fOrdMatch $fDataMatch$fGenericMatch $fShowPat$fEqPat$fOrdPat $fDataPat $fGenericPat $fShowPragma $fEqPragma $fOrdPragma $fDataPragma$fGenericPragma$fShowDerivClause$fEqDerivClause$fOrdDerivClause$fDataDerivClause$fGenericDerivClause$fShowDerivStrategy$fEqDerivStrategy$fOrdDerivStrategy$fDataDerivStrategy$fGenericDerivStrategy$fShowTySynEqn $fEqTySynEqn $fOrdTySynEqn$fDataTySynEqn$fGenericTySynEqn $fShowForeign $fEqForeign $fOrdForeign $fDataForeign$fGenericForeign$fShowRuleBndr $fEqRuleBndr $fOrdRuleBndr$fDataRuleBndr$fGenericRuleBndr $fShowCon$fEqCon$fOrdCon $fDataCon $fGenericCon$fShowTypeFamilyHead$fEqTypeFamilyHead$fOrdTypeFamilyHead$fDataTypeFamilyHead$fGenericTypeFamilyHead$fShowFamilyResultSig$fEqFamilyResultSig$fOrdFamilyResultSig$fDataFamilyResultSig$fGenericFamilyResultSig $fShowType$fEqType $fOrdType $fDataType $fGenericType$fShowTyVarBndr $fEqTyVarBndr$fOrdTyVarBndr$fDataTyVarBndr$fGenericTyVarBndr$fFunctorTyVarBndr$fShowAnnLookup $fEqAnnLookup$fOrdAnnLookup$fDataAnnLookup$fGenericAnnLookup $fShowRole$fEqRole $fOrdRole $fDataRole $fGenericRole $fShowTyLit $fEqTyLit $fOrdTyLit $fDataTyLit$fGenericTyLit$fShowInjectivityAnn$fEqInjectivityAnn$fOrdInjectivityAnn$fDataInjectivityAnn$fGenericInjectivityAnn$fShowSpecificity$fEqSpecificity$fOrdSpecificity$fDataSpecificity$fGenericSpecificity$fShowPatSynArgs$fEqPatSynArgs$fOrdPatSynArgs$fDataPatSynArgs$fGenericPatSynArgs $fShowBang$fEqBang $fOrdBang $fDataBang $fGenericBang$fShowDecidedStrictness$fEqDecidedStrictness$fOrdDecidedStrictness$fDataDecidedStrictness$fGenericDecidedStrictness$fShowSourceStrictness$fEqSourceStrictness$fOrdSourceStrictness$fDataSourceStrictness$fGenericSourceStrictness$fShowSourceUnpackedness$fEqSourceUnpackedness$fOrdSourceUnpackedness$fDataSourceUnpackedness$fGenericSourceUnpackedness$fShowAnnTarget $fEqAnnTarget$fOrdAnnTarget$fDataAnnTarget$fGenericAnnTarget $fShowPhases $fEqPhases $fOrdPhases $fDataPhases$fGenericPhases$fShowRuleMatch $fEqRuleMatch$fOrdRuleMatch$fDataRuleMatch$fGenericRuleMatch $fShowInline $fEqInline $fOrdInline $fDataInline$fGenericInline $fShowSafety $fEqSafety $fOrdSafety $fDataSafety$fGenericSafety$fShowCallconv $fEqCallconv $fOrdCallconv$fDataCallconv$fGenericCallconv $fShowFunDep $fEqFunDep $fOrdFunDep $fDataFunDep$fGenericFunDep $fShowOverlap $fEqOverlap $fOrdOverlap $fDataOverlap$fGenericOverlap $fShowLit$fEqLit$fOrdLit $fDataLit $fGenericLit $fDataBytes$fGenericBytes $fEqFixity $fOrdFixity $fShowFixity $fDataFixity$fGenericFixity$fEqFixityDirection$fOrdFixityDirection$fShowFixityDirection$fDataFixityDirection$fGenericFixityDirection$fShowModuleInfo$fEqModuleInfo$fOrdModuleInfo$fDataModuleInfo$fGenericModuleInfo $fShowLoc$fEqLoc$fOrdLoc $fDataLoc $fGenericLoc $fDataName$fEqName $fGenericName$fDataNameFlavour$fEqNameFlavour$fOrdNameFlavour$fShowNameFlavour$fGenericNameFlavour $fEqNameSpace$fOrdNameSpace$fShowNameSpace$fDataNameSpace$fGenericNameSpace $fShowOccName $fEqOccName $fOrdOccName $fDataOccName$fGenericOccName $fShowModule $fEqModule $fOrdModule $fDataModule$fGenericModule $fShowPkgName $fEqPkgName $fOrdPkgName $fDataPkgName$fGenericPkgName $fShowModName $fEqModName $fOrdModName $fDataModName$fGenericModName QuasiQuoter quoteFileDocPprMpprNamepprName' to_HPJ_DocisEmptyemptysemicommacolondcolonspaceequalsarrowlparenrparenlbrackrbracklbracerbracetextptextcharintintegerfloatdoublerationalparensbracketsbracesquotes doubleQuotes<>hcat<+>hsep$$$+$vcatcatsepfcatfsepnesthang punctuate $fMonadPprM$fApplicativePprM $fFunctorPprM $fShowPprMPprFlag pprTyVarBndrTypeArgTANormalTyArg ForallVisFlag ForallVis ForallInvisPprpprppr_list Precedence nestDepthappPrecopPrecunopPrecfunPrecqualPrecsigPrecnoPrecparensIfpprintppr_sig pprFixity pprPatSynSig pprPrefixOccisSymOcc pprInfixExppprExp pprFields pprMaybeExp pprMatchPat pprGuardedpprBody pprClausepprLit bytesToString pprStringpprPatppr_decppr_deriv_strategy ppr_overlapppr_data ppr_newtype ppr_type_data ppr_typedefppr_deriv_clause ppr_tySyn ppr_tf_head ppr_bndrscommaSepApplied pprForall pprForallVis pprForall' pprRecFields pprGadtRHSpprVarBangType pprBangTypepprVarStrictType pprStrictTypepprType pprParendType pprInfixTpprParendTypeArgisStarTpprTyApp fromTANormal pprFunArgTypesplitpprTyLitpprCxt ppr_cxt_preds where_clause showtextl hashParens quoteParenssepWithcommaSep commaSepWithsemiSep semiSepWithunboxedSumBarsbar$fPprLoc $fPprRange $fPprRole $fPprTyLit $fPprType$fPprDecidedStrictness$fPprSourceStrictness$fPprSourceUnpackedness $fPprBang$fPprPatSynArgs$fPprPatSynDir$fPprCon $fPprClause $fPprRuleBndr $fPprPhases$fPprRuleMatch $fPprInline $fPprPragma $fPprForeign$fPprInjectivityAnn$fPprFamilyResultSig $fPprFunDep$fPprDec$fPprPat$fPprLit $fPprMatch $fPprStmt$fPprExp$fPprModuleInfo $fPprModule $fPprInfo $fPprName $fPprList $fPprTypeArg$fPprTyVarBndr$fPprFlagSpecificity $fPprFlag()$fShowForallVisFlagDerivStrategyQFamilyResultSigQ PatSynArgsQ PatSynDirQ TySynEqnQ RuleBndrQ FieldExpQVarStrictTypeQ StrictTypeQ VarBangTypeQ BangTypeQBangQSourceUnpackednessQSourceStrictnessQRangeQStmtQGuardQBodyQClauseQMatchQ DerivClauseQPredQCxtQTyLitQKindQConQDecQ FieldPatQInfoQCodeQTExpQ bytesPrimLuInfixPparensPfromR fromThenRfromToR fromThenToRnormalGpatGparensEuInfixElam1E arithSeqEstringE instanceD pragLineDstandaloneDerivDuInfixTpromotedInfixTpromotedUInfixTparensTclassPequalPisStrict notStrictunpacked strictType varStrictTypevarKconKtupleKarrowKlistKappKappsE withDecDoc withDecsDocfunD_doc dataD_doc newtypeD_doc typeDataD_doc dataInstD_docnewtypeInstD_doc patSynD_docdocConsmkBytes>>=>>MapinsertlookupisPosix isWindows pathSeparatorpathSeparatorsisPathSeparatorsearchPathSeparatorisSearchPathSeparator extSeparatorisExtSeparatorsplitSearchPath getSearchPathbaseGHC.IOFilePathsplitExtension addExtension takeExtension-<.>replaceExtension<.> dropExtension hasExtension isExtensionOfstripExtension GHC.MaybeNothingJustdropExtensionssplitExtensionstakeExtensionsreplaceExtensionsisLetter splitDrive joinDrive takeDrive dropDrivehasDriveisDrive splitFileNamereplaceFileName dropFileName takeDirectory takeFileName takeBaseNamereplaceBaseNamehasTrailingPathSeparatoraddTrailingPathSeparatordropTrailingPathSeparatorreplaceDirectorycombine combineAlways splitPathsplitDirectoriesjoinPath equalFilePath normalise makeRelativeisValid makeValid isRelative isAbsolute stripSuffixMaybeghc-primGHC.PrimAddr#Control.Monad.Failfail GHC.ClassesEqGHC.BaseString Data.DataDataControl.Monad.FixmfixGHC.IO.ExceptionFixIOException GHC.TypesTrue