-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Shell programming, Haskell-style
--   
--   <tt>turtle</tt> is a reimplementation of the Unix command line
--   environment in Haskell so that you can use Haskell as both a shell and
--   a scripting language.
--   
--   Features include:
--   
--   <ul>
--   <li>Batteries included: Command an extended suite of predefined
--   utilities</li>
--   <li>Interoperability: You can still run external shell commands</li>
--   <li>Portability: Works on Windows, OS X, and Linux</li>
--   <li>Exception safety: Safely acquire and release resources</li>
--   <li>Streaming: Transform or fold command output in constant space</li>
--   <li>Patterns: Use typed regular expressions that can parse structured
--   values</li>
--   <li>Formatting: Type-safe <tt>printf</tt>-style text formatting</li>
--   <li>Modern: Supports <tt>text</tt> and <tt>system-filepath</tt></li>
--   </ul>
--   
--   Read <a>Turtle.Tutorial</a> for a detailed tutorial or
--   <a>Turtle.Prelude</a> for a quick-start guide
--   
--   <tt>turtle</tt> is designed to be beginner-friendly, but as a result
--   lacks certain features, like tracing commands. If you feel comfortable
--   using <tt>turtle</tt> then you should also check out the
--   <tt>Shelly</tt> library which provides similar functionality.
@package turtle
@version 1.5.19

module Turtle.Line

-- | A line of text (does not contain newlines).
data Line

-- | Convert a line to a text value.
lineToText :: Line -> Text

-- | Split text into lines. The inverse of <a>linesToText</a>.
textToLines :: Text -> NonEmpty Line

-- | Merge lines into a single text value.
linesToText :: [Line] -> Text

-- | Try to convert a text value into a line. Precondition (checked): the
--   argument does not contain newlines.
textToLine :: Text -> Maybe Line

-- | Convert a text value into a line. Precondition (unchecked): the
--   argument does not contain newlines.
unsafeTextToLine :: Text -> Line

-- | The <a>NewlineForbidden</a> exception is thrown when you construct a
--   <a>Line</a> using an overloaded string literal or by calling
--   <a>fromString</a> explicitly and the supplied string contains
--   newlines. This is a programming error to do so: if you aren't sure
--   that the input string is newline-free, do not rely on the
--   <tt><a>IsString</a> <a>Line</a></tt> instance.
--   
--   When debugging, it might be useful to look for implicit invocations of
--   <a>fromString</a> for <a>Line</a>:
--   
--   <pre>
--   &gt;&gt;&gt; sh (do { line &lt;- "Hello\nWorld"; echo line })
--   *** Exception: NewlineForbidden
--   </pre>
--   
--   In the above example, <tt>echo</tt> expects its argument to be a
--   <a>Line</a>, thus <tt>line :: <a>Line</a></tt>. Since we bind
--   <tt>line</tt> in <tt>Shell</tt>, the string literal
--   <tt>"Hello\nWorld"</tt> has type <tt><tt>Shell</tt> <a>Line</a></tt>.
--   The <tt><a>IsString</a> (<tt>Shell</tt> <a>Line</a>)</tt> instance
--   delegates the construction of a <a>Line</a> to the <tt><a>IsString</a>
--   <a>Line</a></tt> instance, where the exception is thrown.
--   
--   To fix the problem, use <a>textToLines</a>:
--   
--   <pre>
--   &gt;&gt;&gt; sh (do { line &lt;- select (textToLines "Hello\nWorld"); echo line })
--   Hello
--   World
--   </pre>
data NewlineForbidden
NewlineForbidden :: NewlineForbidden
instance GHC.Show.Show Turtle.Line.NewlineForbidden
instance GHC.Base.Monoid Turtle.Line.Line
instance GHC.Show.Show Turtle.Line.Line
instance GHC.Classes.Ord Turtle.Line.Line
instance GHC.Classes.Eq Turtle.Line.Line
instance GHC.Base.Semigroup Turtle.Line.Line
instance Data.String.IsString Turtle.Line.Line
instance GHC.Exception.Type.Exception Turtle.Line.NewlineForbidden


-- | Minimalist implementation of type-safe formatted strings, borrowing
--   heavily from the implementation of the <tt>formatting</tt> package.
--   
--   Example use of this module:
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; import Turtle.Format
--   
--   &gt;&gt;&gt; format ("This is a "%s%" string that takes "%d%" arguments") "format" 2
--   "This is a format string that takes 2 arguments"
--   </pre>
--   
--   A <a>Format</a> string that takes no arguments has this type:
--   
--   <pre>
--   "I take 0 arguments" :: Format r r
--   
--   format "I take 0 arguments" :: Text
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; format "I take 0 arguments"
--   "I take 0 arguments"
--   </pre>
--   
--   A <a>Format</a> string that takes one argument has this type:
--   
--   <pre>
--   "I take "%d%" arguments" :: Format r (Int -&gt; r)
--   
--   format ("I take "%d%" argument") :: Int -&gt; Text
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; format ("I take "%d%" argument") 1
--   "I take 1 argument"
--   </pre>
--   
--   A <a>Format</a> string that takes two arguments has this type:
--   
--   <pre>
--   "I "%s%" "%d%" arguments" :: Format r (Text -&gt; Int -&gt; r)
--   
--   format ("I "%s%" "%d%" arguments") :: Text -&gt; Int -&gt; Text
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; format ("I "%s%" "%d%" arguments") "take" 2
--   "I take 2 arguments"
--   </pre>
module Turtle.Format

-- | A <a>Format</a> string
data Format a b

-- | Concatenate two <a>Format</a> strings
(%) :: Format b c -> Format a b -> Format a c

-- | Convert a <a>Format</a> string to a print function that takes zero or
--   more typed arguments and returns a <a>Text</a> string
format :: Format Text r -> r

-- | Print a <a>Format</a> string to standard output (without a trailing
--   newline)
--   
--   <pre>
--   &gt;&gt;&gt; printf ("Hello, "%s%"!\n") "world"
--   Hello, world!
--   </pre>
printf :: MonadIO io => Format (io ()) r -> r

-- | Print a <a>Format</a> string to standard err (without a trailing
--   newline)
--   
--   <pre>
--   &gt;&gt;&gt; eprintf ("Hello, "%s%"!\n") "world"
--   Hello, world!
--   </pre>
eprintf :: MonadIO io => Format (io ()) r -> r

-- | Create your own format specifier
makeFormat :: (a -> Text) -> Format r (a -> r)

-- | <a>Format</a> any <a>Show</a>able value
--   
--   <pre>
--   &gt;&gt;&gt; format w True
--   "True"
--   </pre>
w :: Show a => Format r (a -> r)

-- | <a>Format</a> an <a>Integral</a> value as a signed decimal
--   
--   <pre>
--   &gt;&gt;&gt; format d 25
--   "25"
--   
--   &gt;&gt;&gt; format d (-25)
--   "-25"
--   </pre>
d :: Integral n => Format r (n -> r)

-- | <a>Format</a> a <a>Word</a> value as an unsigned decimal
--   
--   <pre>
--   &gt;&gt;&gt; format u 25
--   "25"
--   </pre>
u :: Format r (Word -> r)

-- | <a>Format</a> a <a>Word</a> value as an unsigned octal number
--   
--   <pre>
--   &gt;&gt;&gt; format o 25
--   "31"
--   </pre>
o :: Format r (Word -> r)

-- | <a>Format</a> a <a>Word</a> value as an unsigned hexadecimal number
--   (without a leading "0x")
--   
--   <pre>
--   &gt;&gt;&gt; format x 25
--   "19"
--   </pre>
x :: Format r (Word -> r)

-- | <a>Format</a> a <a>Double</a> using decimal notation with 6 digits of
--   precision
--   
--   <pre>
--   &gt;&gt;&gt; format f 25.1
--   "25.100000"
--   </pre>
f :: Format r (Double -> r)

-- | <a>Format</a> a <a>Double</a> using scientific notation with 6 digits
--   of precision
--   
--   <pre>
--   &gt;&gt;&gt; format e 25.1
--   "2.510000e1"
--   </pre>
e :: Format r (Double -> r)

-- | <a>Format</a> a <a>Double</a> using decimal notation for small
--   exponents and scientific notation for large exponents
--   
--   <pre>
--   &gt;&gt;&gt; format g 25.1
--   "25.100000"
--   
--   &gt;&gt;&gt; format g 123456789
--   "1.234568e8"
--   
--   &gt;&gt;&gt; format g 0.00000000001
--   "1.000000e-11"
--   </pre>
g :: Format r (Double -> r)

-- | <a>Format</a> that inserts <a>Text</a>
--   
--   <pre>
--   &gt;&gt;&gt; format s "ABC"
--   "ABC"
--   </pre>
s :: Format r (Text -> r)

-- | <a>Format</a> that inserts a <a>Line</a>
--   
--   <pre>
--   &gt;&gt;&gt; format l "ABC"
--   "ABC"
--   </pre>
l :: Format r (Line -> r)

-- | <a>Format</a> a <a>FilePath</a> into <a>Text</a>
fp :: Format r (FilePath -> r)

-- | <a>Format</a> a <a>UTCTime</a> into <a>Text</a>
utc :: Format r (UTCTime -> r)

-- | Convert a <a>Show</a>able value to any type that implements
--   <a>IsString</a> (such as <a>Text</a>)
--   
--   <pre>
--   &gt;&gt;&gt; repr (1,2)
--   "(1,2)"
--   </pre>
repr :: (Show a, IsString text) => a -> text
instance Control.Category.Category Turtle.Format.Format
instance (a GHC.Types.~ b) => Data.String.IsString (Turtle.Format.Format a b)


-- | Example usage of this module:
--   
--   <pre>
--   -- options.hs
--   
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   import Turtle
--   
--   parser :: Parser (Text, Int)
--   parser = (,) &lt;$&gt; optText "name" 'n' "Your first name"
--                &lt;*&gt; optInt  "age"  'a' "Your current age"
--   
--   main = do
--       (name, age) &lt;- options "Greeting script" parser
--       echo (repr (format ("Hello there, "%s) name))
--       echo (repr (format ("You are "%d%" years old") age))
--   </pre>
--   
--   <pre>
--   $ ./options --name John --age 42
--   Hello there, John
--   You are 42 years old
--   </pre>
--   
--   <pre>
--   $ ./options --help
--   Greeting script
--   
--   Usage: options (-n|--name NAME) (-a|--age AGE)
--   
--   Available options:
--    -h,--help                Show this help text
--    --name NAME              Your first name
--    --age AGE                Your current age
--   </pre>
--   
--   See the <a>Turtle.Tutorial</a> module which contains more examples on
--   how to use command-line parsing.
module Turtle.Options

-- | A <tt>Parser a</tt> is an option parser returning a value of type
--   <tt>a</tt>.
data Parser a

-- | The name of a command-line argument
--   
--   This is used to infer the long name and metavariable for the command
--   line flag. For example, an <a>ArgName</a> of <tt>"name"</tt> will
--   create a <tt>--name</tt> flag with a <tt>NAME</tt> metavariable
newtype ArgName
ArgName :: Text -> ArgName
[getArgName] :: ArgName -> Text

-- | The name of a sub-command
--   
--   This is lower-cased to create a sub-command. For example, a
--   <a>CommandName</a> of <tt>"Name"</tt> will parse <tt>name</tt> on the
--   command line before parsing the remaining arguments using the
--   command's subparser.
newtype CommandName
CommandName :: Text -> CommandName
[getCommandName] :: CommandName -> Text

-- | The short one-character abbreviation for a flag (i.e. <tt>-n</tt>)
type ShortName = Char

-- | A brief description of what your program does
--   
--   This description will appear in the header of the <tt>--help</tt>
--   output
newtype Description
Description :: Doc -> Description
[getDescription] :: Description -> Doc

-- | A helpful message explaining what a flag does
--   
--   This will appear in the <tt>--help</tt> output
newtype HelpMessage
HelpMessage :: Text -> HelpMessage
[getHelpMessage] :: HelpMessage -> Text

-- | This parser returns <a>True</a> if the given flag is set and
--   <a>False</a> if the flag is absent
switch :: ArgName -> ShortName -> Optional HelpMessage -> Parser Bool

-- | Parse a <a>Text</a> value as a flag-based option
optText :: ArgName -> ShortName -> Optional HelpMessage -> Parser Text

-- | Parse a <a>Line</a> value as a flag-based option
optLine :: ArgName -> ShortName -> Optional HelpMessage -> Parser Line

-- | Parse an <a>Int</a> as a flag-based option
optInt :: ArgName -> ShortName -> Optional HelpMessage -> Parser Int

-- | Parse an <a>Integer</a> as a flag-based option
optInteger :: ArgName -> ShortName -> Optional HelpMessage -> Parser Integer

-- | Parse a <a>Double</a> as a flag-based option
optDouble :: ArgName -> ShortName -> Optional HelpMessage -> Parser Double

-- | Parse a <a>FilePath</a> value as a flag-based option
optPath :: ArgName -> ShortName -> Optional HelpMessage -> Parser FilePath

-- | Parse any type that implements <a>Read</a>
optRead :: Read a => ArgName -> ShortName -> Optional HelpMessage -> Parser a

-- | Build a flag-based option parser for any type by providing a
--   <a>Text</a>-parsing function
opt :: (Text -> Maybe a) -> ArgName -> ShortName -> Optional HelpMessage -> Parser a

-- | Parse a <a>Text</a> as a positional argument
argText :: ArgName -> Optional HelpMessage -> Parser Text

-- | Parse a <a>Line</a> as a positional argument
argLine :: ArgName -> Optional HelpMessage -> Parser Line

-- | Parse an <a>Int</a> as a positional argument
argInt :: ArgName -> Optional HelpMessage -> Parser Int

-- | Parse an <a>Integer</a> as a positional argument
argInteger :: ArgName -> Optional HelpMessage -> Parser Integer

-- | Parse a <a>Double</a> as a positional argument
argDouble :: ArgName -> Optional HelpMessage -> Parser Double

-- | Parse a <a>FilePath</a> as a positional argument
argPath :: ArgName -> Optional HelpMessage -> Parser FilePath

-- | Parse any type that implements <a>Read</a> as a positional argument
argRead :: Read a => ArgName -> Optional HelpMessage -> Parser a

-- | Build a positional argument parser for any type by providing a
--   <a>Text</a>-parsing function
arg :: (Text -> Maybe a) -> ArgName -> Optional HelpMessage -> Parser a

-- | Create a sub-command that parses <a>CommandName</a> and then parses
--   the rest of the command-line arguments
--   
--   The sub-command will have its own <a>Description</a> and help text
subcommand :: CommandName -> Description -> Parser a -> Parser a

-- | Create a named group of sub-commands
subcommandGroup :: forall a. Description -> [(CommandName, Description, Parser a)] -> Parser a

-- | Parse the given options from the command line
options :: MonadIO io => Description -> Parser a -> io a

-- | Parse the given options from the command line and add additional
--   information
--   
--   Extended version of <tt>options</tt> with program version header and
--   footer information
optionsExt :: MonadIO io => Header -> Footer -> Description -> Version -> Parser a -> io a
instance Data.String.IsString Turtle.Options.ArgName
instance Data.String.IsString Turtle.Options.CommandName
instance Data.String.IsString Turtle.Options.Description
instance Data.String.IsString Turtle.Options.Header
instance Data.String.IsString Turtle.Options.Footer
instance Data.String.IsString Turtle.Options.HelpMessage


-- | Use this module to either:
--   
--   <ul>
--   <li>match <a>Text</a> with light-weight backtracking patterns,
--   or:</li>
--   <li>parse structured values from <a>Text</a>.</li>
--   </ul>
--   
--   Example usage:
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; match ("can" &lt;|&gt; "cat") "cat"
--   ["cat"]
--   
--   &gt;&gt;&gt; match ("can" &lt;|&gt; "cat") "dog"
--   []
--   
--   &gt;&gt;&gt; match (decimal `sepBy` ",") "1,2,3"
--   [[1,2,3]]
--   </pre>
--   
--   This pattern has unlimited backtracking, and will return as many
--   solutions as possible:
--   
--   <pre>
--   &gt;&gt;&gt; match (prefix (star anyChar)) "123"
--   ["123","12","1",""]
--   </pre>
--   
--   Use <tt>do</tt> notation to structure more complex patterns:
--   
--   <pre>
--   &gt;&gt;&gt; :{
--   let bit = ("0" *&gt; pure False) &lt;|&gt; ("1" *&gt; pure True) :: Pattern Bool;
--       portableBitMap = do
--           { "P1"
--           ; width  &lt;- spaces1 *&gt; decimal
--           ; height &lt;- spaces1 *&gt; decimal
--           ; count width (count height (spaces1 *&gt; bit))
--           };
--   in  match (prefix portableBitMap) "P1\n2 2\n0 0\n1 0\n"
--   :}
--   [[[False,False],[True,False]]]
--   </pre>
module Turtle.Pattern

