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


-- | A parser and writer for the HTTP Link header per RFC 5988
--   
--   Please see the README on GitHub at
--   <a>https://github.com/myfreeweb/http-link-header#readme</a>
@package http-link-header
@version 1.2.1


-- | The data type definitions for the HTTP Link header.
module Network.HTTP.Link.Types

-- | The link attribute key.
data LinkParam
Rel :: LinkParam
Anchor :: LinkParam
Rev :: LinkParam
Hreflang :: LinkParam
Media :: LinkParam
Title :: LinkParam
Title' :: LinkParam
ContentType :: LinkParam
Other :: Text -> LinkParam

-- | A single link containing some representation of a URL.
data Link uri
Link :: uri -> [(LinkParam, Text)] -> Link uri

-- | Types that can represent URLs.
--   
--   For example, to parse links containing <tt>Text.URI.URI</tt> from the
--   <a>modern-uri</a> package, simply define the orphan instance:
--   
--   <pre>
--   instance IsURI Modern.URI where
--       uriFromText = left displayException . mkURI
--       uriToText = render
--   </pre>
class IsURI uri
uriFromText :: IsURI uri => Text -> Either String uri
uriToText :: IsURI uri => uri -> Text

-- | Extracts the URI from the link.
href :: IsURI uri => Link uri -> uri

-- | Extracts the parameters from the link.
linkParams :: Link uri -> [(LinkParam, Text)]
instance GHC.Show.Show Network.HTTP.Link.Types.LinkParam
instance GHC.Classes.Eq Network.HTTP.Link.Types.LinkParam
instance GHC.Show.Show uri => GHC.Show.Show (Network.HTTP.Link.Types.Link uri)
instance GHC.Classes.Eq uri => GHC.Classes.Eq (Network.HTTP.Link.Types.Link uri)
instance Network.HTTP.Link.Types.IsURI Network.URI.URI
instance Network.HTTP.Link.Types.IsURI Data.Text.Internal.Text


-- | The parser for the HTTP Link header as defined in RFC 5988. More
--   liberal than the RFC though: does not validate URLs and other deep
--   stuff, accepts whitespace in weird places.
module Network.HTTP.Link.Parser

-- | The Attoparsec parser for the Link header.
linkHeader :: IsURI uri => Parser [Link uri]

-- | Parses a Link header, returns an Either, where Left is the Attoparsec
--   error string (probably not a useful one).
parseLinkHeader' :: IsURI uri => Text -> Either String [Link uri]

-- | Parses a Link header, returns a Maybe.
parseLinkHeader :: IsURI uri => Text -> Maybe [Link uri]

-- | Parses a Link header, returns an Either, where Left is the Attoparsec
--   error string (probably not a useful one).
parseLinkHeaderBS' :: IsURI uri => ByteString -> Either String [Link uri]

-- | Parses a Link header, returns a Maybe.
parseLinkHeaderBS :: IsURI uri => ByteString -> Maybe [Link uri]

module Network.HTTP.Link.Writer
writeLink :: IsURI uri => Link uri -> Text
writeLinkHeader :: IsURI uri => [Link uri] -> Text


-- | This module exports all the things at the same time, plus a utility
--   function.
module Network.HTTP.Link

-- | Construct a Link.
lnk :: IsURI uri => String -> [(LinkParam, Text)] -> Maybe (Link uri)
instance Network.HTTP.Link.Types.IsURI uri => Web.Internal.HttpApiData.ToHttpApiData [Network.HTTP.Link.Types.Link uri]
instance Network.HTTP.Link.Types.IsURI uri => Web.Internal.HttpApiData.ToHttpApiData (Network.HTTP.Link.Types.Link uri)
