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
routeEmpty :: r
routeSegments :: Lens' r (Array String)
routeQueryString :: Lens' r (Object String)
Instances
#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
#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.
Re-exports from Data.Intertwine.Route.PathPiece
Re-exports from Data.Intertwine.Syntax
#(<|||>) 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