-- | A fully backtracking pattern that parses an <tt>'a'</tt> from some
--   <a>Text</a>
data Pattern a

-- | Match a <a>Pattern</a> against a <a>Text</a> input, returning all
--   possible solutions
--   
--   The <a>Pattern</a> must match the entire <a>Text</a>
match :: Pattern a -> Text -> [a]

-- | Match any character
--   
--   <pre>
--   &gt;&gt;&gt; match anyChar "1"
--   "1"
--   
--   &gt;&gt;&gt; match anyChar ""
--   ""
--   </pre>
anyChar :: Pattern Char

-- | Matches the end of input
--   
--   <pre>
--   &gt;&gt;&gt; match eof "1"
--   []
--   
--   &gt;&gt;&gt; match eof ""
--   [()]
--   </pre>
eof :: Pattern ()

-- | Synonym for <a>anyChar</a>
dot :: Pattern Char

-- | Match any character that satisfies the given predicate
--   
--   <pre>
--   &gt;&gt;&gt; match (satisfy (== '1')) "1"
--   "1"
--   
--   &gt;&gt;&gt; match (satisfy (== '2')) "1"
--   ""
--   </pre>
satisfy :: (Char -> Bool) -> Pattern Char

-- | Match a specific character
--   
--   <pre>
--   &gt;&gt;&gt; match (char '1') "1"
--   "1"
--   
--   &gt;&gt;&gt; match (char '2') "1"
--   ""
--   </pre>
char :: Char -> Pattern Char

-- | Match any character except the given one
--   
--   <pre>
--   &gt;&gt;&gt; match (notChar '2') "1"
--   "1"
--   
--   &gt;&gt;&gt; match (notChar '1') "1"
--   ""
--   </pre>
notChar :: Char -> Pattern Char

-- | Match a specific string
--   
--   <pre>
--   &gt;&gt;&gt; match (text "123") "123"
--   ["123"]
--   </pre>
--   
--   You can also omit the <a>text</a> function if you enable the
--   <tt>OverloadedStrings</tt> extension:
--   
--   <pre>
--   &gt;&gt;&gt; match "123" "123"
--   ["123"]
--   </pre>
text :: Text -> Pattern Text

-- | Match a specific string in a case-insensitive way
--   
--   This only handles ASCII strings
--   
--   <pre>
--   &gt;&gt;&gt; match (asciiCI "abc") "ABC"
--   ["ABC"]
--   </pre>
asciiCI :: Text -> Pattern Text

-- | Match any one of the given characters
--   
--   <pre>
--   &gt;&gt;&gt; match (oneOf "1a") "1"
--   "1"
--   
--   &gt;&gt;&gt; match (oneOf "2a") "1"
--   ""
--   </pre>
oneOf :: [Char] -> Pattern Char

-- | Match anything other than the given characters
--   
--   <pre>
--   &gt;&gt;&gt; match (noneOf "2a") "1"
--   "1"
--   
--   &gt;&gt;&gt; match (noneOf "1a") "1"
--   ""
--   </pre>
noneOf :: [Char] -> Pattern Char

-- | Match a whitespace character
--   
--   <pre>
--   &gt;&gt;&gt; match space " "
--   " "
--   
--   &gt;&gt;&gt; match space "1"
--   ""
--   </pre>
space :: Pattern Char

-- | Match zero or more whitespace characters
--   
--   <pre>
--   &gt;&gt;&gt; match spaces "  "
--   ["  "]
--   
--   &gt;&gt;&gt; match spaces ""
--   [""]
--   </pre>
spaces :: Pattern Text

-- | Match one or more whitespace characters
--   
--   <pre>
--   &gt;&gt;&gt; match spaces1 "  "
--   ["  "]
--   
--   &gt;&gt;&gt; match spaces1 ""
--   []
--   </pre>
spaces1 :: Pattern Text

-- | Match the tab character (<tt>'t'</tt>)
--   
--   <pre>
--   &gt;&gt;&gt; match tab "\t"
--   "\t"
--   
--   &gt;&gt;&gt; match tab " "
--   ""
--   </pre>
tab :: Pattern Char

-- | Match the newline character (<tt>'n'</tt>)
--   
--   <pre>
--   &gt;&gt;&gt; match newline "\n"
--   "\n"
--   
--   &gt;&gt;&gt; match newline " "
--   ""
--   </pre>
newline :: Pattern Char

-- | Matches a carriage return (<tt>'r'</tt>) followed by a newline
--   (<tt>'n'</tt>)
--   
--   <pre>
--   &gt;&gt;&gt; match crlf "\r\n"
--   ["\r\n"]
--   
--   &gt;&gt;&gt; match crlf "\n\r"
--   []
--   </pre>
crlf :: Pattern Text

-- | Match an uppercase letter
--   
--   <pre>
--   &gt;&gt;&gt; match upper "A"
--   "A"
--   
--   &gt;&gt;&gt; match upper "a"
--   ""
--   </pre>
upper :: Pattern Char

-- | Match a lowercase letter
--   
--   <pre>
--   &gt;&gt;&gt; match lower "a"
--   "a"
--   
--   &gt;&gt;&gt; match lower "A"
--   ""
--   </pre>
lower :: Pattern Char

-- | Match a letter or digit
--   
--   <pre>
--   &gt;&gt;&gt; match alphaNum "1"
--   "1"
--   
--   &gt;&gt;&gt; match alphaNum "a"
--   "a"
--   
--   &gt;&gt;&gt; match alphaNum "A"
--   "A"
--   
--   &gt;&gt;&gt; match alphaNum "."
--   ""
--   </pre>
alphaNum :: Pattern Char

-- | Match a letter
--   
--   <pre>
--   &gt;&gt;&gt; match letter "A"
--   "A"
--   
--   &gt;&gt;&gt; match letter "a"
--   "a"
--   
--   &gt;&gt;&gt; match letter "1"
--   ""
--   </pre>
letter :: Pattern Char

-- | Match a digit
--   
--   <pre>
--   &gt;&gt;&gt; match digit "1"
--   "1"
--   
--   &gt;&gt;&gt; match digit "a"
--   ""
--   </pre>
digit :: Pattern Char

-- | Match a hexadecimal digit
--   
--   <pre>
--   &gt;&gt;&gt; match hexDigit "1"
--   "1"
--   
--   &gt;&gt;&gt; match hexDigit "A"
--   "A"
--   
--   &gt;&gt;&gt; match hexDigit "a"
--   "a"
--   
--   &gt;&gt;&gt; match hexDigit "g"
--   ""
--   </pre>
hexDigit :: Pattern Char

-- | Match an octal digit
--   
--   <pre>
--   &gt;&gt;&gt; match octDigit "1"
--   "1"
--   
--   &gt;&gt;&gt; match octDigit "9"
--   ""
--   </pre>
octDigit :: Pattern Char

-- | Match an unsigned decimal number
--   
--   <pre>
--   &gt;&gt;&gt; match decimal  "123"
--   [123]
--   
--   &gt;&gt;&gt; match decimal "-123"
--   []
--   </pre>
decimal :: Num n => Pattern n

-- | Transform a numeric parser to accept an optional leading <tt>'+'</tt>
--   or <tt>'-'</tt> sign
--   
--   <pre>
--   &gt;&gt;&gt; match (signed decimal) "+123"
--   [123]
--   
--   &gt;&gt;&gt; match (signed decimal) "-123"
--   [-123]
--   
--   &gt;&gt;&gt; match (signed decimal)  "123"
--   [123]
--   </pre>
signed :: Num a => Pattern a -> Pattern a

-- | Use this to match the prefix of a string
--   
--   <pre>
--   &gt;&gt;&gt; match         "A"  "ABC"
--   []
--   
--   &gt;&gt;&gt; match (prefix "A") "ABC"
--   ["A"]
--   </pre>
prefix :: Pattern a -> Pattern a

-- | Use this to match the suffix of a string
--   
--   <pre>
--   &gt;&gt;&gt; match         "C"  "ABC"
--   []
--   
--   &gt;&gt;&gt; match (suffix "C") "ABC"
--   ["C"]
--   </pre>
suffix :: Pattern a -> Pattern a

-- | Use this to match the interior of a string
--   
--   <pre>
--   &gt;&gt;&gt; match      "B"  "ABC"
--   []
--   
--   &gt;&gt;&gt; match (has "B") "ABC"
--   ["B"]
--   </pre>
has :: Pattern a -> Pattern a

-- | Match the entire string if it begins with the given pattern
--   
--   This returns the entire string, not just the matched prefix
--   
--   <pre>
--   &gt;&gt;&gt; match (begins  "A"             ) "ABC"
--   ["ABC"]
--   
--   &gt;&gt;&gt; match (begins ("A" *&gt; pure "1")) "ABC"
--   ["1BC"]
--   </pre>
begins :: Pattern Text -> Pattern Text

-- | Match the entire string if it ends with the given pattern
--   
--   This returns the entire string, not just the matched prefix
--   
--   <pre>
--   &gt;&gt;&gt; match (ends  "C"             ) "ABC"
--   ["ABC"]
--   
--   &gt;&gt;&gt; match (ends ("C" *&gt; pure "1")) "ABC"
--   ["AB1"]
--   </pre>
ends :: Pattern Text -> Pattern Text

-- | Match the entire string if it contains the given pattern
--   
--   This returns the entire string, not just the interior pattern
--   
--   <pre>
--   &gt;&gt;&gt; match (contains  "B"             ) "ABC"
--   ["ABC"]
--   
--   &gt;&gt;&gt; match (contains ("B" *&gt; pure "1")) "ABC"
--   ["A1C"]
--   </pre>
contains :: Pattern Text -> Pattern Text

-- | <tt>(<a>invert</a> p)</tt> succeeds if <tt>p</tt> fails and fails if
--   <tt>p</tt> succeeds
--   
--   <pre>
--   &gt;&gt;&gt; match (invert "A") "A"
--   []
--   
--   &gt;&gt;&gt; match (invert "A") "B"
--   [()]
--   
--   &gt;&gt;&gt; match (invert "A") "AA"
--   [()]
--   </pre>
invert :: Pattern a -> Pattern ()

-- | Match a <a>Char</a>, but return <a>Text</a>
--   
--   <pre>
--   &gt;&gt;&gt; match (once (char '1')) "1"
--   ["1"]
--   
--   &gt;&gt;&gt; match (once (char '1')) ""
--   []
--   </pre>
once :: Pattern Char -> Pattern Text

-- | Parse 0 or more occurrences of the given character
--   
--   <pre>
--   &gt;&gt;&gt; match (star anyChar) "123"
--   ["123"]
--   
--   &gt;&gt;&gt; match (star anyChar) ""
--   [""]
--   </pre>
--   
--   See also: <a>chars</a>
star :: Pattern Char -> Pattern Text

-- | Parse 1 or more occurrences of the given character
--   
--   <pre>
--   &gt;&gt;&gt; match (plus digit) "123"
--   ["123"]
--   
--   &gt;&gt;&gt; match (plus digit) ""
--   []
--   </pre>
--   
--   See also: <a>chars1</a>
plus :: Pattern Char -> Pattern Text

-- | Patterns that match multiple times are greedy by default, meaning that
--   they try to match as many times as possible. The <a>selfless</a>
--   combinator makes a pattern match as few times as possible
--   
--   This only changes the order in which solutions are returned, by
--   prioritizing less greedy solutions
--   
--   <pre>
--   &gt;&gt;&gt; match (prefix (selfless (some anyChar))) "123"
--   ["1","12","123"]
--   
--   &gt;&gt;&gt; match (prefix           (some anyChar) ) "123"
--   ["123","12","1"]
--   </pre>
selfless :: Pattern a -> Pattern a

-- | Apply the patterns in the list in order, until one of them succeeds
--   
--   <pre>
--   &gt;&gt;&gt; match (choice ["cat", "dog", "egg"]) "egg"
--   ["egg"]
--   
--   &gt;&gt;&gt; match (choice ["cat", "dog", "egg"]) "cat"
--   ["cat"]
--   
--   &gt;&gt;&gt; match (choice ["cat", "dog", "egg"]) "fan"
--   []
--   </pre>
choice :: [Pattern a] -> Pattern a

-- | Apply the given pattern a fixed number of times, collecting the
--   results
--   
--   <pre>
--   &gt;&gt;&gt; match (count 3 anyChar) "123"
--   ["123"]
--   
--   &gt;&gt;&gt; match (count 4 anyChar) "123"
--   []
--   </pre>
count :: Int -> Pattern a -> Pattern [a]

-- | Apply the given pattern at least the given number of times, collecting
--   the results
--   
--   <pre>
--   &gt;&gt;&gt; match (lowerBounded 5 dot) "123"
--   []
--   
--   &gt;&gt;&gt; match (lowerBounded 2 dot) "123"
--   ["123"]
--   </pre>
lowerBounded :: Int -> Pattern a -> Pattern [a]

-- | Apply the given pattern 0 or more times, up to a given bound,
--   collecting the results
--   
--   <pre>
--   &gt;&gt;&gt; match (upperBounded 5 dot) "123"
--   ["123"]
--   
--   &gt;&gt;&gt; match (upperBounded 2 dot) "123"
--   []
--   
--   &gt;&gt;&gt; match ((,) &lt;$&gt; upperBounded 2 dot &lt;*&gt; chars) "123"
--   [("12","3"),("1","23")]
--   </pre>
upperBounded :: Int -> Pattern a -> Pattern [a]

-- | Apply the given pattern a number of times restricted by given lower
--   and upper bounds, collecting the results
--   
--   <pre>
--   &gt;&gt;&gt; match (bounded 2 5 "cat") "catcatcat"
--   [["cat","cat","cat"]]
--   
--   &gt;&gt;&gt; match (bounded 2 5 "cat") "cat"
--   []
--   
--   &gt;&gt;&gt; match (bounded 2 5 "cat") "catcatcatcatcatcat"
--   []
--   </pre>
--   
--   <a>bounded</a> could be implemented naively as follows:
--   
--   <pre>
--   bounded m n p = do
--     x &lt;- choice (map pure [m..n])
--     count x p
--   </pre>
bounded :: Int -> Int -> Pattern a -> Pattern [a]

-- | Transform a parser to a succeed with an empty value instead of failing
--   
--   See also: <a>optional</a>
--   
--   <pre>
--   &gt;&gt;&gt; match (option "1" &lt;&gt; "2") "12"
--   ["12"]
--   
--   &gt;&gt;&gt; match (option "1" &lt;&gt; "2") "2"
--   ["2"]
--   </pre>
option :: Monoid a => Pattern a -> Pattern a

-- | <tt>(between open close p)</tt> matches <tt>'p'</tt> in between
--   <tt>'open'</tt> and <tt>'close'</tt>
--   
--   <pre>
--   &gt;&gt;&gt; match (between (char '(') (char ')') (star anyChar)) "(123)"
--   ["123"]
--   
--   &gt;&gt;&gt; match (between (char '(') (char ')') (star anyChar)) "(123"
--   []
--   </pre>
between :: Pattern a -> Pattern b -> Pattern c -> Pattern c

-- | Discard the pattern's result
--   
--   <pre>
--   &gt;&gt;&gt; match (skip anyChar) "1"
--   [()]
--   
--   &gt;&gt;&gt; match (skip anyChar) ""
--   []
--   </pre>
skip :: Pattern a -> Pattern ()

