Module

Yoga.HTTP.API.Path

Package
purescript-yoga-http-api
Repository
rowtype-yoga/purescript-yoga-http-api

#Path Source

data Path :: forall k. k -> Typedata Path segments

Type-level path representation

Examples: Path Root -- / Path (Lit "users") -- /users Path (Lit "users" / Capture "id" Int) -- /users/:id Path (Lit "users" / Capture "id" Int / Lit "posts") -- /users/:id/posts

Instances

#Root Source

data Root

Root path representing "/"

Example: Path Root -- /

Instances

#Lit Source

data Lit :: Symbol -> Typedata Lit (segment :: Symbol)

Literal path segment (wrapper for Symbol to work around PureScript 0.15 limitations)

In PureScript 0.15, we can't use bare Symbols like Path "users" due to kind inference. Instead, use: Path (Lit "users")

Example: Path (Lit "users") -- /users Path (Lit "users" / Capture "id" Int) -- /users/:id

Instances

#Capture Source

data Capture :: Symbol -> Type -> Typedata Capture (name :: Symbol) (ty :: Type)

Capture a path parameter with a name and type

Example: Capture "id" Int -- captures :id as an Int Capture "name" String -- captures :name as a String

Instances

#PathCons Source

data PathCons :: forall k1 k2. k1 -> k2 -> Typedata PathCons left right

Instances

#type (/) Source

Operator alias for Yoga.HTTP.API.Path.PathCons (right-associative / precedence 6)

Infix operator for building paths

Example: Lit "users" / Capture "id" Int / Lit "posts"

#Param Source

data Param :: Symbol -> Type -> Typedata Param (name :: Symbol) (ty :: Type)

Sugar for Capture — use with bare Symbols in the path DSL

Example: Path ("users" / "id" : Int / "posts") -- equivalent to: Path (Lit "users" / Capture "id" Int / Lit "posts")

Instances

#type (:) Source

Operator alias for Yoga.HTTP.API.Path.Param (right-associative / precedence 8)

#QueryParams Source

data QueryParams :: forall k. k -> Type -> Typedata QueryParams path params

Attach query parameters to a path

Example: Path ("users" / "id" : Int) :? { limit :: Int, offset :: Required Int }

Instances

#type (:?) Source

Operator alias for Yoga.HTTP.API.Path.QueryParams (left-associative / precedence 1)

#Required Source

data Required a

Marker for required query parameters (default is optional → Maybe)

Example: Path ("users") :? (limit :: Int, offset :: Required Int) -- limit parses as Maybe Int, offset parses as Int (fails if missing)

#PathPattern Source

class PathPattern :: forall k. k -> Constraintclass PathPattern path  where

Generate a Fastify-compatible URL pattern from a path type

Examples: pathPattern (Proxy :: _ (Path Root)) = "/" pathPattern (Proxy :: _ (Path (Lit "users"))) = "/users" pathPattern (Proxy :: _ (Path (Lit "users" / Capture "id" Int))) = "/users/:id" pathPattern (Proxy :: _ ("users" / "id" : Int)) = "/users/:id"

Members

Instances

#PathPatternSegs Source

class PathPatternSegs :: forall k. k -> Constraintclass PathPatternSegs segs  where

Internal poly-kinded class for generating URL patterns from path segments.

Members

Instances

#ParseParam Source

class ParseParam (ty :: Type)  where

Parse a value from a String (used for path captures)

Members

Instances

#ParsePath Source

class ParsePath :: Type -> Row Type -> Constraintclass ParsePath (path :: Type) (params :: Row Type) | path -> params where

Parse a URL string into a record of typed path parameters

Examples: parsePath @(Path Root) "/" = Just {} parsePath @(Path (Lit "users")) "/users" = Just {} parsePath @(Path (Lit "users" / Capture "id" Int)) "/users/123" = Just { id: 123 }

Members

Instances