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


-- | File URI parsing
--   
--   Parses file URIs based on RFC 8089, including windows filepaths.
@package file-uri
@version 0.1.0.0

module System.URI.File.Internal

-- | A parsed file URI. It can have an auth/host part.
data FileURI
FileURI :: Maybe ByteString -> ByteString -> FileURI

-- | optional host part ("localhost" is parsed as <a>Nothing</a>);
--   <a>UNC</a> paths on windows go into <a>filePath</a> and are not split
[fileAuth] :: FileURI -> Maybe ByteString

-- | the proper absolute filepath
[filePath] :: FileURI -> ByteString

-- | RFC syntax configuration.
data ParseSyntax

-- | Only parses the strict syntax according to <a>section 2 of RFC
--   8089</a>, which is technically posix paths.
StrictPosix :: ParseSyntax

-- | Also parses extended user information described in <a>E.1</a>
ExtendedPosix :: ParseSyntax

-- | Parses windows paths according to <a>E.1</a>, <a>E.2</a> and
--   <a>E.3</a>. Unlike the spec, posix paths are rejected.
ExtendedWindows :: ParseSyntax

-- | Parse a file URI such as <tt>file:///foo/bar</tt> into <a>FileURI</a>.
--   
--   <pre>
--   &gt;&gt;&gt; parseFileURI StrictPosix "file:/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI StrictPosix "file:///path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI StrictPosix "file://hostname/path/to/file"
--   Right (FileURI {fileAuth = Just "hostname", filePath = "/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI StrictPosix "file://localhost/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI StrictPosix "http://localhost/path/to/file"
--   Left "string"
--   
--   &gt;&gt;&gt; parseFileURI StrictPosix "/path/to/file"
--   Left "string"
--   
--   &gt;&gt;&gt; parseFileURI ExtendedWindows "file://///host.example.com/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "//host.example.com/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI ExtendedWindows "file:///c:/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "c:/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI ExtendedWindows "file:/c:/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "c:/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI ExtendedWindows "file:c:/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "c:/path/to/file"})
--   </pre>
parseFileURI :: ParseSyntax -> ByteString -> Either String FileURI

-- | Parse a file URI according to the <a>main ABNF in RFC 8089</a>,
--   without any extended rules, which is as follows:
--   
--   <pre>
--   file-URI       = file-scheme ":" file-hier-part
--   
--   file-scheme    = "file"
--   
--   file-hier-part = ( "//" auth-path )
--                  / local-path
--   
--   auth-path      = [ file-auth ] path-absolute
--   
--   local-path     = path-absolute
--   
--   file-auth      = "localhost"
--                  / host
--   </pre>
fileURIStrictP :: Parser FileURI

-- | Parse a file URI according to the <a>main ABNF in RFC 8089</a>, with
--   extended rule <a>E.1</a>.
--   
--   <pre>
--   file-URI       = file-scheme ":" file-hier-part
--   
--   file-scheme    = "file"
--   
--   file-hier-part = ( "//" auth-path )
--                  / local-path
--   
--   auth-path      = [ file-auth ] path-absolute
--   
--   local-path     = path-absolute
--   
--   file-auth      = "localhost"
--                  / [ userinfo "@" ] host
--   </pre>
fileURIExtendedPosixP :: Parser FileURI

-- | Parse a file URI according for windows according to <a>E.1</a>,
--   <a>E.2</a> and <a>E.3</a>. Unlike the spec, posix paths are rejected.
--   The ABNF is a slight modification of <a>Appendix F</a>.
--   
--   <pre>
--   file-URI       = file-scheme ":" file-hier-part
--   
--   file-scheme    = "file"
--   
--   file-hier-part = ( "//" auth-path )
--                  / local-path
--   
--   auth-path      = [ file-auth ] file-absolute
--                  / unc-authority path-absolute
--   
--   local-path     =  drive-letter path-absolute
--                  / file-absolute
--   
--   file-auth      = "localhost"
--                  / [ userinfo "@" ] host
--   
--   unc-authority  = 2*3"/" file-host
--   
--   file-host      = inline-IP <i> IPv4address </i> reg-name
--   
--   inline-IP      = "%5B" ( IPv6address / IPvFuture ) "%5D"
--   
--   file-absolute  = "/" drive-letter path-absolute
--   
--   drive-letter   = ALPHA ":"
--                  / ALPHA "|"
--   </pre>
fileURIExtendedWindowsP :: Parser FileURI
pathAbsoluteP :: Parser ByteString
uncAuthorityP :: Parser ByteString
fileHostP :: Parser ByteString
fileAbsoluteP :: Parser ByteString
driveLetterP :: Parser Word8

-- | Like <a>driveLetterP</a>, but appends <tt>:</tt>.
driveLetterP' :: Parser ByteString
userInfoP :: Parser ByteString
hostP :: Parser ByteString
regNameP :: Parser ByteString
ipLiteralP :: Parser ByteString

-- | Parses IPVFuture addresses. See relevant section in RFC.
ipVFutureP :: Parser ByteString

-- | Parses IPV6 addresses. See relevant section in RFC.
ipV6P :: Parser ByteString

-- | Parses a valid IPV4 address
ipV4P :: Parser ByteString
pathAbEmpty :: Parser ByteString
segmentP :: Parser ByteString
segmentNZP :: Parser ByteString
segmentNZNCP :: Parser ByteString
pcharP :: Parser Word8
pctEncodedP :: Parser Word8
hexDigit :: Word8 -> Bool
unreserved :: String
subDelims :: String
alphaNum :: String
alpha :: String
digit :: String
oBracket :: Word8
cBracket :: Word8
colon :: Word8
period :: Word8
satisfyClass :: String -> Parser Word8
sequenceM :: Monad m => [m ByteString] -> m ByteString
parseBetween :: (Alternative m, Monad m) => Int -> Int -> m a -> m [a]
instance GHC.Classes.Eq System.URI.File.Internal.FileURI
instance GHC.Classes.Eq System.URI.File.Internal.ParseSyntax
instance GHC.Internal.Show.Show System.URI.File.Internal.FileURI
instance GHC.Internal.Show.Show System.URI.File.Internal.ParseSyntax


-- | <tt>System.URI.File</tt> aims to be an <a>RFC8089</a> compliant URI
--   file parser that uses efficient ByteStrings for parsing and
--   representing the data.
--   
--   As such it only parses a subset of <a>RFC3986</a>, but is better at
--   interpreting the file paths. <b>Filepaths are always absolute
--   according to the spec</b>.
--   
--   Part of this module was ripped off of the <a>uri-bytestring</a>
--   package from Soostone (specifically the host part parsing).
module System.URI.File

-- | A parsed file URI. It can have an auth/host part.
data FileURI
FileURI :: Maybe ByteString -> ByteString -> FileURI

-- | optional host part ("localhost" is parsed as <a>Nothing</a>);
--   <a>UNC</a> paths on windows go into <a>filePath</a> and are not split
[fileAuth] :: FileURI -> Maybe ByteString

-- | the proper absolute filepath
[filePath] :: FileURI -> ByteString

-- | RFC syntax configuration.
data ParseSyntax

-- | Only parses the strict syntax according to <a>section 2 of RFC
--   8089</a>, which is technically posix paths.
StrictPosix :: ParseSyntax

-- | Also parses extended user information described in <a>E.1</a>
ExtendedPosix :: ParseSyntax

-- | Parses windows paths according to <a>E.1</a>, <a>E.2</a> and
--   <a>E.3</a>. Unlike the spec, posix paths are rejected.
ExtendedWindows :: ParseSyntax

-- | Parse a file URI such as <tt>file:///foo/bar</tt> into <a>FileURI</a>.
--   
--   <pre>
--   &gt;&gt;&gt; parseFileURI StrictPosix "file:/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI StrictPosix "file:///path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI StrictPosix "file://hostname/path/to/file"
--   Right (FileURI {fileAuth = Just "hostname", filePath = "/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI StrictPosix "file://localhost/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI StrictPosix "http://localhost/path/to/file"
--   Left "string"
--   
--   &gt;&gt;&gt; parseFileURI StrictPosix "/path/to/file"
--   Left "string"
--   
--   &gt;&gt;&gt; parseFileURI ExtendedWindows "file://///host.example.com/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "//host.example.com/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI ExtendedWindows "file:///c:/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "c:/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI ExtendedWindows "file:/c:/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "c:/path/to/file"})
--   
--   &gt;&gt;&gt; parseFileURI ExtendedWindows "file:c:/path/to/file"
--   Right (FileURI {fileAuth = Nothing, filePath = "c:/path/to/file"})
--   </pre>
parseFileURI :: ParseSyntax -> ByteString -> Either String FileURI

-- | Parse a file URI according to the <a>main ABNF in RFC 8089</a>,
--   without any extended rules, which is as follows:
--   
--   <pre>
--   file-URI       = file-scheme ":" file-hier-part
--   
--   file-scheme    = "file"
--   
--   file-hier-part = ( "//" auth-path )
--                  / local-path
--   
--   auth-path      = [ file-auth ] path-absolute
--   
--   local-path     = path-absolute
--   
--   file-auth      = "localhost"
--                  / host
--   </pre>
fileURIStrictP :: Parser FileURI

-- | Parse a file URI according to the <a>main ABNF in RFC 8089</a>, with
--   extended rule <a>E.1</a>.
--   
--   <pre>
--   file-URI       = file-scheme ":" file-hier-part
--   
--   file-scheme    = "file"
--   
--   file-hier-part = ( "//" auth-path )
--                  / local-path
--   
--   auth-path      = [ file-auth ] path-absolute
--   
--   local-path     = path-absolute
--   
--   file-auth      = "localhost"
--                  / [ userinfo "@" ] host
--   </pre>
fileURIExtendedPosixP :: Parser FileURI

-- | Parse a file URI according for windows according to <a>E.1</a>,
--   <a>E.2</a> and <a>E.3</a>. Unlike the spec, posix paths are rejected.
--   The ABNF is a slight modification of <a>Appendix F</a>.
--   
--   <pre>
--   file-URI       = file-scheme ":" file-hier-part
--   
--   file-scheme    = "file"
--   
--   file-hier-part = ( "//" auth-path )
--                  / local-path
--   
--   auth-path      = [ file-auth ] file-absolute
--                  / unc-authority path-absolute
--   
--   local-path     =  drive-letter path-absolute
--                  / file-absolute
--   
--   file-auth      = "localhost"
--                  / [ userinfo "@" ] host
--   
--   unc-authority  = 2*3"/" file-host
--   
--   file-host      = inline-IP <i> IPv4address </i> reg-name
--   
--   inline-IP      = "%5B" ( IPv6address / IPvFuture ) "%5D"
--   
--   file-absolute  = "/" drive-letter path-absolute
--   
--   drive-letter   = ALPHA ":"
--                  / ALPHA "|"
--   </pre>
fileURIExtendedWindowsP :: Parser FileURI
