Module
Routing.Match
- Package
- purescript-routing
- Repository
- purescript-contrib/purescript-routing
#nonempty Source
nonempty :: Match NonEmptyString
Matches a non-empty string.
#eitherMatch Source
eitherMatch :: forall a b. Match (Either a b) -> Match b
if we match something that can fail then we have to
match Either a b
. This function converts matching on such
sum to matching on right subpart. Matching on left branch fails.
i.e.
data Sort = Asc | Desc
sortOfString :: String -> Either String Sort
sortOfString "asc" = Right Asc
sortOfString "desc" = Right Desc
sortOfString _ = Left "incorrect sort"
newtype Routing = Routing Sort
routes :: Match Routing
routes = (pure Routing) <*> (eitherMatch (sortOfString <$> var))