Module

URI.Scheme

#Scheme

newtype Scheme

The scheme part of an absolute URI. For example: http, ftp, git.

Instances

#fromString

fromString :: String -> Maybe Scheme

Attempts to create a Scheme from the passed string. The scheme component of a URI has no escape sequences, so this function will return Nothing if an invalid value is provided.

fromString "http" == Just (Scheme.unsafeFromString "http")
fromString "git+ssh" == Just (Scheme.unsafeFromString "git+ssh")
fromString "!!!" == Nothing
fromString "" == Nothing

#toString

toString :: Scheme -> NonEmptyString

Returns the string value for a scheme.

toString (unsafeFromString "http") == "http"
toString (unsafeFromString "git+ssh") == "git+ssh"

#unsafeFromString

unsafeFromString :: String -> Scheme

Constructs a Scheme part unsafely: if the value is not an acceptable scheme a runtime error will be thrown.

This is intended as a convenience when describing Schemes statically in PureScript code, in all other cases fromString should be used.

#parser

parser :: Parser String Scheme

A parser for the scheme component of a URI. Expects a scheme string followed by ':'.

#print

print :: Scheme -> String

A printer for the scheme component of a URI. Prints a scheme value followed by a ':'.

Modules