-- | Restrict the pattern to consume no more than the given number of
--   characters
--   
--   <pre>
--   &gt;&gt;&gt; match (within 2 decimal) "12"
--   [12]
--   
--   &gt;&gt;&gt; match (within 2 decimal) "1"
--   [1]
--   
--   &gt;&gt;&gt; match (within 2 decimal) "123"
--   []
--   </pre>
within :: Int -> Pattern a -> Pattern a

-- | Require the pattern to consume exactly the given number of characters
--   
--   <pre>
--   &gt;&gt;&gt; match (fixed 2 decimal) "12"
--   [12]
--   
--   &gt;&gt;&gt; match (fixed 2 decimal) "1"
--   []
--   </pre>
fixed :: Int -> Pattern a -> Pattern a

-- | <tt>p <a>sepBy</a> sep</tt> matches zero or more occurrences of
--   <tt>p</tt> separated by <tt>sep</tt>
--   
--   <pre>
--   &gt;&gt;&gt; match (decimal `sepBy` char ',') "1,2,3"
--   [[1,2,3]]
--   
--   &gt;&gt;&gt; match (decimal `sepBy` char ',') ""
--   [[]]
--   </pre>
sepBy :: Pattern a -> Pattern b -> Pattern [a]

-- | <tt>p <a>sepBy1</a> sep</tt> matches one or more occurrences of
--   <tt>p</tt> separated by <tt>sep</tt>
--   
--   <pre>
--   &gt;&gt;&gt; match (decimal `sepBy1` ",") "1,2,3"
--   [[1,2,3]]
--   
--   &gt;&gt;&gt; match (decimal `sepBy1` ",") ""
--   []
--   </pre>
sepBy1 :: Pattern a -> Pattern b -> Pattern [a]

-- | Like <tt>star dot</tt> or <tt>star anyChar</tt>, except more efficient
chars :: Pattern Text

-- | Like <tt>plus dot</tt> or <tt>plus anyChar</tt>, except more efficient
chars1 :: Pattern Text
instance GHC.Base.MonadPlus Turtle.Pattern.Pattern
instance GHC.Base.Alternative Turtle.Pattern.Pattern
instance GHC.Base.Monad Turtle.Pattern.Pattern
instance GHC.Base.Applicative Turtle.Pattern.Pattern
instance GHC.Base.Functor Turtle.Pattern.Pattern
instance GHC.Base.Monoid a => GHC.Base.Semigroup (Turtle.Pattern.Pattern a)
instance GHC.Base.Monoid a => GHC.Base.Monoid (Turtle.Pattern.Pattern a)
instance GHC.Base.Monoid a => GHC.Num.Num (Turtle.Pattern.Pattern a)
instance (a GHC.Types.~ Data.Text.Internal.Text) => Data.String.IsString (Turtle.Pattern.Pattern a)


-- | You can think of <a>Shell</a> as <tt>[]</tt> + <a>IO</a> +
--   <tt>Managed</tt>. In fact, you can embed all three of them within a
--   <a>Shell</a>:
--   
--   <pre>
--   select ::        [a] -&gt; Shell a
--   liftIO ::      IO a  -&gt; Shell a
--   using  :: Managed a  -&gt; Shell a
--   </pre>
--   
--   Those three embeddings obey these laws:
--   
--   <pre>
--   do { x &lt;- select m; select (f x) } = select (do { x &lt;- m; f x })
--   do { x &lt;- liftIO m; liftIO (f x) } = liftIO (do { x &lt;- m; f x })
--   do { x &lt;- with   m; using  (f x) } = using  (do { x &lt;- m; f x })
--   
--   select (return x) = return x
--   liftIO (return x) = return x
--   using  (return x) = return x
--   </pre>
--   
--   ... and <a>select</a> obeys these additional laws:
--   
--   <pre>
--   select xs &lt;|&gt; select ys = select (xs &lt;|&gt; ys)
--   select empty = empty
--   </pre>
--   
--   You typically won't build <a>Shell</a>s using the <a>Shell</a>
--   constructor. Instead, use these functions to generate primitive
--   <a>Shell</a>s:
--   
--   <ul>
--   <li><a>empty</a>, to create a <a>Shell</a> that outputs nothing</li>
--   <li><a>return</a>, to create a <a>Shell</a> that outputs a single
--   value</li>
--   <li><a>select</a>, to range over a list of values within a
--   <a>Shell</a></li>
--   <li><a>liftIO</a>, to embed an <a>IO</a> action within a
--   <a>Shell</a></li>
--   <li><a>using</a>, to acquire a <tt>Managed</tt> resource within a
--   <a>Shell</a></li>
--   </ul>
--   
--   Then use these classes to combine those primitive <a>Shell</a>s into
--   larger <a>Shell</a>s:
--   
--   <ul>
--   <li><a>Alternative</a>, to concatenate <a>Shell</a> outputs using
--   (<a>&lt;|&gt;</a>)</li>
--   <li><a>Monad</a>, to build <a>Shell</a> comprehensions using
--   <tt>do</tt> notation</li>
--   </ul>
--   
--   If you still insist on building your own <a>Shell</a> from scratch,
--   then the <a>Shell</a> you build must satisfy this law:
--   
--   <pre>
--   -- For every shell `s`:
--   _foldShell s (FoldShell step begin done) = do
--       x' &lt;- _foldShell s (FoldShell step begin return)
--       done x'
--   </pre>
--   
--   ... which is a fancy way of saying that your <a>Shell</a> must call
--   <tt>'begin'</tt> exactly once when it begins and call <tt>'done'</tt>
--   exactly once when it ends.
module Turtle.Shell

-- | A <tt>(Shell a)</tt> is a protected stream of <tt>a</tt>'s with side
--   effects
newtype Shell a
Shell :: (forall r. FoldShell a r -> IO r) -> Shell a
[_foldShell] :: Shell a -> forall r. FoldShell a r -> IO r

-- | This is similar to <tt><a>FoldM</a> <a>IO</a></tt> except that the
--   <tt>begin</tt> field is pure
--   
--   This small difference is necessary to implement a well-behaved
--   <a>MonadCatch</a> instance for <a>Shell</a>
data FoldShell a b
FoldShell :: (x -> a -> IO x) -> x -> (x -> IO b) -> FoldShell a b

-- | Provided for backwards compatibility with versions of
--   <tt>turtle-1.4.*</tt> and older
_foldIO :: Shell a -> FoldM IO a r -> IO r

-- | Provided for ease of migration from versions of <tt>turtle-1.4.*</tt>
--   and older
_Shell :: (forall r. FoldM IO a r -> IO r) -> Shell a

-- | Use a <tt><a>FoldM</a> <a>IO</a></tt> to reduce the stream of
--   <tt>a</tt>'s produced by a <a>Shell</a>
foldIO :: MonadIO io => Shell a -> FoldM IO a r -> io r

-- | Use a <a>FoldShell</a> to reduce the stream of <tt>a</tt>'s produced
--   by a <a>Shell</a>
foldShell :: MonadIO io => Shell a -> FoldShell a b -> io b

-- | Use a <a>Fold</a> to reduce the stream of <tt>a</tt>'s produced by a
--   <a>Shell</a>
fold :: MonadIO io => Shell a -> Fold a b -> io b

-- | Flipped version of <a>fold</a>. Useful for reducing a stream of data
--   
--   <h4><b>Example</b></h4>
--   
--   Sum a <a>Shell</a> of numbers:
--   
--   <pre>
--   &gt;&gt;&gt; select [1, 2, 3] &amp; reduce Fold.sum
--   6
--   </pre>
reduce :: MonadIO io => Fold a b -> Shell a -> io b

-- | Run a <a>Shell</a> to completion, discarding any unused values
sh :: MonadIO io => Shell a -> io ()

-- | Run a <a>Shell</a> to completion, <a>print</a>ing any unused values
view :: (MonadIO io, Show a) => Shell a -> io ()

-- | Convert a list to a <a>Shell</a> that emits each element of the list
select :: Foldable f => f a -> Shell a

-- | Lift a computation from the <a>IO</a> monad.
liftIO :: MonadIO m => IO a -> m a
using :: MonadManaged m => Managed a -> m a
instance GHC.Base.Functor Turtle.Shell.Shell
instance GHC.Base.Applicative Turtle.Shell.Shell
instance GHC.Base.Monad Turtle.Shell.Shell
instance GHC.Base.Alternative Turtle.Shell.Shell
instance GHC.Base.MonadPlus Turtle.Shell.Shell
instance Control.Monad.IO.Class.MonadIO Turtle.Shell.Shell
instance Control.Monad.Managed.MonadManaged Turtle.Shell.Shell
instance Control.Monad.Catch.MonadThrow Turtle.Shell.Shell
instance Control.Monad.Catch.MonadCatch Turtle.Shell.Shell
instance Control.Monad.Fail.MonadFail Turtle.Shell.Shell
instance GHC.Base.Monoid a => GHC.Base.Semigroup (Turtle.Shell.Shell a)
instance GHC.Base.Monoid a => GHC.Base.Monoid (Turtle.Shell.Shell a)
instance GHC.Base.Monoid a => GHC.Num.Num (Turtle.Shell.Shell a)
instance Data.String.IsString a => Data.String.IsString (Turtle.Shell.Shell a)


-- | This module provides a large suite of utilities that resemble Unix
--   utilities.
--   
--   Many of these commands are just existing Haskell commands renamed to
--   match their Unix counterparts:
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; cd "/tmp"
--   
--   &gt;&gt;&gt; pwd
--   FilePath "/tmp"
--   </pre>
--   
--   Some commands are <a>Shell</a>s that emit streams of values.
--   <a>view</a> prints all values in a <a>Shell</a> stream:
--   
--   <pre>
--   &gt;&gt;&gt; view (ls "/usr")
--   FilePath "/usr/lib"
--   FilePath "/usr/src"
--   FilePath "/usr/sbin"
--   FilePath "/usr/include"
--   FilePath "/usr/share"
--   FilePath "/usr/games"
--   FilePath "/usr/local"
--   FilePath "/usr/bin"
--   
--   &gt;&gt;&gt; view (find (suffix "Browser.py") "/usr/lib")
--   FilePath "/usr/lib/python3.4/idlelib/ClassBrowser.py"
--   FilePath "/usr/lib/python3.4/idlelib/RemoteObjectBrowser.py"
--   FilePath "/usr/lib/python3.4/idlelib/PathBrowser.py"
--   FilePath "/usr/lib/python3.4/idlelib/ObjectBrowser.py"
--   </pre>
--   
--   Use <a>fold</a> to reduce the output of a <a>Shell</a> stream:
--   
--   <pre>
--   &gt;&gt;&gt; import qualified Control.Foldl as Fold
--   
--   &gt;&gt;&gt; fold (ls "/usr") Fold.length
--   8
--   
--   &gt;&gt;&gt; fold (find (suffix "Browser.py") "/usr/lib") Fold.head
--   Just (FilePath "/usr/lib/python3.4/idlelib/ClassBrowser.py")
--   </pre>
--   
--   Create files using <a>output</a>:
--   
--   <pre>
--   &gt;&gt;&gt; output "foo.txt" ("123" &lt;|&gt; "456" &lt;|&gt; "ABC")
--   
--   &gt;&gt;&gt; realpath "foo.txt"
--   FilePath "/tmp/foo.txt"
--   </pre>
--   
--   Read in files using <a>input</a>:
--   
--   <pre>
--   &gt;&gt;&gt; stdout (input "foo.txt")
--   123
--   456
--   ABC
--   </pre>
--   
--   Format strings in a type safe way using <a>format</a>:
--   
--   <pre>
--   &gt;&gt;&gt; dir &lt;- pwd
--   
--   &gt;&gt;&gt; format ("I am in the "%fp%" directory") dir
--   "I am in the /tmp directory"
--   </pre>
--   
--   Commands like <a>grep</a>, <a>sed</a> and <a>find</a> accept arbitrary
--   <a>Pattern</a>s
--   
--   <pre>
--   &gt;&gt;&gt; stdout (grep ("123" &lt;|&gt; "ABC") (input "foo.txt"))
--   123
--   ABC
--   
--   &gt;&gt;&gt; let exclaim = fmap (&lt;&gt; "!") (plus digit)
--   
--   &gt;&gt;&gt; stdout (sed exclaim (input "foo.txt"))
--   123!
--   456!
--   ABC
--   </pre>
--   
--   Note that <a>grep</a> and <a>find</a> differ from their Unix
--   counterparts by requiring that the <a>Pattern</a> matches the entire
--   line or file name by default. However, you can optionally match the
--   prefix, suffix, or interior of a line:
--   
--   <pre>
--   &gt;&gt;&gt; stdout (grep (has    "2") (input "foo.txt"))
--   123
--   
--   &gt;&gt;&gt; stdout (grep (prefix "1") (input "foo.txt"))
--   123
--   
--   &gt;&gt;&gt; stdout (grep (suffix "3") (input "foo.txt"))
--   123
--   </pre>
--   
--   You can also build up more sophisticated <a>Shell</a> programs using
--   <a>sh</a> in conjunction with <tt>do</tt> notation:
--   
--   <pre>
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   import Turtle
--   
--   main = sh example
--   
--   example = do
--       -- Read in file names from "files1.txt" and "files2.txt"
--       file &lt;- fmap fromText (input "files1.txt" &lt;|&gt; input "files2.txt")
--   
--       -- Stream each file to standard output only if the file exists
--       True &lt;- liftIO (testfile file)
--       line &lt;- input file
--       liftIO (echo line)
--   </pre>
--   
--   See <a>Turtle.Tutorial</a> for an extended tutorial explaining how to
--   use this library in greater detail.
module Turtle.Prelude

-- | Print exactly one line to <tt>stdout</tt>
--   
--   To print more than one line see <a>printf</a>, which also supports
--   formatted output
echo :: MonadIO io => Line -> io ()

-- | Print exactly one line to <tt>stderr</tt>
err :: MonadIO io => Line -> io ()

-- | Read in a line from <tt>stdin</tt>
--   
--   Returns <a>Nothing</a> if at end of input
readline :: MonadIO io => io (Maybe Line)

-- | Read in the entire content of a text file.
--   
--   This computation throws <a>IOError</a> on failure. See “Classifying
--   I/O errors” in the <a>System.IO.Error</a> documentation for
--   information on why the failure occured.
readTextFile :: FilePath -> IO Text

-- | Replace the entire content of a text file with the provided
--   <a>Text</a>.
--   
--   This computation throws <a>IOError</a> on failure. See “Classifying
--   I/O errors” in the <a>System.IO.Error</a> documentation for
--   information on why the failure occured.
writeTextFile :: FilePath -> Text -> IO ()

-- | Get command line arguments in a list
arguments :: MonadIO io => io [Text]

-- | Set or modify an environment variable
export :: MonadIO io => Text -> Text -> io ()

-- | Delete an environment variable
unset :: MonadIO io => Text -> io ()

-- | Look up an environment variable
need :: MonadIO io => Text -> io (Maybe Text)

-- | Retrieve all environment variables
env :: MonadIO io => io [(Text, Text)]

-- | Change the current directory
cd :: MonadIO io => FilePath -> io ()

-- | Get the current directory
pwd :: MonadIO io => io FilePath

-- | Get the home directory
home :: MonadIO io => io FilePath

-- | Get the path pointed to by a symlink
readlink :: MonadIO io => FilePath -> io FilePath

-- | Canonicalize a path
realpath :: MonadIO io => FilePath -> io FilePath

-- | Move a file or directory
--   
--   Works if the two paths are on the same filesystem. If not, <tt>mv</tt>
--   will still work when dealing with a regular file, but the operation
--   will not be atomic
mv :: MonadIO io => FilePath -> FilePath -> io ()

-- | Create a directory
--   
--   Fails if the directory is present
mkdir :: MonadIO io => FilePath -> io ()

-- | Create a directory tree (equivalent to <tt>mkdir -p</tt>)
--   
--   Does not fail if the directory is present
mktree :: MonadIO io => FilePath -> io ()

-- | Copy a file
cp :: MonadIO io => FilePath -> FilePath -> io ()

-- | Copy a directory tree and preserve symbolic links
cptree :: MonadIO io => FilePath -> FilePath -> io ()

-- | Copy a directory tree and dereference symbolic links
cptreeL :: MonadIO io => FilePath -> FilePath -> io ()

