Module

Type.Trout

Package
purescript-trout
Repository
owickstrom/purescript-trout

#Lit Source

data Lit (v :: Symbol)

A literal path segment, matching paths where the next segment is equal to the value of the Symbol.

For example, the type Lit "settings" :> Lit "general" :> "reset" would match the path /settings/general/reset.

#Capture Source

data Capture (v :: Symbol) t

Captures one segment of a path as type t. The v is a Symbol that describes the captured value.

#CaptureAll Source

data CaptureAll (v :: Symbol) t

Captures all remaining segments of a path, all as type t. The v is a Symbol that describes the captured value.

#Resource Source

data Resource ms cts

A type-level description of an HTTP resource, terminating a chain of path literals, captures, and other endpoint type constructs. The ms are the methods handled by this resource. cts are the content types that this resource supports.

#Method Source

data Method (m :: Symbol) r

The m symbol is the HTTP method that is handled, and r is the response representation (usually some type specific to the application domain.)

#Raw Source

data Raw (m :: Symbol)

A type-level description of a raw middleware, terminating a chain of path literals, captures, and other endpoint type constructs. The m symbol is the HTTP method that is handled.

#Sub Source

data Sub e t

The Sub is used to create the chain of Lit, Capture, Resource, and other such type constructs that build up an endpoint type. Sub is more often used infix with the :> operator.

#LitSub Source

type LitSub (v :: Symbol) t = Sub (Lit v) t

A handy type alias for Sub (Lit v), meant to be used infix with the :/ operator. Instead of writing Lit "a" :> Lit "b" :> ..., you can write "a" :/ "b" :/ ....

#AltE Source

data AltE a b

AltE respresents choice, i.e. that endpoint a is tried first, and if it fails, b is tried next. AltE is written infix using :<|> and is used to compose multiple endpoint types into a larger API or site. It is used to build up recursive structures, so AltE a (AltE b c) can be written a :<|> b :<|> c.

It it also used to extract information from a type, where the information has the same structure as the type. For instance, when extracting links from an AltE type, you can pattern match the result using :<|> to access the links of a and b. That also works recursively with a pattern match like a :<|> b :<|> c :<|> d.

Constructors

#type (:>) Source

Operator alias for Type.Trout.Sub (right-associative / precedence 5)

#type (:/) Source

Operator alias for Type.Trout.LitSub (right-associative / precedence 5)

#type (:<|>) Source

Operator alias for Type.Trout.AltE (left-associative / precedence 4)

#(:<|>) Source

Operator alias for Type.Trout.AltE (left-associative / precedence 4)