Module

URI.Fragment

#Fragment

newtype Fragment

The fragment component (hash) of a URI.

Instances

#fromString

fromString :: String -> Fragment

Constructs a fragment value from a string, percent-encoding any characters that require it. Note that running this on a string that has already had percent-encoding applied will double-encode it, for those situations use unsafeFromString instead.

fromString "foo" = unsafeFromString "foo"
fromString "foo#bar" = unsafeFromString "foo%23bar"
fromString "foo%23bar" = unsafeFromString "foo%2523bar"

#toString

toString :: Fragment -> String

Returns the string value for a fragment, percent-decoding any characters that require it.

toString (unsafeFromString "foo") = "foo"
toString (unsafeFromString "foo%23bar") = "foo#bar"

#unsafeFromString

unsafeFromString :: String -> Fragment

Constructs a fragment value from a string directly - no percent-encoding will be applied. This is useful when using a custom encoding scheme for the fragment, to prevent double-encoding.

#unsafeToString

unsafeToString :: Fragment -> String

Returns the string value for the fragment without percent-decoding. Only "unsafe" in the sense that values this produces may need further decoding, the name is more for symmetry with the fromString/unsafeFromString pairing.

#parser

parser :: Parser String Fragment

A parser for the fragment component of a URI. Expects values with a '#' prefix.

#print

print :: Fragment -> String

A printer for the fragment component of a URI. Will print the value with a '#' prefix.

#fragmentChar

fragmentChar :: Parser String Char

The supported fragment characters, excluding percent-encodings.

Modules