-- | Create a symlink from one <tt>FilePath</tt> to another
symlink :: MonadIO io => FilePath -> FilePath -> io ()

-- | Returns <a>True</a> if the given <a>FilePath</a> is not a symbolic
--   link
--   
--   This comes in handy in conjunction with <a>lsif</a>:
--   
--   <pre>
--   lsif isNotSymbolicLink
--   </pre>
isNotSymbolicLink :: MonadIO io => FilePath -> io Bool

-- | Remove a file
rm :: MonadIO io => FilePath -> io ()

-- | Remove a directory
rmdir :: MonadIO io => FilePath -> io ()

-- | Remove a directory tree (equivalent to <tt>rm -r</tt>)
--   
--   Use at your own risk
rmtree :: MonadIO io => FilePath -> io ()

-- | Check if a file exists
testfile :: MonadIO io => FilePath -> io Bool

-- | Check if a directory exists
testdir :: MonadIO io => FilePath -> io Bool

-- | Check if a path exists
testpath :: MonadIO io => FilePath -> io Bool

-- | Get the current time
date :: MonadIO io => io UTCTime

-- | Get the time a file was last modified
datefile :: MonadIO io => FilePath -> io UTCTime

-- | Touch a file, updating the access and modification times to the
--   current time
--   
--   Creates an empty file if it does not exist
touch :: MonadIO io => FilePath -> io ()

-- | Time how long a command takes in monotonic wall clock time
--   
--   Returns the duration alongside the return value
time :: MonadIO io => io a -> io (a, NominalDiffTime)

-- | Get the system's host name
hostname :: MonadIO io => io Text

-- | Show the full path of an executable file
which :: MonadIO io => FilePath -> io (Maybe FilePath)

-- | Show all matching executables in PATH, not just the first
whichAll :: FilePath -> Shell FilePath

-- | Sleep for the given duration
--   
--   A numeric literal argument is interpreted as seconds. In other words,
--   <tt>(sleep 2.0)</tt> will sleep for two seconds.
sleep :: MonadIO io => NominalDiffTime -> io ()

-- | Exit with the given exit code
--   
--   An exit code of <tt>0</tt> indicates success
exit :: MonadIO io => ExitCode -> io a

-- | Throw an exception using the provided <a>Text</a> message
die :: MonadIO io => Text -> io a

-- | Analogous to <a>&amp;&amp;</a> in Bash
--   
--   Runs the second command only if the first one returns
--   <a>ExitSuccess</a>
(.&&.) :: Monad m => m ExitCode -> m ExitCode -> m ExitCode
infixr 3 .&&.

-- | Analogous to <a>||</a> in Bash
--   
--   Run the second command only if the first one returns
--   <a>ExitFailure</a>
(.||.) :: Monad m => m ExitCode -> m ExitCode -> m ExitCode
infixr 2 .||.

-- | Acquire a <tt>Managed</tt> read-only <a>Handle</a> from a
--   <a>FilePath</a>
readonly :: MonadManaged managed => FilePath -> managed Handle

-- | Acquire a <tt>Managed</tt> write-only <a>Handle</a> from a
--   <a>FilePath</a>
writeonly :: MonadManaged managed => FilePath -> managed Handle

-- | Acquire a <tt>Managed</tt> append-only <a>Handle</a> from a
--   <a>FilePath</a>
appendonly :: MonadManaged managed => FilePath -> managed Handle

-- | Create a temporary file underneath the given directory
--   
--   Deletes the temporary file when done
--   
--   Note that this provides the <a>Handle</a> of the file in order to
--   avoid a potential race condition from the file being moved or deleted
--   before you have a chance to open the file. The <a>mktempfile</a>
--   function provides a simpler API if you don't need to worry about that
--   possibility.
mktemp :: MonadManaged managed => FilePath -> Text -> managed (FilePath, Handle)

-- | Create a temporary file underneath the given directory
--   
--   Deletes the temporary file when done
mktempfile :: MonadManaged managed => FilePath -> Text -> managed FilePath

-- | Create a temporary directory underneath the given directory
--   
--   Deletes the temporary directory when done
mktempdir :: MonadManaged managed => FilePath -> Text -> managed FilePath

-- | Fork a thread, acquiring an <a>Async</a> value
fork :: MonadManaged managed => IO a -> managed (Async a)

-- | Wait for an <a>Async</a> action to complete
wait :: MonadIO io => Async a -> io a

-- | Change the current directory. Once the current <a>Shell</a> is done,
--   it returns back to the original directory.
--   
--   <pre>
--   &gt;&gt;&gt; :set -XOverloadedStrings
--   
--   &gt;&gt;&gt; cd "/"
--   
--   &gt;&gt;&gt; view (pushd "/tmp" &gt;&gt; pwd)
--   FilePath "/tmp"
--   
--   &gt;&gt;&gt; pwd
--   FilePath "/"
--   </pre>
pushd :: MonadManaged managed => FilePath -> managed ()

-- | Read lines of <a>Text</a> from standard input
stdin :: Shell Line

-- | Read lines of <a>Text</a> from a file
input :: FilePath -> Shell Line

-- | Read lines of <a>Text</a> from a <a>Handle</a>
inhandle :: Handle -> Shell Line

-- | Stream lines of <a>Text</a> to standard output
stdout :: MonadIO io => Shell Line -> io ()

-- | Stream lines of <a>Text</a> to a file
output :: MonadIO io => FilePath -> Shell Line -> io ()

-- | Stream lines of <a>Text</a> to a <a>Handle</a>
outhandle :: MonadIO io => Handle -> Shell Line -> io ()

-- | Stream lines of <a>Text</a> to append to a file
append :: MonadIO io => FilePath -> Shell Line -> io ()

-- | Stream lines of <a>Text</a> to standard error
stderr :: MonadIO io => Shell Line -> io ()

-- | Read in a stream's contents strictly
strict :: MonadIO io => Shell Line -> io Text

-- | Stream all immediate children of the given directory, excluding
--   <tt>"."</tt> and <tt>".."</tt>
ls :: FilePath -> Shell FilePath

-- | Stream all recursive descendents of the given directory
--   
--   This skips any directories that fail the supplied predicate
--   
--   <pre>
--   lstree = lsif (\_ -&gt; return True)
--   </pre>
lsif :: (FilePath -> IO Bool) -> FilePath -> Shell FilePath

-- | Stream all recursive descendents of the given directory
lstree :: FilePath -> Shell FilePath

-- | Stream the recursive descendents of a given directory between a given
--   minimum and maximum depth
lsdepth :: Int -> Int -> FilePath -> Shell FilePath

-- | Combine the output of multiple <a>Shell</a>s, in order
cat :: [Shell a] -> Shell a

-- | Keep all lines that match the given <a>Pattern</a>
grep :: Pattern a -> Shell Line -> Shell Line

-- | Keep every <a>Text</a> element that matches the given <a>Pattern</a>
grepText :: Pattern a -> Shell Text -> Shell Text

-- | Replace all occurrences of a <a>Pattern</a> with its <a>Text</a>
--   result
--   
--   <a>sed</a> performs substitution on a line-by-line basis, meaning that
--   substitutions may not span multiple lines. Additionally, substitutions
--   may occur multiple times within the same line, like the behavior of
--   <tt>s/.../.../g</tt>.
--   
--   Warning: Do not use a <a>Pattern</a> that matches the empty string,
--   since it will match an infinite number of times. <a>sed</a> tries to
--   detect such <a>Pattern</a>s and <a>die</a> with an error message if
--   they occur, but this detection is necessarily incomplete.
sed :: Pattern Text -> Shell Line -> Shell Line

-- | Like <a>sed</a>, but the provided substitution must match the
--   beginning of the line
sedPrefix :: Pattern Text -> Shell Line -> Shell Line

-- | Like <a>sed</a>, but the provided substitution must match the end of
--   the line
sedSuffix :: Pattern Text -> Shell Line -> Shell Line

-- | Like <a>sed</a>, but the provided substitution must match the entire
--   line
sedEntire :: Pattern Text -> Shell Line -> Shell Line

-- | Make a `Shell Text -&gt; Shell Text` function work on <a>FilePath</a>s
--   instead. | Ignores any paths which cannot be decoded as valid
--   <a>Text</a>.
onFiles :: (Shell Text -> Shell Text) -> Shell FilePath -> Shell FilePath

-- | Like <a>sed</a>, but operates in place on a <a>FilePath</a> (analogous
--   to <tt>sed -i</tt>)
inplace :: MonadIO io => Pattern Text -> FilePath -> io ()

-- | Like <a>sedPrefix</a>, but operates in place on a <a>FilePath</a>
inplacePrefix :: MonadIO io => Pattern Text -> FilePath -> io ()

-- | Like <a>sedSuffix</a>, but operates in place on a <a>FilePath</a>
inplaceSuffix :: MonadIO io => Pattern Text -> FilePath -> io ()

-- | Like <a>sedEntire</a>, but operates in place on a <a>FilePath</a>
inplaceEntire :: MonadIO io => Pattern Text -> FilePath -> io ()

-- | Search a directory recursively for all files matching the given
--   <a>Pattern</a>
find :: Pattern a -> FilePath -> Shell FilePath

-- | Filter a shell of FilePaths according to a given pattern
findtree :: Pattern a -> Shell FilePath -> Shell FilePath

-- | A Stream of <tt>"y"</tt>s
yes :: Shell Line

-- | Number each element of a <a>Shell</a> (starting at 0)
nl :: Num n => Shell a -> Shell (n, a)

-- | Merge two <a>Shell</a>s together, element-wise
--   
--   If one <a>Shell</a> is longer than the other, the excess elements are
--   truncated
paste :: Shell a -> Shell b -> Shell (a, b)

-- | A <a>Shell</a> that endlessly emits <tt>()</tt>
endless :: Shell ()

-- | Limit a <a>Shell</a> to a fixed number of values
limit :: Int -> Shell a -> Shell a

-- | Limit a <a>Shell</a> to values that satisfy the predicate
--   
--   This terminates the stream on the first value that does not satisfy
--   the predicate
limitWhile :: (a -> Bool) -> Shell a -> Shell a

-- | Cache a <a>Shell</a>'s output so that repeated runs of the script will
--   reuse the result of previous runs. You must supply a <a>FilePath</a>
--   where the cached result will be stored.
--   
--   The stored result is only reused if the <a>Shell</a> successfully ran
--   to completion without any exceptions. Note: on some platforms Ctrl-C
--   will flush standard input and signal end of file before killing the
--   program, which may trick the program into "successfully" completing.
cache :: (Read a, Show a) => FilePath -> Shell a -> Shell a

-- | Run a list of IO actions in parallel using fork and wait.
--   
--   <pre>
--   &gt;&gt;&gt; view (parallel [(sleep 3) &gt;&gt; date, date, date])
--   2016-12-01 17:22:10.83296 UTC
--   2016-12-01 17:22:07.829876 UTC
--   2016-12-01 17:22:07.829963 UTC
--   </pre>
parallel :: [IO a] -> Shell a

-- | Returns the result of a <a>Shell</a> that outputs a single line. Note
--   that if no lines / more than 1 line is produced by the Shell, this
--   function will <a>die</a> with an error message.
--   
--   <pre>
--   main = do
--     directory &lt;- single (inshell "pwd" empty)
--     print directory
--   </pre>
single :: MonadIO io => Shell a -> io a

-- | Filter adjacent duplicate elements:
--   
--   <pre>
--   &gt;&gt;&gt; view (uniq (select [1,1,2,1,3]))
--   1
--   2
--   1
--   3
--   </pre>
uniq :: Eq a => Shell a -> Shell a

-- | Filter adjacent duplicates determined after applying the function to
--   the element:
--   
--   <pre>
--   &gt;&gt;&gt; view (uniqOn fst (select [(1,'a'),(1,'b'),(2,'c'),(1,'d'),(3,'e')]))
--   (1,'a')
--   (2,'c')
--   (1,'d')
--   (3,'e')
--   </pre>
uniqOn :: Eq b => (a -> b) -> Shell a -> Shell a

-- | Filter adjacent duplicate elements determined via the given function:
--   
--   <pre>
--   &gt;&gt;&gt; view (uniqBy (==) (select [1,1,2,1,3]))
--   1
--   2
--   1
--   3
--   </pre>
uniqBy :: (a -> a -> Bool) -> Shell a -> Shell a

-- | Return a new <a>Shell</a> that discards duplicates from the input
--   <a>Shell</a>:
--   
--   <pre>
--   &gt;&gt;&gt; view (nub (select [1, 1, 2, 3, 3, 4, 3]))
--   1
--   2
--   3
--   4
--   </pre>
nub :: Ord a => Shell a -> Shell a

-- | Return a new <a>Shell</a> that discards duplicates determined via the
--   given function from the input <a>Shell</a>:
--   
--   <pre>
--   &gt;&gt;&gt; view (nubOn id (select [1, 1, 2, 3, 3, 4, 3]))
--   1
--   2
--   3
--   4
--   </pre>
nubOn :: Ord b => (a -> b) -> Shell a -> Shell a

-- | Return a list of the sorted elements of the given <a>Shell</a>,
--   keeping duplicates:
--   
--   <pre>
--   &gt;&gt;&gt; sort (select [1,4,2,3,3,7])
--   [1,2,3,3,4,7]
--   </pre>
sort :: (Functor io, MonadIO io, Ord a) => Shell a -> io [a]

-- | Return a list of the elements of the given <a>Shell</a>, sorted after
--   applying the given function and keeping duplicates:
--   
--   <pre>
--   &gt;&gt;&gt; sortOn id (select [1,4,2,3,3,7])
--   [1,2,3,3,4,7]
--   </pre>
sortOn :: (Functor io, MonadIO io, Ord b) => (a -> b) -> Shell a -> io [a]

-- | Return a list of the elements of the given <a>Shell</a>, sorted by the
--   given function and keeping duplicates:
--   
--   <pre>
--   &gt;&gt;&gt; sortBy (comparing fst) (select [(1,'a'),(4,'b'),(2,'c'),(3,'d'),(3,'e'),(7,'f')])
--   [(1,'a'),(2,'c'),(3,'d'),(3,'e'),(4,'b'),(7,'f')]
--   </pre>
sortBy :: (Functor io, MonadIO io) => (a -> a -> Ordering) -> Shell a -> io [a]

