Module

React.Router.Utils

Package
purescript-cofree-react-router
Repository
coot/purescript-cofree-react-router

#routeToString Source

routeToString :: Route -> String

Print Routing.Types.Route as a string, useful for debugging.

#warning Source

warning :: forall e. Boolean -> String -> Eff (console :: CONSOLE | e) Unit

#hasBaseName Source

#stripBaseName Source

#joinUrls Source

joinUrls :: URL -> URL -> URL

Join two url strings putting / separator in between if necessary.

#showLocation Source

showLocation :: forall t a. Show a => Foldable t => t a -> URL

Fold over list of locations and join them as urls.

showLocation (Home : User 1 : Settings) -- /user/1/settings

#findLocation Source

findLocation :: forall a arg. (RouteLeaf arg -> Maybe a) -> List (Cofree List (RouteLeaf arg)) -> Maybe (Tuple a (List (Cofree List (RouteLeaf arg))))

Find location inside a tail of Cofree List. This is useful for querying about children that are mounted under a given component.

#composeFL Source

composeFL :: forall b a arg. (List (Cofree List (RouteLeaf arg)) -> Maybe (Tuple a (List (Cofree List (RouteLeaf arg))))) -> (List (Cofree List (RouteLeaf arg)) -> Maybe (Tuple b (List (Cofree List (RouteLeaf arg))))) -> List (Cofree List (RouteLeaf arg)) -> Maybe (Tuple (Tuple a (Maybe b)) (List (Cofree List (RouteLeaf arg))))

Compose two findLocation _ functions. Note that this composition runs from left to right (unlike function composition), i.e. the left argument is applied first and then the right argument is applied to the tail returned by the first one. For example

data A = A
data B = B
data C = C
type Arg = { arg :: Location, url :: Route}

fn :: Arg -> Maybe A
fn _ = Just A

gn :: Arg -> Maybe B
gn _ = Just B

hn :: Arg -> Maybe C
hn _ = Just C

(findLocation fn) :>>> (findLocation gn)
 :: Arg
 -> Maybe (Tuple (Tuple A (Maybe B)) (List (Cofree List Arg)))

(findLocation fn) :>>> (findLocation gn) :>>> (findLocation hn)
  :: Arg
  -> Maybe (Tuple (Tuple A (Maybe (Tuple B (Maybe C)))) (List (Cofree List Arg)))

#(:>>>) Source

Operator alias for React.Router.Utils.composeFL (right-associative / precedence 7)

#composeFLFlipped Source

composeFLFlipped :: forall b a arg. (List (Cofree List (RouteLeaf arg)) -> Maybe (Tuple a (List (Cofree List (RouteLeaf arg))))) -> (List (Cofree List (RouteLeaf arg)) -> Maybe (Tuple b (List (Cofree List (RouteLeaf arg))))) -> List (Cofree List (RouteLeaf arg)) -> Maybe (Tuple (Tuple b (Maybe a)) (List (Cofree List (RouteLeaf arg))))

#(:<<<) Source

Operator alias for React.Router.Utils.composeFLFlipped (right-associative / precedence 7)

#mountedLocationsRelative Source

mountedLocationsRelative :: forall arg. RouteProps arg -> List (List arg)

Take tail of the RouteProps and list all mounted locations relative. The resulting routes are relative to the current path.

Note that the current path (i.e. RouteProps { args }) is not included.

#mountedLocations Source

mountedLocations :: forall arg. RouteProps arg -> List (List arg)

Like mountedLocationsRelative but the list full paths instead of relative ones.

Note that the current path (i.e. RouteProps { args }) is not included.