okapi-0.2.0.0: A bidirectional HTTP description language
Safe HaskellNone
LanguageGHC2024

Okapi.HTTP.Request.Path

Synopsis

Documentation

data Path a where Source #

Constructors

Seg_ :: forall a1. Leaf Path a1 -> a1 -> Path () 
Seg :: forall a. Text -> Leaf Path a -> Path a 
Segs :: forall a1. Leaf Path a1 -> Path (NonEmpty a1) 
Raw :: Path [Text] 

Instances

Instances details
HasLeaf Path Int16 Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path Int32 Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path Int64 Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path Text Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path UUID Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path Integer Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

HasLeaf Path Int Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

Methods

leaf :: Leaf Path Int Source #

type Context Path Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

type Context Path = [Text]
type Failure Path Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

type Piece Path Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

type Piece Path = Text

data ParseError Source #

Constructors

ParseError 

Instances

Instances details
Show ParseError Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

Eq ParseError Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

segment_ :: Leaf Path a -> a -> Tree Path () () Source #

Match a fixed literal segment.

>>> printer (segment_ int 42) ()
["42"]
>>> parser (segment_ int 42) ["42"]
(Right (),[])
>>> parser (segment_ int 42) ["99"]
(Left ParseError,["99"])

segment :: Text -> Leaf Path a -> Tree Path a a Source #

Parse and print a single typed path segment.

>>> printer (segment "id" int) (42 :: Int)
["42"]
>>> parser (segment "id" int) ["42"]
(Right 42,[])
>>> parser (segment "id" int) ["hello"]
(Left ParseError,["hello"])
>>> parser (segment "id" int) []
(Left ParseError,[])
printParse parser printer (segment "n" int) (x :: Int)
printParse parser printer (segment "n" integer) x
printStable parser printer (segment "n" int) (x :: Int)

segments :: Leaf Path a -> Tree Path (NonEmpty a) (NonEmpty a) Source #

Parse and print all remaining path segments as a non-empty list.

printParse parser printer (segments int) (x :| xs)
printStable parser printer (segments int) (x :| xs)

data LitF (sym :: Symbol) Source #

Constructors

LitF 

Instances

Instances details
Show (LitF sym) Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

Methods

showsPrec :: Int -> LitF sym -> ShowS #

show :: LitF sym -> String #

showList :: [LitF sym] -> ShowS #

Eq (LitF sym) Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

Methods

(==) :: LitF sym -> LitF sym -> Bool #

(/=) :: LitF sym -> LitF sym -> Bool #

KnownSymbol sym => GPath (S1 meta (Rec0 (LitF sym))) Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

Methods

gPathCodec :: Tree Path (S1 meta (Rec0 (LitF sym)) ()) (S1 meta (Rec0 (LitF sym)) ()) Source #

class GPath (f :: Type -> Type) where Source #

Methods

gPathCodec :: Tree Path (f ()) (f ()) Source #

Instances

Instances details
(GPath f, GPath g) => GPath (f :*: g) Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

Methods

gPathCodec :: Tree Path ((f :*: g) ()) ((f :*: g) ()) Source #

GPath f => GPath (C1 meta f) Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

Methods

gPathCodec :: Tree Path (C1 meta f ()) (C1 meta f ()) Source #

GPath f => GPath (D1 meta f) Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

Methods

gPathCodec :: Tree Path (D1 meta f ()) (D1 meta f ()) Source #

KnownSymbol sym => GPath (S1 meta (Rec0 (LitF sym))) Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

Methods

gPathCodec :: Tree Path (S1 meta (Rec0 (LitF sym)) ()) (S1 meta (Rec0 (LitF sym)) ()) Source #

(Selector meta, HasLeaf Path a) => GPath (S1 meta (Rec0 a)) Source # 
Instance details

Defined in Okapi.HTTP.Request.Path

Methods

gPathCodec :: Tree Path (S1 meta (Rec0 a) ()) (S1 meta (Rec0 a) ()) Source #

pathCodec :: (Generic a, GPath (Rep a)) => Tree Path a a Source #