-- | Group an arbitrary stream of <a>Text</a> into newline-delimited
--   <a>Line</a>s
--   
--   <pre>
--   &gt;&gt;&gt; stdout (toLines ("ABC" &lt;|&gt; "DEF" &lt;|&gt; "GHI")
--   ABCDEFGHI
--   
--   &gt;&gt;&gt; stdout (toLines empty)  -- Note that this always emits at least 1 `Line`
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; stdout (toLines ("ABC\nDEF" &lt;|&gt; "" &lt;|&gt; "GHI\nJKL"))
--   ABC
--   DEFGHI
--   JKL
--   </pre>
toLines :: Shell Text -> Shell Line

-- | Count the number of characters in the stream (like <tt>wc -c</tt>)
--   
--   This uses the convention that the elements of the stream are
--   implicitly ended by newlines that are one character wide
countChars :: Integral n => Fold Line n

-- | Count the number of words in the stream (like <tt>wc -w</tt>)
countWords :: Integral n => Fold Line n

-- | Count the number of lines in the stream (like <tt>wc -l</tt>)
--   
--   This uses the convention that each element of the stream represents
--   one line
countLines :: Integral n => Fold Line n

-- | Split a line into chunks delimited by the given <a>Pattern</a>
cut :: Pattern a -> Text -> [Text]

-- | Run a command using <tt>execvp</tt>, retrieving the exit code
--   
--   The command inherits <tt>stdout</tt> and <tt>stderr</tt> for the
--   current process
proc :: MonadIO io => Text -> [Text] -> Shell Line -> io ExitCode

-- | Run a command line using the shell, retrieving the exit code
--   
--   This command is more powerful than <a>proc</a>, but highly vulnerable
--   to code injection if you template the command line with untrusted
--   input
--   
--   The command inherits <tt>stdout</tt> and <tt>stderr</tt> for the
--   current process
shell :: MonadIO io => Text -> Shell Line -> io ExitCode

-- | This function is identical to <a>proc</a> except this throws
--   <a>ProcFailed</a> for non-zero exit codes
procs :: MonadIO io => Text -> [Text] -> Shell Line -> io ()

-- | This function is identical to <a>shell</a> except this throws
--   <a>ShellFailed</a> for non-zero exit codes
shells :: MonadIO io => Text -> Shell Line -> io ()

-- | Run a command using <tt>execvp</tt>, streaming <tt>stdout</tt> as
--   lines of <a>Text</a>
--   
--   The command inherits <tt>stderr</tt> for the current process
inproc :: Text -> [Text] -> Shell Line -> Shell Line

-- | Run a command line using the shell, streaming <tt>stdout</tt> as lines
--   of <a>Text</a>
--   
--   This command is more powerful than <a>inproc</a>, but highly
--   vulnerable to code injection if you template the command line with
--   untrusted input
--   
--   The command inherits <tt>stderr</tt> for the current process
--   
--   Throws an <a>ExitCode</a> exception if the command returns a non-zero
--   exit code
inshell :: Text -> Shell Line -> Shell Line

-- | Run a command using the shell, streaming <tt>stdout</tt> and
--   <tt>stderr</tt> as lines of <a>Text</a>. Lines from <tt>stdout</tt>
--   are wrapped in <a>Right</a> and lines from <tt>stderr</tt> are wrapped
--   in <a>Left</a>.
--   
--   Throws an <a>ExitCode</a> exception if the command returns a non-zero
--   exit code
inprocWithErr :: Text -> [Text] -> Shell Line -> Shell (Either Line Line)

-- | Run a command line using the shell, streaming <tt>stdout</tt> and
--   <tt>stderr</tt> as lines of <a>Text</a>. Lines from <tt>stdout</tt>
--   are wrapped in <a>Right</a> and lines from <tt>stderr</tt> are wrapped
--   in <a>Left</a>.
--   
--   This command is more powerful than <a>inprocWithErr</a>, but highly
--   vulnerable to code injection if you template the command line with
--   untrusted input
--   
--   Throws an <a>ExitCode</a> exception if the command returns a non-zero
--   exit code
inshellWithErr :: Text -> Shell Line -> Shell (Either Line Line)

-- | Run a command using <tt>execvp</tt>, retrieving the exit code and
--   stdout as a non-lazy blob of Text
--   
--   The command inherits <tt>stderr</tt> for the current process
procStrict :: MonadIO io => Text -> [Text] -> Shell Line -> io (ExitCode, Text)

-- | Run a command line using the shell, retrieving the exit code and
--   stdout as a non-lazy blob of Text
--   
--   This command is more powerful than <a>proc</a>, but highly vulnerable
--   to code injection if you template the command line with untrusted
--   input
--   
--   The command inherits <tt>stderr</tt> for the current process
shellStrict :: MonadIO io => Text -> Shell Line -> io (ExitCode, Text)

-- | Run a command using <tt>execvp</tt>, retrieving the exit code, stdout,
--   and stderr as a non-lazy blob of Text
procStrictWithErr :: MonadIO io => Text -> [Text] -> Shell Line -> io (ExitCode, Text, Text)

-- | Run a command line using the shell, retrieving the exit code, stdout,
--   and stderr as a non-lazy blob of Text
--   
--   This command is more powerful than <a>proc</a>, but highly vulnerable
--   to code injection if you template the command line with untrusted
--   input
shellStrictWithErr :: MonadIO io => Text -> Shell Line -> io (ExitCode, Text, Text)

-- | <a>system</a> generalizes <a>shell</a> and <a>proc</a> by allowing you
--   to supply your own custom <tt>CreateProcess</tt>. This is for advanced
--   users who feel comfortable using the lower-level <tt>process</tt> API
system :: MonadIO io => CreateProcess -> Shell Line -> io ExitCode

-- | <a>stream</a> generalizes <a>inproc</a> and <a>inshell</a> by allowing
--   you to supply your own custom <tt>CreateProcess</tt>. This is for
--   advanced users who feel comfortable using the lower-level
--   <tt>process</tt> API
--   
--   Throws an <a>ExitCode</a> exception if the command returns a non-zero
--   exit code
stream :: CreateProcess -> Shell Line -> Shell Line

-- | <a>streamWithErr</a> generalizes <a>inprocWithErr</a> and
--   <a>inshellWithErr</a> by allowing you to supply your own custom
--   <tt>CreateProcess</tt>. This is for advanced users who feel
--   comfortable using the lower-level <tt>process</tt> API
--   
--   Throws an <a>ExitCode</a> exception if the command returns a non-zero
--   exit code
streamWithErr :: CreateProcess -> Shell Line -> Shell (Either Line Line)

-- | <a>systemStrict</a> generalizes <a>shellStrict</a> and
--   <a>procStrict</a> by allowing you to supply your own custom
--   <tt>CreateProcess</tt>. This is for advanced users who feel
--   comfortable using the lower-level <tt>process</tt> API
systemStrict :: MonadIO io => CreateProcess -> Shell Line -> io (ExitCode, Text)

-- | <a>systemStrictWithErr</a> generalizes <a>shellStrictWithErr</a> and
--   <a>procStrictWithErr</a> by allowing you to supply your own custom
--   <tt>CreateProcess</tt>. This is for advanced users who feel
--   comfortable using the lower-level <tt>process</tt> API
systemStrictWithErr :: MonadIO io => CreateProcess -> Shell Line -> io (ExitCode, Text, Text)

-- | This type is the same as
--   <tt><a>System.Directory</a>.<a>Permissions</a></tt> type except
--   combining the <a>executable</a> and <a>searchable</a> fields into a
--   single <a>executable</a> field for consistency with the Unix
--   <tt>chmod</tt>. This simplification is still entirely consistent with
--   the behavior of <a>System.Directory</a>, which treats the two fields
--   as interchangeable.
data Permissions
Permissions :: Bool -> Bool -> Bool -> Permissions
[_readable] :: Permissions -> Bool
[_writable] :: Permissions -> Bool
[_executable] :: Permissions -> Bool

-- | Update a file or directory's user permissions
--   
--   <pre>
--   chmod rwo         "foo.txt"  -- chmod u=rw foo.txt
--   chmod executable  "foo.txt"  -- chmod u+x foo.txt
--   chmod nonwritable "foo.txt"  -- chmod u-w foo.txt
--   </pre>
--   
--   The meaning of each permission is:
--   
--   <ul>
--   <li><a>readable</a> (<tt>+r</tt> for short): For files, determines
--   whether you can read from that file (such as with <a>input</a>). For
--   directories, determines whether or not you can list the directory
--   contents (such as with <a>ls</a>). Note: if a directory is not
--   readable then <a>ls</a> will stream an empty list of contents</li>
--   <li><a>writable</a> (<tt>+w</tt> for short): For files, determines
--   whether you can write to that file (such as with <a>output</a>). For
--   directories, determines whether you can create a new file underneath
--   that directory.</li>
--   <li><a>executable</a> (<tt>+x</tt> for short): For files, determines
--   whether or not that file is executable (such as with <a>proc</a>). For
--   directories, determines whether or not you can read or execute files
--   underneath that directory (such as with <a>input</a> or
--   <a>proc</a>)</li>
--   </ul>
chmod :: MonadIO io => (Permissions -> Permissions) -> FilePath -> io Permissions

-- | Get a file or directory's user permissions
getmod :: MonadIO io => FilePath -> io Permissions

-- | Set a file or directory's user permissions
setmod :: MonadIO io => Permissions -> FilePath -> io ()

-- | Copy a file or directory's permissions (analogous to <tt>chmod
--   --reference</tt>)
copymod :: MonadIO io => FilePath -> FilePath -> io ()

-- | <pre>
--   +r
--   </pre>
readable :: Permissions -> Permissions

-- | <pre>
--   -r
--   </pre>
nonreadable :: Permissions -> Permissions

-- | <pre>
--   +w
--   </pre>
writable :: Permissions -> Permissions

-- | <pre>
--   -w
--   </pre>
nonwritable :: Permissions -> Permissions

-- | <pre>
--   +x
--   </pre>
executable :: Permissions -> Permissions

-- | <pre>
--   -x
--   </pre>
nonexecutable :: Permissions -> Permissions

-- | <pre>
--   -r -w -x
--   </pre>
ooo :: Permissions -> Permissions

-- | <pre>
--   +r -w -x
--   </pre>
roo :: Permissions -> Permissions

-- | <pre>
--   -r +w -x
--   </pre>
owo :: Permissions -> Permissions

-- | <pre>
--   -r -w +x
--   </pre>
oox :: Permissions -> Permissions

-- | <pre>
--   +r +w -x
--   </pre>
rwo :: Permissions -> Permissions

-- | <pre>
--   +r -w +x
--   </pre>
rox :: Permissions -> Permissions

-- | <pre>
--   -r +w +x
--   </pre>
owx :: Permissions -> Permissions

-- | <pre>
--   +r +w +x
--   </pre>
rwx :: Permissions -> Permissions

-- | Get the size of a file or a directory
du :: MonadIO io => FilePath -> io Size

-- | An abstract file size
--   
--   Specify the units you want by using an accessor like <a>kilobytes</a>
--   
--   The <a>Num</a> instance for <a>Size</a> interprets numeric literals as
--   bytes
data Size

-- | Construct a <a>Size</a> from an integer in bytes
--   
--   <pre>
--   &gt;&gt;&gt; format sz (B 42)
--   "42 B"
--   </pre>
pattern B :: Integral n => n -> Size

-- | Construct a <a>Size</a> from an integer in kilobytes
--   
--   <pre>
--   &gt;&gt;&gt; format sz (KB 42)
--   "42.0 KB"
--   
--   &gt;&gt;&gt; let B n = KB 1 in n
--   1000
--   </pre>
pattern KB :: Integral n => n -> Size

-- | Construct a <a>Size</a> from an integer in megabytes
--   
--   <pre>
--   &gt;&gt;&gt; format sz (MB 42)
--   "42.0 MB"
--   
--   &gt;&gt;&gt; let KB n = MB 1 in n
--   1000
--   </pre>
pattern MB :: Integral n => n -> Size

-- | Construct a <a>Size</a> from an integer in gigabytes
--   
--   <pre>
--   &gt;&gt;&gt; format sz (GB 42)
--   "42.0 GB"
--   
--   &gt;&gt;&gt; let MB n = GB 1 in n
--   1000
--   </pre>
pattern GB :: Integral n => n -> Size

-- | Construct a <a>Size</a> from an integer in terabytes
--   
--   <pre>
--   &gt;&gt;&gt; format sz (TB 42)
--   "42.0 TB"
--   
--   &gt;&gt;&gt; let GB n = TB 1 in n
--   1000
--   </pre>
pattern TB :: Integral n => n -> Size

-- | Construct a <a>Size</a> from an integer in kibibytes
--   
--   <pre>
--   &gt;&gt;&gt; format sz (KiB 42)
--   "43.8 KB"
--   
--   &gt;&gt;&gt; let B n = KiB 1 in n
--   1024
--   </pre>
pattern KiB :: Integral n => n -> Size

-- | Construct a <a>Size</a> from an integer in mebibytes
--   
--   <pre>
--   &gt;&gt;&gt; format sz (MiB 42)
--   "44.40 MB"
--   
--   &gt;&gt;&gt; let KiB n = MiB 1 in n
--   1024
--   </pre>
pattern MiB :: Integral n => n -> Size

-- | Construct a <a>Size</a> from an integer in gibibytes
--   
--   <pre>
--   &gt;&gt;&gt; format sz (GiB 42)
--   "45.97 GB"
--   
--   &gt;&gt;&gt; let MiB n = GiB 1 in n
--   1024
--   </pre>
pattern GiB :: Integral n => n -> Size

-- | Construct a <a>Size</a> from an integer in tebibytes
--   
--   <pre>
--   &gt;&gt;&gt; format sz (TiB 42)
--   "46.179 TB"
--   
--   &gt;&gt;&gt; let GiB n = TiB 1 in n
--   1024
--   </pre>
pattern TiB :: Integral n => n -> Size

-- | <a>Format</a> a <a>Size</a> using a human readable representation
--   
--   <pre>
--   &gt;&gt;&gt; format sz 42
--   "42 B"
--   
--   &gt;&gt;&gt; format sz 2309
--   "2.309 KB"
--   
--   &gt;&gt;&gt; format sz 949203
--   "949.203 KB"
--   
--   &gt;&gt;&gt; format sz 1600000000
--   "1.600 GB"
--   
--   &gt;&gt;&gt; format sz 999999999999999999
--   "999999.999 TB"
--   </pre>
sz :: Format r (Size -> r)

-- | Extract a size in bytes
bytes :: Integral n => Size -> n

-- | <pre>
--   1 kilobyte = 1000 bytes
--   </pre>
kilobytes :: Integral n => Size -> n

-- | <pre>
--   1 megabyte = 1000 kilobytes
--   </pre>
megabytes :: Integral n => Size -> n

-- | <pre>
--   1 gigabyte = 1000 megabytes
--   </pre>
gigabytes :: Integral n => Size -> n

-- | <pre>
--   1 terabyte = 1000 gigabytes
--   </pre>
terabytes :: Integral n => Size -> n

-- | <pre>
--   1 kibibyte = 1024 bytes
--   </pre>
kibibytes :: Integral n => Size -> n

-- | <pre>
--   1 mebibyte = 1024 kibibytes
--   </pre>
mebibytes :: Integral n => Size -> n

-- | <pre>
--   1 gibibyte = 1024 mebibytes
--   </pre>
gibibytes :: Integral n => Size -> n

-- | <pre>
--   1 tebibyte = 1024 gibibytes
--   </pre>
tebibytes :: Integral n => Size -> n

-- | POSIX defines operations to get information, such as owner,
--   permissions, size and access times, about a file. This information is
--   represented by the <a>FileStatus</a> type.
--   
--   Note: see <tt>chmod</tt>.
data FileStatus

-- | Get the status of a file
stat :: MonadIO io => FilePath -> io FileStatus

-- | Get the status of a file, but don't follow symbolic links
lstat :: MonadIO io => FilePath -> io FileStatus

-- | Size of the file in bytes. Does not follow symlinks
fileSize :: FileStatus -> Size

-- | Time of last access
accessTime :: FileStatus -> POSIXTime

-- | Time of last modification
modificationTime :: FileStatus -> POSIXTime

-- | Time of last status change (i.e. owner, group, link count, mode, etc.)
statusChangeTime :: FileStatus -> POSIXTime

-- | Checks if this file is a block device.
isBlockDevice :: FileStatus -> Bool

-- | Checks if this file is a character device.
isCharacterDevice :: FileStatus -> Bool

-- | Checks if this file is a named pipe device.
isNamedPipe :: FileStatus -> Bool

-- | Checks if this file is a regular file device.
isRegularFile :: FileStatus -> Bool

-- | Checks if this file is a directory device.
isDirectory :: FileStatus -> Bool

-- | Checks if this file is a symbolic link device.
isSymbolicLink :: FileStatus -> Bool

-- | Checks if this file is a socket device.
isSocket :: FileStatus -> Bool

-- | Check if a file was last modified after a given timestamp
cmin :: MonadIO io => UTCTime -> FilePath -> io Bool

-- | Check if a file was last modified before a given timestamp
cmax :: MonadIO io => UTCTime -> FilePath -> io Bool
data WithHeader a

-- | The first line with the header
Header :: a -> WithHeader a

-- | Every other line: 1st element is header, 2nd element is original row
Row :: a -> a -> WithHeader a
header :: Shell a -> Shell (WithHeader a)
data ProcFailed
ProcFailed :: Text -> [Text] -> ExitCode -> ProcFailed
[procCommand] :: ProcFailed -> Text
[procArguments] :: ProcFailed -> [Text]
[procExitCode] :: ProcFailed -> ExitCode
data ShellFailed
ShellFailed :: Text -> ExitCode -> ShellFailed
[shellCommandLine] :: ShellFailed -> Text
[shellExitCode] :: ShellFailed -> ExitCode
instance GHC.Show.Show Turtle.Prelude.ProcFailed
instance GHC.Show.Show Turtle.Prelude.ShellFailed
instance GHC.Show.Show Turtle.Prelude.Permissions
instance GHC.Classes.Ord Turtle.Prelude.Permissions
instance GHC.Read.Read Turtle.Prelude.Permissions
instance GHC.Classes.Eq Turtle.Prelude.Permissions
instance GHC.Num.Num Turtle.Prelude.Size
instance GHC.Classes.Ord Turtle.Prelude.Size
instance GHC.Classes.Eq Turtle.Prelude.Size
instance GHC.Show.Show a => GHC.Show.Show (Turtle.Prelude.WithHeader a)
instance GHC.Show.Show Turtle.Prelude.Size
instance GHC.Exception.Type.Exception Turtle.Prelude.ShellFailed
instance GHC.Exception.Type.Exception Turtle.Prelude.ProcFailed


