Module

React.Router.Utils

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

#showLocation Source

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

Fold over list of locations and join them as urls.

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

#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.

#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.

#findLocation Source

findLocation :: forall a arg. ({ arg :: arg, url :: Route } -> Maybe a) -> List (Cofree List { arg :: arg, url :: Route }) -> Maybe (Tuple a (List (Cofree List { arg :: arg, url :: Route })))

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 { arg :: arg, url :: Route }) -> Maybe (Tuple a (List (Cofree List { arg :: arg, url :: Route })))) -> (List (Cofree List { arg :: arg, url :: Route }) -> Maybe (Tuple b (List (Cofree List { arg :: arg, url :: Route })))) -> List (Cofree List { arg :: arg, url :: Route }) -> Maybe (Tuple (Tuple a (Maybe b)) (List (Cofree List { arg :: arg, url :: Route })))

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 { arg :: arg, url :: Route }) -> Maybe (Tuple a (List (Cofree List { arg :: arg, url :: Route })))) -> (List (Cofree List { arg :: arg, url :: Route }) -> Maybe (Tuple b (List (Cofree List { arg :: arg, url :: Route })))) -> List (Cofree List { arg :: arg, url :: Route }) -> Maybe (Tuple (Tuple b (Maybe a)) (List (Cofree List { arg :: arg, url :: Route })))

#(:<<<) Source

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

#joinUrls Source

joinUrls :: String -> String -> String

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

#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