Module

Data.Intertwine.Route

Package
purescript-intertwine
Repository
collegevine/purescript-intertwine

#IsRoute Source

class IsRoute r  where

This class abstracts the idea of the "route" data type, making it possible for the primitive in this module to work with data types from other libraries.

Members

Instances

#PathInfo Source

data PathInfo

The default representation of a route: here the route is represented as a sequence of path segments and a dictionary of querystring parameters.

Constructors

Instances

#RoutesDef Source

type RoutesDef route a = forall syntax. Syntax syntax => syntax route a

Syntax definition for a set of routes of type a.

#parseRoute Source

parseRoute :: forall route a. IsRoute route => RoutesDef route a -> route -> Maybe a

#printRoute Source

printRoute :: forall route a. IsRoute route => RoutesDef route a -> a -> Maybe route

#empty Source

empty :: forall route. IsRoute route => RoutesDef route Unit

Empty route. During printing doesn't produce any output, during parsing makes sure that there are no URL segments remaining.

#literal Source

literal :: forall route. IsRoute route => String -> RoutesDef route Unit

Literal string. During printing outputs the given string, during parsing consumes the next URL segment and makes sure it's equal to the given string.

#value Source

value :: forall route a. IsRoute route => PathPiece a => RoutesDef route a

A value of the given type as URL segment. During printing, the printer outputs the value as a URL segment, using the PathPiece instance to convert it to a string. During parsing, the parser consumes a URL segment and tries to parse it into a value of the given type using the PathPiece instance.

#exactly Source

exactly :: forall route a. Eq a => a -> RoutesDef route a

A primitive that encodes a constant value. During printing, the printer succeeds iff the value beign printed is equal to theValue, otherwise fails. During parsing, the parser returns theValue without consuming any input.

#query Source

query :: forall route a. IsRoute route => PathPiece a => String -> RoutesDef route (Maybe a)

QueryString value. During printing adds the printed value to the QueryString under given key. During parsing, looks up the value in the QueryString.

Re-exports from Data.Intertwine.Route.PathPiece

#PathPiece Source

class PathPiece a  where

This class makes a type suitable for participating in route printing/parsing - i.e. to be the type of path segments and querystring parameters.

Members

Instances

Re-exports from Data.Intertwine.Syntax

#Ctor Source

data Ctor (name :: Symbol)

This type is equivalent to SProxy, but provided here separately for the purpose of shortening the code in combination with the <|:|> operator (see comments there).

Constructors

#(<|||>) Source

Operator alias for Data.Intertwine.Syntax.alt (left-associative / precedence 2)

Combines two printers/parsers of the same type in a way that first attempts the left one, and if it fails, falls back to the right.

#(<|:|>) Source

Operator alias for Data.Intertwine.Syntax.injectConstructor (right-associative / precedence 5)

Binds a constructor, whose name is encoded in the Ctor value, to the given parser/printer.

For example:

data T = A String | B (Maybe Int)

syntax =
         (Ctor::Ctor "A") <|:|> value
   <|||> (Ctor::Ctor "B") <|:|> query "id"

#(<|*|>) Source

Operator alias for Data.Intertwine.Syntax.synApply (right-associative / precedence 5)

Combines two printers/parsers together, iyelding a printer/parser that can print/parse a tuple of the two combined values.

a :: syntax a
b :: syntax b
a <|*|> b :: syntax (a, b)

#(<|$|>) Source

Operator alias for Data.Intertwine.Syntax.synInject (right-associative / precedence 5)

Injects an Iso into a printer/parser on the right side, producing a printer/parser of the type that is left type of the Iso.

i :: Iso a (b, (c, d))
p :: syntax (b, (c, d))
i <|$|> p :: syntax a

#(*|>) Source

Operator alias for Data.Intertwine.Syntax.dropUnit (right-associative / precedence 5)

Combines a printer/parser that consumes/returns a unit with another printer/parser in a way that the unit is dropped instead of becoming part of a tuple, as it would with <|*|>

a :: syntax Unit
b :: syntax a
a *|> b :: syntax a