-- | This module provides <a>ByteString</a> analogs of several utilities in
--   <a>Turtle.Prelude</a>. The main difference is that the chunks of bytes
--   read by these utilities are not necessarily aligned to line
--   boundaries.
module Turtle.Bytes

-- | Read chunks of bytes from standard input
--   
--   The chunks are not necessarily aligned to line boundaries
stdin :: Shell ByteString

-- | Read chunks of bytes from a file
--   
--   The chunks are not necessarily aligned to line boundaries
input :: FilePath -> Shell ByteString

-- | Read chunks of bytes from a <a>Handle</a>
--   
--   The chunks are not necessarily aligned to line boundaries
inhandle :: Handle -> Shell ByteString

-- | Stream chunks of bytes to standard output
--   
--   The chunks are not necessarily aligned to line boundaries
stdout :: MonadIO io => Shell ByteString -> io ()

-- | Stream chunks of bytes to a file
--   
--   The chunks do not need to be aligned to line boundaries
output :: MonadIO io => FilePath -> Shell ByteString -> io ()

-- | Stream chunks of bytes to a <a>Handle</a>
--   
--   The chunks do not need to be aligned to line boundaries
outhandle :: MonadIO io => Handle -> Shell ByteString -> io ()

-- | Append chunks of bytes to append to a file
--   
--   The chunks do not need to be aligned to line boundaries
append :: MonadIO io => FilePath -> Shell ByteString -> io ()

-- | Stream chunks of bytes to standard error
--   
--   The chunks do not need to be aligned to line boundaries
stderr :: MonadIO io => Shell ByteString -> io ()

-- | Read in a stream's contents strictly
strict :: MonadIO io => Shell ByteString -> io ByteString

-- | Compress a stream using <tt>zlib</tt>
--   
--   Note that this can decompress streams that are the concatenation of
--   multiple compressed streams (just like <tt>gzip</tt>)
--   
--   <pre>
--   &gt;&gt;&gt; let compressed = select [ "ABC", "DEF" ] &amp; compress 0 defaultWindowBits
--   
--   &gt;&gt;&gt; compressed &amp; decompress defaultWindowBits &amp; view
--   "ABCDEF"
--   
--   &gt;&gt;&gt; (compressed &lt;|&gt; compressed) &amp; decompress defaultWindowBits &amp; view
--   "ABCDEF"
--   "ABCDEF"
--   </pre>
compress :: Int -> WindowBits -> Shell ByteString -> Shell ByteString

-- | Decompress a stream using <tt>zlib</tt> (just like the <tt>gzip</tt>
--   command)
decompress :: WindowBits -> Shell ByteString -> Shell ByteString

-- | This specifies the size of the compression window. Larger values of
--   this parameter result in better compression at the expense of higher
--   memory usage.
--   
--   The compression window size is the value of the the window bits raised
--   to the power 2. The window bits must be in the range <tt>9..15</tt>
--   which corresponds to compression window sizes of 512b to 32Kb. The
--   default is 15 which is also the maximum size.
--   
--   The total amount of memory used depends on the window bits and the
--   <a>MemoryLevel</a>. See the <a>MemoryLevel</a> for the details.
data WindowBits
WindowBits :: Int -> WindowBits

-- | The default <a>WindowBits</a> is 15 which is also the maximum size.
defaultWindowBits :: WindowBits

-- | Encode a stream of bytes as UTF8 <a>Text</a>
fromUTF8 :: Shell Text -> Shell ByteString

-- | Decode a stream of bytes as UTF8 <a>Text</a>
--   
--   NOTE: This function will throw a pure exception (i.e. an <a>error</a>)
--   if UTF8 decoding fails (mainly due to limitations in the <tt>text</tt>
--   package's stream decoding API)
toUTF8 :: Shell ByteString -> Shell Text

-- | Run a command using <tt>execvp</tt>, retrieving the exit code
--   
--   The command inherits <tt>stdout</tt> and <tt>stderr</tt> for the
--   current process
proc :: MonadIO io => Text -> [Text] -> Shell ByteString -> io ExitCode

-- | Run a command line using the shell, retrieving the exit code
--   
--   This command is more powerful than <a>proc</a>, but highly vulnerable
--   to code injection if you template the command line with untrusted
--   input
--   
--   The command inherits <tt>stdout</tt> and <tt>stderr</tt> for the
--   current process
shell :: MonadIO io => Text -> Shell ByteString -> io ExitCode

-- | This function is identical to <a>proc</a> except this throws
--   <a>ProcFailed</a> for non-zero exit codes
procs :: MonadIO io => Text -> [Text] -> Shell ByteString -> io ()

-- | This function is identical to <a>shell</a> except this throws
--   <a>ShellFailed</a> for non-zero exit codes
shells :: MonadIO io => Text -> Shell ByteString -> io ()

-- | Run a command using <tt>execvp</tt>, streaming <tt>stdout</tt> as
--   chunks of <a>ByteString</a>
--   
--   The command inherits <tt>stderr</tt> for the current process
inproc :: Text -> [Text] -> Shell ByteString -> Shell ByteString

-- | Run a command line using the shell, streaming <tt>stdout</tt> as
--   chunks of <a>ByteString</a>
--   
--   This command is more powerful than <a>inproc</a>, but highly
--   vulnerable to code injection if you template the command line with
--   untrusted input
--   
--   The command inherits <tt>stderr</tt> for the current process
inshell :: Text -> Shell ByteString -> Shell ByteString

-- | Run a command using the shell, streaming <tt>stdout</tt> and
--   <tt>stderr</tt> as chunks of <a>ByteString</a>. Chunks from
--   <tt>stdout</tt> are wrapped in <a>Right</a> and chunks from
--   <tt>stderr</tt> are wrapped in <a>Left</a>.
--   
--   Throws an <a>ExitCode</a> exception if the command returns a non-zero
--   exit code
inprocWithErr :: Text -> [Text] -> Shell ByteString -> Shell (Either ByteString ByteString)

-- | Run a command line using the shell, streaming <tt>stdout</tt> and
--   <tt>stderr</tt> as chunks of <a>ByteString</a>. Chunks from
--   <tt>stdout</tt> are wrapped in <a>Right</a> and chunks from
--   <tt>stderr</tt> are wrapped in <a>Left</a>.
--   
--   This command is more powerful than <a>inprocWithErr</a>, but highly
--   vulnerable to code injection if you template the command line with
--   untrusted input
--   
--   Throws an <a>ExitCode</a> exception if the command returns a non-zero
--   exit code
inshellWithErr :: Text -> Shell ByteString -> Shell (Either ByteString ByteString)

-- | Run a command using <tt>execvp</tt>, retrieving the exit code and
--   stdout as a non-lazy blob of Text
--   
--   The command inherits <tt>stderr</tt> for the current process
procStrict :: MonadIO io => Text -> [Text] -> Shell ByteString -> io (ExitCode, ByteString)

-- | Run a command line using the shell, retrieving the exit code and
--   stdout as a non-lazy blob of Text
--   
--   This command is more powerful than <a>proc</a>, but highly vulnerable
--   to code injection if you template the command line with untrusted
--   input
--   
--   The command inherits <tt>stderr</tt> for the current process
shellStrict :: MonadIO io => Text -> Shell ByteString -> io (ExitCode, ByteString)

-- | Run a command using <tt>execvp</tt>, retrieving the exit code, stdout,
--   and stderr as a non-lazy blob of Text
procStrictWithErr :: MonadIO io => Text -> [Text] -> Shell ByteString -> io (ExitCode, ByteString, ByteString)

-- | Run a command line using the shell, retrieving the exit code, stdout,
--   and stderr as a non-lazy blob of Text
--   
--   This command is more powerful than <a>proc</a>, but highly vulnerable
--   to code injection if you template the command line with untrusted
--   input
shellStrictWithErr :: MonadIO io => Text -> Shell ByteString -> io (ExitCode, ByteString, ByteString)

-- | <a>system</a> generalizes <a>shell</a> and <a>proc</a> by allowing you
--   to supply your own custom <tt>CreateProcess</tt>. This is for advanced
--   users who feel comfortable using the lower-level <tt>process</tt> API
system :: MonadIO io => CreateProcess -> Shell ByteString -> io ExitCode

-- | <a>stream</a> generalizes <a>inproc</a> and <a>inshell</a> by allowing
--   you to supply your own custom <tt>CreateProcess</tt>. This is for
--   advanced users who feel comfortable using the lower-level
--   <tt>process</tt> API
--   
--   Throws an <a>ExitCode</a> exception if the command returns a non-zero
--   exit code
stream :: CreateProcess -> Shell ByteString -> Shell ByteString

-- | <a>streamWithErr</a> generalizes <a>inprocWithErr</a> and
--   <a>inshellWithErr</a> by allowing you to supply your own custom
--   <tt>CreateProcess</tt>. This is for advanced users who feel
--   comfortable using the lower-level <tt>process</tt> API
--   
--   Throws an <a>ExitCode</a> exception if the command returns a non-zero
--   exit code
streamWithErr :: CreateProcess -> Shell ByteString -> Shell (Either ByteString ByteString)

-- | <a>systemStrict</a> generalizes <a>shellStrict</a> and
--   <a>procStrict</a> by allowing you to supply your own custom
--   <tt>CreateProcess</tt>. This is for advanced users who feel
--   comfortable using the lower-level <tt>process</tt> API
systemStrict :: MonadIO io => CreateProcess -> Shell ByteString -> io (ExitCode, ByteString)

-- | <a>systemStrictWithErr</a> generalizes <a>shellStrictWithErr</a> and
--   <a>procStrictWithErr</a> by allowing you to supply your own custom
--   <tt>CreateProcess</tt>. This is for advanced users who feel
--   comfortable using the lower-level <tt>process</tt> API
systemStrictWithErr :: MonadIO io => CreateProcess -> Shell ByteString -> io (ExitCode, ByteString, ByteString)


-- | See <a>Turtle.Tutorial</a> to learn how to use this library or
--   <a>Turtle.Prelude</a> for a quick-start guide.
--   
--   Here is the recommended way to import this library:
--   
--   <pre>
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   import Turtle
--   import Prelude hiding (FilePath)
--   </pre>
--   
--   This module re-exports the rest of the library and also re-exports
--   useful modules from <tt>base</tt>:
--   
--   <a>Turtle.Format</a> provides type-safe string formatting
--   
--   <a>Turtle.Pattern</a> provides <a>Pattern</a>s, which are like more
--   powerful regular expressions
--   
--   <a>Turtle.Shell</a> provides a <a>Shell</a> abstraction for building
--   streaming, exception-safe pipelines
--   
--   <a>Turtle.Prelude</a> provides a library of Unix-like utilities to get
--   you started with basic shell-like programming within Haskell
--   
--   <a>Control.Applicative</a> provides two classes:
--   
--   <ul>
--   <li><a>Applicative</a>, which works with <a>Fold</a>, <a>Pattern</a>,
--   <a>Managed</a>, and <a>Shell</a></li>
--   <li><a>Alternative</a>, which works with <a>Pattern</a> and
--   <a>Shell</a></li>
--   </ul>
--   
--   <a>Control.Monad</a> provides two classes:
--   
--   <ul>
--   <li><a>Monad</a>, which works with <a>Pattern</a>, <a>Managed</a> and
--   <a>Shell</a></li>
--   <li><a>MonadPlus</a>, which works with <a>Pattern</a> and
--   <a>Shell</a></li>
--   </ul>
--   
--   <a>Control.Monad.IO.Class</a> provides one class:
--   
--   <ul>
--   <li><a>MonadIO</a>, which works with <a>Managed</a> and
--   <a>Shell</a></li>
--   </ul>
--   
--   <a>Data.Monoid</a> provides one class:
--   
--   <ul>
--   <li><a>Monoid</a>, which works with <a>Fold</a>, <a>Pattern</a>,
--   <a>Managed</a>, and <a>Shell</a></li>
--   </ul>
--   
--   <a>Control.Monad.Managed.Safe</a> provides <a>Managed</a> resources
--   
--   <a>Filesystem.Path.CurrentOS</a> provides <a>FilePath</a>-manipulation
--   utilities
--   
--   Additionally, you might also want to import the following modules
--   qualified:
--   
--   <ul>
--   <li><a>Options.Applicative</a> from <tt>optparse-applicative</tt> for
--   command-line option parsing</li>
--   <li><a>Control.Foldl</a> (for predefined folds)</li>
--   <li><a>Control.Foldl.Text</a> (for <a>Text</a>-specific folds)</li>
--   <li><a>Data.Text</a> (for <a>Text</a>-manipulation utilities)</li>
--   <li><a>Data.Text.IO</a> (for reading and writing <a>Text</a>)</li>
--   <li><a>Filesystem.Path.CurrentOS</a> (for the remaining
--   <a>FilePath</a> utilities)</li>
--   </ul>
module Turtle

-- | A functor with application, providing operations to
--   
--   <ul>
--   <li>embed pure expressions (<a>pure</a>), and</li>
--   <li>sequence computations and combine their results (<a>&lt;*&gt;</a>
--   and <a>liftA2</a>).</li>
--   </ul>
--   
--   A minimal complete definition must include implementations of
--   <a>pure</a> and of either <a>&lt;*&gt;</a> or <a>liftA2</a>. If it
--   defines both, then they must behave the same as their default
--   definitions:
--   
--   <pre>
--   (<a>&lt;*&gt;</a>) = <a>liftA2</a> <a>id</a>
--   </pre>
--   
--   <pre>
--   <a>liftA2</a> f x y = f <a>&lt;$&gt;</a> x <a>&lt;*&gt;</a> y
--   </pre>
--   
--   Further, any definition must satisfy the following:
--   
--   <ul>
--   <li><i>Identity</i> <pre><a>pure</a> <a>id</a> <a>&lt;*&gt;</a> v =
--   v</pre></li>
--   <li><i>Composition</i> <pre><a>pure</a> (.) <a>&lt;*&gt;</a> u
--   <a>&lt;*&gt;</a> v <a>&lt;*&gt;</a> w = u <a>&lt;*&gt;</a> (v
--   <a>&lt;*&gt;</a> w)</pre></li>
--   <li><i>Homomorphism</i> <pre><a>pure</a> f <a>&lt;*&gt;</a>
--   <a>pure</a> x = <a>pure</a> (f x)</pre></li>
--   <li><i>Interchange</i> <pre>u <a>&lt;*&gt;</a> <a>pure</a> y =
--   <a>pure</a> (<a>$</a> y) <a>&lt;*&gt;</a> u</pre></li>
--   </ul>
--   
--   The other methods have the following default definitions, which may be
--   overridden with equivalent specialized implementations:
--   
--   <ul>
--   <li><pre>u <a>*&gt;</a> v = (<a>id</a> <a>&lt;$</a> u)
--   <a>&lt;*&gt;</a> v</pre></li>
--   <li><pre>u <a>&lt;*</a> v = <a>liftA2</a> <a>const</a> u v</pre></li>
--   </ul>
--   
--   As a consequence of these laws, the <a>Functor</a> instance for
--   <tt>f</tt> will satisfy
--   
--   <ul>
--   <li><pre><a>fmap</a> f x = <a>pure</a> f <a>&lt;*&gt;</a> x</pre></li>
--   </ul>
--   
--   It may be useful to note that supposing
--   
--   <pre>
--   forall x y. p (q x y) = f x . g y
--   </pre>
--   
--   it follows from the above that
--   
--   <pre>
--   <a>liftA2</a> p (<a>liftA2</a> q u v) = <a>liftA2</a> f u . <a>liftA2</a> g v
--   </pre>
--   
--   If <tt>f</tt> is also a <a>Monad</a>, it should satisfy
--   
--   <ul>
--   <li><pre><a>pure</a> = <a>return</a></pre></li>
--   <li><pre>m1 <a>&lt;*&gt;</a> m2 = m1 <a>&gt;&gt;=</a> (x1 -&gt; m2
--   <a>&gt;&gt;=</a> (x2 -&gt; <a>return</a> (x1 x2)))</pre></li>
--   <li><pre>(<a>*&gt;</a>) = (<a>&gt;&gt;</a>)</pre></li>
--   </ul>
--   
--   (which implies that <a>pure</a> and <a>&lt;*&gt;</a> satisfy the
--   applicative functor laws).
class Functor f => Applicative (f :: Type -> Type)

-- | Lift a value.
pure :: Applicative f => a -> f a

-- | Sequential application.
--   
--   A few functors support an implementation of <a>&lt;*&gt;</a> that is
--   more efficient than the default one.
--   
--   Using <tt>ApplicativeDo</tt>: '<tt>fs <a>&lt;*&gt;</a> as</tt>' can be
--   understood as the <tt>do</tt> expression
--   
--   <pre>
--   do f &lt;- fs
--      a &lt;- as
--      pure (f a)
--   </pre>
(<*>) :: Applicative f => f (a -> b) -> f a -> f b

-- | Lift a binary function to actions.
--   
--   Some functors support an implementation of <a>liftA2</a> that is more
--   efficient than the default one. In particular, if <a>fmap</a> is an
--   expensive operation, it is likely better to use <a>liftA2</a> than to
--   <a>fmap</a> over the structure and then use <a>&lt;*&gt;</a>.
--   
--   This became a typeclass method in 4.10.0.0. Prior to that, it was a
--   function defined in terms of <a>&lt;*&gt;</a> and <a>fmap</a>.
--   
--   Using <tt>ApplicativeDo</tt>: '<tt><a>liftA2</a> f as bs</tt>' can be
--   understood as the <tt>do</tt> expression
--   
--   <pre>
--   do a &lt;- as
--      b &lt;- bs
--      pure (f a b)
--   </pre>
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c

-- | Sequence actions, discarding the value of the first argument.
--   
--   '<tt>as <a>*&gt;</a> bs</tt>' can be understood as the <tt>do</tt>
--   expression
--   
--   <pre>
--   do as
--      bs
--   </pre>
--   
--   This is a tad complicated for our <tt>ApplicativeDo</tt> extension
--   which will give it a <tt>Monad</tt> constraint. For an
--   <tt>Applicative</tt> constraint we write it of the form
--   
--   <pre>
--   do _ &lt;- as
--      b &lt;- bs
--      pure b
--   </pre>
(*>) :: Applicative f => f a -> f b -> f b

-- | Sequence actions, discarding the value of the second argument.
--   
--   Using <tt>ApplicativeDo</tt>: '<tt>as <a>&lt;*</a> bs</tt>' can be
--   understood as the <tt>do</tt> expression
--   
--   <pre>
--   do a &lt;- as
--      bs
--      pure a
--   </pre>
(<*) :: Applicative f => f a -> f b -> f a
infixl 4 <*
infixl 4 *>
infixl 4 <*>

-- | One or none.
optional :: Alternative f => f a -> f (Maybe a)

-- | An infix synonym for <a>fmap</a>.
--   
--   The name of this operator is an allusion to <a>$</a>. Note the
--   similarities between their types:
--   
--   <pre>
--    ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
--   (&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
--   </pre>
--   
--   Whereas <a>$</a> is function application, <a>&lt;$&gt;</a> is function
--   application lifted over a <a>Functor</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Convert from a <tt><a>Maybe</a> <a>Int</a></tt> to a <tt><a>Maybe</a>
--   <a>String</a></tt> using <a>show</a>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Nothing
--   Nothing
--   
--   &gt;&gt;&gt; show &lt;$&gt; Just 3
--   Just "3"
--   </pre>
--   
--   Convert from an <tt><a>Either</a> <a>Int</a> <a>Int</a></tt> to an
--   <tt><a>Either</a> <a>Int</a></tt> <a>String</a> using <a>show</a>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Left 17
--   Left 17
--   
--   &gt;&gt;&gt; show &lt;$&gt; Right 17
--   Right "17"
--   </pre>
--   
--   Double each element of a list:
--   
--   <pre>
--   &gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
--   [2,4,6]
--   </pre>
--   
--   Apply <a>even</a> to the second element of a pair:
--   
--   <pre>
--   &gt;&gt;&gt; even &lt;$&gt; (2,2)
--   (2,True)
--   </pre>
(<$>) :: Functor f => (a -> b) -> f a -> f b
infixl 4 <$>

-- | A monoid on applicative functors.
--   
--   If defined, <a>some</a> and <a>many</a> should be the least solutions
--   of the equations:
--   
--   <ul>
--   <li><pre><a>some</a> v = (:) <a>&lt;$&gt;</a> v <a>&lt;*&gt;</a>
--   <a>many</a> v</pre></li>
--   <li><pre><a>many</a> v = <a>some</a> v <a>&lt;|&gt;</a> <a>pure</a>
--   []</pre></li>
--   </ul>
class Applicative f => Alternative (f :: Type -> Type)

-- | The identity of <a>&lt;|&gt;</a>
empty :: Alternative f => f a

-- | An associative binary operation
(<|>) :: Alternative f => f a -> f a -> f a

-- | One or more.
some :: Alternative f => f a -> f [a]

-- | Zero or more.
many :: Alternative f => f a -> f [a]
infixl 3 <|>

-- | Conditional failure of <a>Alternative</a> computations. Defined by
--   
--   <pre>
--   guard True  = <a>pure</a> ()
--   guard False = <a>empty</a>
--   </pre>
--   
--   <h4><b>Examples</b></h4>
--   
--   Common uses of <a>guard</a> include conditionally signaling an error
--   in an error monad and conditionally rejecting the current choice in an
--   <a>Alternative</a>-based parser.
--   
--   As an example of signaling an error in the error monad <a>Maybe</a>,
--   consider a safe division function <tt>safeDiv x y</tt> that returns
--   <a>Nothing</a> when the denominator <tt>y</tt> is zero and
--   <tt><a>Just</a> (x `div` y)</tt> otherwise. For example:
--   
--   <pre>
--   &gt;&gt;&gt; safeDiv 4 0
--   Nothing
--   &gt;&gt;&gt; safeDiv 4 2
--   Just 2
--   </pre>
--   
--   A definition of <tt>safeDiv</tt> using guards, but not <a>guard</a>:
--   
--   <pre>
--   safeDiv :: Int -&gt; Int -&gt; Maybe Int
--   safeDiv x y | y /= 0    = Just (x `div` y)
--               | otherwise = Nothing
--   </pre>
--   
--   A definition of <tt>safeDiv</tt> using <a>guard</a> and <a>Monad</a>
--   <tt>do</tt>-notation:
--   
--   <pre>
--   safeDiv :: Int -&gt; Int -&gt; Maybe Int
--   safeDiv x y = do
--     guard (y /= 0)
--     return (x `div` y)
--   </pre>
guard :: Alternative f => Bool -> f ()

-- | The <a>join</a> function is the conventional monad join operator. It
--   is used to remove one level of monadic structure, projecting its bound
--   argument into the outer level.
--   
--   '<tt><a>join</a> bss</tt>' can be understood as the <tt>do</tt>
--   expression
--   
--   <pre>
--   do bs &lt;- bss
--      bs
--   </pre>
--   
--   <h4><b>Examples</b></h4>
--   
--   A common use of <a>join</a> is to run an <a>IO</a> computation
--   returned from an <a>STM</a> transaction, since <a>STM</a> transactions
--   can't perform <a>IO</a> directly. Recall that
--   
--   <pre>
--   <a>atomically</a> :: STM a -&gt; IO a
--   </pre>
--   
--   is used to run <a>STM</a> transactions atomically. So, by specializing
--   the types of <a>atomically</a> and <a>join</a> to
--   
--   <pre>
--   <a>atomically</a> :: STM (IO b) -&gt; IO (IO b)
--   <a>join</a>       :: IO (IO b)  -&gt; IO b
--   </pre>
--   
--   we can compose them as
--   
--   <pre>
--   <a>join</a> . <a>atomically</a> :: STM (IO b) -&gt; IO b
--   </pre>
--   
--   to run an <a>STM</a> transaction and the <a>IO</a> action it returns.
join :: Monad m => m (m a) -> m a

-- | Direct <a>MonadPlus</a> equivalent of <a>filter</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   The <a>filter</a> function is just <a>mfilter</a> specialized to the
--   list monad:
--   
--   <pre>
--   <a>filter</a> = ( <a>mfilter</a> :: (a -&gt; Bool) -&gt; [a] -&gt; [a] )
--   </pre>
--   
--   An example using <a>mfilter</a> with the <a>Maybe</a> monad:
--   
--   <pre>
--   &gt;&gt;&gt; mfilter odd (Just 1)
--   Just 1
--   &gt;&gt;&gt; mfilter odd (Just 2)
--   Nothing
--   </pre>
mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a

-- | The reverse of <a>when</a>.
unless :: Applicative f => Bool -> f () -> f ()

-- | Like <a>replicateM</a>, but discards the result.
replicateM_ :: Applicative m => Int -> m a -> m ()

-- | Repeat an action indefinitely.
--   
--   Using <tt>ApplicativeDo</tt>: '<tt><a>forever</a> as</tt>' can be
--   understood as the pseudo-<tt>do</tt> expression
--   
--   <pre>
--   do as
--      as
--      ..
--   </pre>
--   
--   with <tt>as</tt> repeating.
--   
--   <h4><b>Examples</b></h4>
--   
--   A common use of <a>forever</a> is to process input from network
--   sockets, <a>Handle</a>s, and channels (e.g. <a>MVar</a> and
--   <a>Chan</a>).
--   
--   For example, here is how we might implement an <a>echo server</a>,
--   using <a>forever</a> both to listen for client connections on a
--   network socket and to echo client input on client connection handles:
--   
--   <pre>
--   echoServer :: Socket -&gt; IO ()
--   echoServer socket = <a>forever</a> $ do
--     client &lt;- accept socket
--     <a>forkFinally</a> (echo client) (\_ -&gt; hClose client)
--     where
--       echo :: Handle -&gt; IO ()
--       echo client = <a>forever</a> $
--         hGetLine client &gt;&gt;= hPutStrLn client
--   </pre>
forever :: Applicative f => f a -> f b

-- | Right-to-left composition of Kleisli arrows.
--   <tt>(<a>&gt;=&gt;</a>)</tt>, with the arguments flipped.
--   
--   Note how this operator resembles function composition
--   <tt>(<a>.</a>)</tt>:
--   
--   <pre>
--   (.)   ::            (b -&gt;   c) -&gt; (a -&gt;   b) -&gt; a -&gt;   c
--   (&lt;=&lt;) :: Monad m =&gt; (b -&gt; m c) -&gt; (a -&gt; m b) -&gt; a -&gt; m c
--   </pre>
(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
infixr 1 <=<

-- | Left-to-right composition of Kleisli arrows.
--   
--   '<tt>(bs <a>&gt;=&gt;</a> cs) a</tt>' can be understood as the
--   <tt>do</tt> expression
--   
--   <pre>
--   do b &lt;- bs a
--      cs b
--   </pre>
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
infixr 1 >=>

-- | The sum of a collection of actions, generalizing <a>concat</a>. As of
--   base 4.8.0.0, <a>msum</a> is just <a>asum</a>, specialized to
--   <a>MonadPlus</a>.
msum :: (Foldable t, MonadPlus m) => t (m a) -> m a

-- | <tt><a>void</a> value</tt> discards or ignores the result of
--   evaluation, such as the return value of an <a>IO</a> action.
--   
--   Using <tt>ApplicativeDo</tt>: '<tt><a>void</a> as</tt>' can be
--   understood as the <tt>do</tt> expression
--   
--   <pre>
--   do as
--      pure ()
--   </pre>
--   
--   with an inferred <tt>Functor</tt> constraint.
--   
--   <h4><b>Examples</b></h4>
--   
--   Replace the contents of a <tt><a>Maybe</a> <a>Int</a></tt> with unit:
--   
--   <pre>
--   &gt;&gt;&gt; void Nothing
--   Nothing
--   
--   &gt;&gt;&gt; void (Just 3)
--   Just ()
--   </pre>
--   
--   Replace the contents of an <tt><a>Either</a> <a>Int</a>
--   <a>Int</a></tt> with unit, resulting in an <tt><a>Either</a>
--   <a>Int</a> <tt>()</tt></tt>:
--   
--   <pre>
--   &gt;&gt;&gt; void (Left 8675309)
--   Left 8675309
--   
--   &gt;&gt;&gt; void (Right 8675309)
--   Right ()
--   </pre>
--   
--   Replace every element of a list with unit:
--   
--   <pre>
--   &gt;&gt;&gt; void [1,2,3]
--   [(),(),()]
--   </pre>
--   
--   Replace the second element of a pair with unit:
--   
--   <pre>
--   &gt;&gt;&gt; void (1,2)
--   (1,())
--   </pre>
--   
--   Discard the result of an <a>IO</a> action:
--   
--   <pre>
--   &gt;&gt;&gt; mapM print [1,2]
--   1
--   2
--   [(),()]
--   
--   &gt;&gt;&gt; void $ mapM print [1,2]
--   1
--   2
--   </pre>
void :: Functor f => f a -> f ()

-- | Conditional execution of <a>Applicative</a> expressions. For example,
--   
--   <pre>
--   when debug (putStrLn "Debugging")
--   </pre>
--   
--   will output the string <tt>Debugging</tt> if the Boolean value
--   <tt>debug</tt> is <a>True</a>, and otherwise do nothing.
when :: Applicative f => Bool -> f () -> f ()

-- | Monads that also support choice and failure.
class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type)

-- | The identity of <a>mplus</a>. It should also satisfy the equations
--   
--   <pre>
--   mzero &gt;&gt;= f  =  mzero
--   v &gt;&gt; mzero   =  mzero
--   </pre>
--   
--   The default definition is
--   
--   <pre>
--   mzero = <a>empty</a>
--   </pre>
mzero :: MonadPlus m => m a

-- | An associative operation. The default definition is
--   
--   <pre>
--   mplus = (<a>&lt;|&gt;</a>)
--   </pre>
mplus :: MonadPlus m => m a -> m a -> m a

-- | Monads in which <a>IO</a> computations may be embedded. Any monad
--   built by applying a sequence of monad transformers to the <a>IO</a>
--   monad will be an instance of this class.
--   
--   Instances should satisfy the following laws, which state that
--   <a>liftIO</a> is a transformer of monads:
--   
--   <ul>
--   <li><pre><a>liftIO</a> . <a>return</a> = <a>return</a></pre></li>
--   <li><pre><a>liftIO</a> (m &gt;&gt;= f) = <a>liftIO</a> m &gt;&gt;=
--   (<a>liftIO</a> . f)</pre></li>
--   </ul>
class Monad m => MonadIO (m :: Type -> Type)

-- | Lift a computation from the <a>IO</a> monad.
liftIO :: MonadIO m => IO a -> m a

-- | An associative operation.
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3] &lt;&gt; [4,5,6]
--   [1,2,3,4,5,6]
--   </pre>
(<>) :: Semigroup a => a -> a -> a
infixr 6 <>

-- | The class of monoids (types with an associative binary operation that
--   has an identity). Instances should satisfy the following:
--   
--   <ul>
--   <li><i>Right identity</i> <tt>x <a>&lt;&gt;</a> <a>mempty</a> =
--   x</tt></li>
--   <li><i>Left identity</i> <tt><a>mempty</a> <a>&lt;&gt;</a> x =
--   x</tt></li>
--   <li><i>Associativity</i> <tt>x <a>&lt;&gt;</a> (y <a>&lt;&gt;</a> z) =
--   (x <a>&lt;&gt;</a> y) <a>&lt;&gt;</a> z</tt> (<a>Semigroup</a>
--   law)</li>
--   <li><i>Concatenation</i> <tt><a>mconcat</a> = <a>foldr</a>
--   (<a>&lt;&gt;</a>) <a>mempty</a></tt></li>
--   </ul>
--   
--   The method names refer to the monoid of lists under concatenation, but
--   there are many other instances.
--   
--   Some types can be viewed as a monoid in more than one way, e.g. both
--   addition and multiplication on numbers. In such cases we often define
--   <tt>newtype</tt>s and make those instances of <a>Monoid</a>, e.g.
--   <a>Sum</a> and <a>Product</a>.
--   
--   <b>NOTE</b>: <a>Semigroup</a> is a superclass of <a>Monoid</a> since
--   <i>base-4.11.0.0</i>.
class Semigroup a => Monoid a

-- | Identity of <a>mappend</a>
--   
--   <pre>
--   &gt;&gt;&gt; "Hello world" &lt;&gt; mempty
--   "Hello world"
--   </pre>
mempty :: Monoid a => a

-- | An associative operation
--   
--   <b>NOTE</b>: This method is redundant and has the default
--   implementation <tt><a>mappend</a> = (<a>&lt;&gt;</a>)</tt> since
--   <i>base-4.11.0.0</i>. Should it be implemented manually, since
--   <a>mappend</a> is a synonym for (<a>&lt;&gt;</a>), it is expected that
--   the two functions are defined the same way. In a future GHC release
--   <a>mappend</a> will be removed from <a>Monoid</a>.
mappend :: Monoid a => a -> a -> a

-- | Fold a list using the monoid.
--   
--   For most types, the default definition for <a>mconcat</a> will be
--   used, but the function is included in the class definition so that an
--   optimized version can be provided for specific types.
--   
--   <pre>
--   &gt;&gt;&gt; mconcat ["Hello", " ", "Haskell", "!"]
--   "Hello Haskell!"
--   </pre>
mconcat :: Monoid a => [a] -> a

-- | Run a <a>Managed</a> computation, enforcing that no acquired resources
--   leak
runManaged :: Managed () -> IO ()

-- | Acquire a <a>Managed</a> value
--   
--   This is a potentially unsafe function since it allows a resource to
--   escape its scope. For example, you might use <a>Managed</a> to safely
--   acquire a file handle, like this:
--   
--   <pre>
--   import qualified System.IO as IO
--   
--   example :: Managed Handle
--   example = managed (IO.withFile "foo.txt" IO.ReadMode)
--   </pre>
--   
--   ... and if you never used the <a>with</a> function then you would
--   never run the risk of accessing the <tt>Handle</tt> after the file was
--   closed. However, if you use <a>with</a> then you can incorrectly
--   access the handle after the handle is closed, like this:
--   
--   <pre>
--   bad :: IO ()
--   bad = do
--       handle &lt;- with example return
--       IO.hPutStrLn handle "bar"  -- This will fail because the handle is closed
--   </pre>
--   
--   ... so only use <a>with</a> if you know what you are doing and you're
--   returning a value that is not a resource being managed.
with :: Managed a -> (a -> IO r) -> IO r

-- | Build a <a>Managed</a> value
managed :: (forall r. () => (a -> IO r) -> IO r) -> Managed a

-- | A managed resource that you acquire using <a>with</a>
data Managed a
data FilePath

-- | Attempt to parse a <a>FilePath</a> from a string suitable for use with
--   functions in <tt>System.IO</tt>. Do not use this function for parsing
--   human‐readable paths, as the character set decoding is
--   platform‐dependent. For converting human‐readable text to a
--   <a>FilePath</a>, use <a>fromText</a>.
--   
--   Since: 0.3.1
decodeString :: String -> FilePath

-- | Attempt to convert a <a>FilePath</a> to a string suitable for use with
--   functions in <tt>System.IO</tt>. The contents of this string are
--   platform‐dependent, and are not guaranteed to be human‐readable. For
--   converting <a>FilePath</a>s to a human‐readable format, use
--   <a>toText</a>.
--   
--   Since: 0.3.1
encodeString :: FilePath -> String

-- | Convert human‐readable text into a <a>FilePath</a>.
--   
--   This function ignores the user’s locale, and assumes all file paths
--   are encoded in UTF8. If you need to create file paths with an unusual
--   or obscure encoding, encode them manually and then use <a>decode</a>.
--   
--   Since: 0.2
fromText :: Text -> FilePath

-- | Attempt to convert a <a>FilePath</a> to human‐readable text.
--   
--   If the path is decoded successfully, the result is a <a>Right</a>
--   containing the decoded text. Successfully decoded text can be
--   converted back to the original path using <a>fromText</a>.
--   
--   If the path cannot be decoded, the result is a <a>Left</a> containing
--   an approximation of the original path. If displayed to the user, this
--   value should be accompanied by some warning that the path has an
--   invalid encoding. Approximated text cannot be converted back to the
--   original path.
--   
--   This function ignores the user’s locale, and assumes all file paths
--   are encoded in UTF8. If you need to display file paths with an unusual
--   or obscure encoding, use <a>encode</a> and then decode them manually.
--   
--   Since: 0.2
toText :: FilePath -> Either Text Text

-- | <pre>
--   splitExtension p = (<a>dropExtension</a> p, <a>extension</a> p)
--   </pre>
splitExtension :: FilePath -> (FilePath, Maybe Text)

-- | Remove a <a>FilePath</a>’s last extension.
dropExtension :: FilePath -> FilePath

-- | An alias for <a>addExtension</a>.
(<.>) :: FilePath -> Text -> FilePath

-- | Get whether a <a>FilePath</a>’s last extension is the predicate.
hasExtension :: FilePath -> Text -> Bool

-- | Get a <a>FilePath</a>’s last extension, or <a>Nothing</a> if it has no
--   extensions.
extension :: FilePath -> Maybe Text

-- | expand a FilePath into a list of the root name, directories, and file
--   name
--   
--   Since: 0.4.7
splitDirectories :: FilePath -> [FilePath]

-- | Remove intermediate <tt>"."</tt> and <tt>".."</tt> directories from a
--   path.
--   
--   <pre>
--   <a>collapse</a> "/foo/./bar" == "/foo/bar"
--   <a>collapse</a> "/foo/bar/../baz" == "/foo/baz"
--   <a>collapse</a> "/foo/../../bar" == "/bar"
--   <a>collapse</a> "./foo/bar" == "./foo/baz"
--   </pre>
--   
--   Note that if any of the elements are symbolic links, <a>collapse</a>
--   may change which file the path resolves to.
--   
--   Since: 0.2
collapse :: FilePath -> FilePath

-- | Remove a prefix from a path.
--   
--   <pre>
--   <a>stripPrefix</a> "/foo/" "/foo/bar/baz.txt" == Just "bar/baz.txt"
--   <a>stripPrefix</a> "/foo/" "/bar/baz.txt" == Nothing
--   </pre>
--   
--   This function operates on logical prefixes, rather than by counting
--   characters. The prefix <tt>"/foo/bar/baz"</tt> is interpreted the path
--   <tt>("/foo/bar/", "baz")</tt>, and will be stripped accordingly:
--   
--   <pre>
--   <a>stripPrefix</a> "/foo/bar/baz" "/foo/bar/baz/qux" == Nothing
--   <a>stripPrefix</a> "/foo/bar/baz" "/foo/bar/baz.txt" == Just ".txt"
--   </pre>
--   
--   Since: 0.4.1
stripPrefix :: FilePath -> FilePath -> Maybe FilePath

-- | Find the greatest common prefix between a list of <a>FilePath</a>s.
commonPrefix :: [FilePath] -> FilePath

-- | An alias for <a>append</a>.
(</>) :: FilePath -> FilePath -> FilePath

-- | Test whether a path is relative.
relative :: FilePath -> Bool

-- | Test whether a path is absolute.
absolute :: FilePath -> Bool

-- | Retrieve a <a>FilePath</a>’s basename component.
--   
--   <pre>
--   basename "foo/bar.txt" == "bar"
--   </pre>
basename :: FilePath -> FilePath

-- | Retrieve a <a>FilePath</a>’s directory name. This is only the <i>file
--   name</i> of the directory, not its full path.
--   
--   <pre>
--   dirname "foo/bar/baz.txt" == "bar"
--   dirname "/" == ""
--   </pre>
--   
--   Since: 0.4.1
dirname :: FilePath -> FilePath

-- | Retrieve a <a>FilePath</a>’s filename component.
--   
--   <pre>
--   filename "foo/bar.txt" == "bar.txt"
--   </pre>
filename :: FilePath -> FilePath

-- | Retrieves the <a>FilePath</a>’s parent directory.
parent :: FilePath -> FilePath

-- | Retrieves the <a>FilePath</a>’s directory. If the path is already a
--   directory, it is returned unchanged.
directory :: FilePath -> FilePath

-- | Retrieves the <a>FilePath</a>’s root.
root :: FilePath -> FilePath

-- | Efficient representation of a left fold that preserves the fold's step
--   function, initial accumulator, and extraction function
--   
--   This allows the <a>Applicative</a> instance to assemble derived folds
--   that traverse the container only once
--   
--   A '<a>Fold</a> a b' processes elements of type <b>a</b> and results in
--   a value of type <b>b</b>.
data Fold a b

-- | <tt>Fold </tt> <tt> step </tt> <tt> initial </tt> <tt> extract</tt>
Fold :: (x -> a -> x) -> x -> (x -> b) -> Fold a b

-- | Like <a>Fold</a>, but monadic.
--   
--   A '<a>FoldM</a> m a b' processes elements of type <b>a</b> and results
--   in a monadic value of type <b>m b</b>.
data FoldM (m :: Type -> Type) a b

-- | <tt>FoldM </tt> <tt> step </tt> <tt> initial </tt> <tt> extract</tt>
FoldM :: (x -> a -> m x) -> m x -> (x -> m b) -> FoldM (m :: Type -> Type) a b

-- | A space efficient, packed, unboxed Unicode text type.
data Text

-- | This is the simplest representation of UTC. It consists of the day
--   number, and a time offset from midnight. Note that if a day has a leap
--   second added to it, it will have 86401 seconds.
data UTCTime

-- | This is a length of time, as measured by UTC. It has a precision of
--   10^-12 s.
--   
--   Conversion functions will treat it as seconds. For example, <tt>(0.010
--   :: NominalDiffTime)</tt> corresponds to 10 milliseconds.
--   
--   It ignores leap-seconds, so it's not necessarily a fixed amount of
--   clock time. For instance, 23:00 UTC + 2 hours of NominalDiffTime =
--   01:00 UTC (+ 1 day), regardless of whether a leap-second intervened.
data NominalDiffTime

-- | Haskell defines operations to read and write characters from and to
--   files, represented by values of type <tt>Handle</tt>. Each value of
--   this type is a <i>handle</i>: a record used by the Haskell run-time
--   system to <i>manage</i> I/O with file system objects. A handle has at
--   least the following properties:
--   
--   <ul>
--   <li>whether it manages input or output or both;</li>
--   <li>whether it is <i>open</i>, <i>closed</i> or
--   <i>semi-closed</i>;</li>
--   <li>whether the object is seekable;</li>
--   <li>whether buffering is disabled, or enabled on a line or block
--   basis;</li>
--   <li>a buffer (whose length may be zero).</li>
--   </ul>
--   
--   Most handles will also have a current I/O position indicating where
--   the next input or output operation will occur. A handle is
--   <i>readable</i> if it manages only input or both input and output;
--   likewise, it is <i>writable</i> if it manages only output or both
--   input and output. A handle is <i>open</i> when first allocated. Once
--   it is closed it can no longer be used for either input or output,
--   though an implementation cannot re-use its storage while references
--   remain to it. Handles are in the <a>Show</a> and <a>Eq</a> classes.
--   The string produced by showing a handle is system dependent; it should
--   include enough information to identify the handle for debugging. A
--   handle is equal according to <a>==</a> only to itself; no attempt is
--   made to compare the internal state of different handles for equality.
data Handle

-- | Defines the exit codes that a program can return.
data ExitCode

-- | indicates successful termination;
ExitSuccess :: ExitCode

-- | indicates program failure with an exit code. The exact interpretation
--   of the code is operating-system dependent. In particular, some values
--   may be prohibited (e.g. 0 on a POSIX-compliant system).
ExitFailure :: Int -> ExitCode

-- | Class for string-like datastructures; used by the overloaded string
--   extension (-XOverloadedStrings in GHC).
class IsString a
fromString :: IsString a => String -> a

-- | <a>&amp;</a> is a reverse application operator. This provides
--   notational convenience. Its precedence is one higher than that of the
--   forward application operator <a>$</a>, which allows <a>&amp;</a> to be
--   nested in <a>$</a>.
--   
--   <pre>
--   &gt;&gt;&gt; 5 &amp; (+1) &amp; show
--   "6"
--   </pre>
(&) :: a -> (a -> b) -> b
infixl 1 &

-- | Flipped version of <a>&lt;$&gt;</a>.
--   
--   <pre>
--   (<a>&lt;&amp;&gt;</a>) = <a>flip</a> <a>fmap</a>
--   </pre>
--   
--   <h4><b>Examples</b></h4>
--   
--   Apply <tt>(+1)</tt> to a list, a <a>Just</a> and a <a>Right</a>:
--   
--   <pre>
--   &gt;&gt;&gt; Just 2 &lt;&amp;&gt; (+1)
--   Just 3
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; [1,2,3] &lt;&amp;&gt; (+1)
--   [2,3,4]
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; Right 3 &lt;&amp;&gt; (+1)
--   Right 4
--   </pre>
(<&>) :: Functor f => f a -> (a -> b) -> f b
infixl 1 <&>


-- | Use <tt>turtle</tt> if you want to write light-weight and maintainable
--   shell scripts.
--   
--   <tt>turtle</tt> embeds shell scripting directly within Haskell for
--   three main reasons:
--   
--   <ul>
--   <li>Haskell code is easy to refactor and maintain because the language
--   is statically typed</li>
--   <li>Haskell is syntactically lightweight, thanks to global type
--   inference</li>
--   <li>Haskell programs can be type-checked and interpreted very rapidly
--   (&lt; 1 second)</li>
--   </ul>
--   
--   These features make Haskell ideal for scripting, particularly for
--   replacing large and unwieldy Bash scripts.
--   
--   This tutorial introduces how to use the <tt>turtle</tt> library to
--   write Haskell scripts. This assumes no prior knowledge of Haskell, but
--   does assume prior knowledge of Bash or a similar shell scripting
--   language.
--   
--   If you are already proficient with Haskell, then you can get quickly
--   up to speed by reading the Quick Start guide at the top of
--   <a>Turtle.Prelude</a>.
--   
--   If you are on Windows, the easiest way to follow along is to install
--   <a>Git for Windows</a> and use the Git Bash program that it installs
--   to get a fully featured Unix-like environment.
--   
--   For all operating systems, the recommended way to compile and run the
--   following examples is to download the <tt>stack</tt> package
--   management tool by following the instructions here:
--   
--   <a>https://github.com/commercialhaskell/stack</a>
--   
--   ... and then run the following instruction anywhere outside of a
--   Haskell project:
--   
--   <pre>
--   $ stack install turtle
--   </pre>
--   
--   This tutorial will mostly focus on using Haskell as a scripting
--   language. The first two lines of each script below contain boilerplate
--   instructions so that <tt>stack</tt> will load and run the script. This
--   helps ensure that a script will run on any computer that has a
--   <tt>stack</tt> executable, as <tt>stack</tt> can install a Haskell
--   compiler if one is not already present. If you are curious about how
--   these two lines work, they are described here:
--   
--   
--   <a>https://github.com/commercialhaskell/stack/blob/master/doc/GUIDE.md#script-interpreter</a>
--   
--   If you want to make a Windows script independently executable outside
--   of a Git Bash environment, you can either (A) compile the script into
--   an executable or (B) run these two commands from a <tt>cmd</tt> shell
--   with administrator privileges to make all <tt>*.hs</tt> scripts
--   executable:
--   
--   <pre>
--   assoc .hs=Haskell
--   ftype Haskell="C:\path\to\stack.exe" "%1" %*
--   </pre>
module Turtle.Tutorial
