@@ -41,10 +41,12 @@ instance matchAlternative :: Alternative Match
4141instance matchApply :: Apply Match where
4242 apply (Match r2a2b) (Match r2a) =
4343 Match $ (\r -> validation (processFnErr r) processFnRes (r2a2b r))
44- where processFnErr r err =
45- invalid $ err * validation identity (const one) (r2a r)
46- processFnRes (Tuple rs a2b) =
47- validation invalid (\(Tuple rss a) -> pure $ Tuple rss (a2b a)) (r2a rs)
44+ where
45+ processFnErr r err =
46+ invalid $ err * validation identity (const one) (r2a r)
47+
48+ processFnRes (Tuple rs a2b) =
49+ validation invalid (\(Tuple rss a) -> pure $ Tuple rss (a2b a)) (r2a rs)
4850
4951instance matchApplicative :: Applicative Match where
5052 pure a = Match \r -> pure $ Tuple r a
@@ -61,7 +63,7 @@ lit input = Match \route ->
6163 Cons (Path i) rs | i == input ->
6264 pure $ Tuple rs unit
6365 Cons (Path _) _ ->
64- invalid $ free $ UnexpectedPath input
66+ invalid $ free $ UnexpectedPath input
6567 _ ->
6668 invalid $ free ExpectedPathPart
6769
@@ -119,9 +121,8 @@ param key = Match \route ->
119121 Just el -> do
120122 let remainingParams = M .delete key map
121123 pure $
122- if M .isEmpty remainingParams
123- then Tuple rs el
124- else Tuple (Cons (Query remainingParams) rs) el
124+ if M .isEmpty remainingParams then Tuple rs el
125+ else Tuple (Cons (Query remainingParams) rs) el
125126 _ ->
126127 invalid $ free ExpectedQuery
127128
@@ -158,12 +159,13 @@ nonempty =
158159list :: forall a . Match a -> Match (List a )
159160list (Match r2a) =
160161 Match $ go Nil
161- where go :: List a -> Route -> V (Free MatchError ) (Tuple Route (List a ))
162- go accum r =
163- validation
164- (const $ pure (Tuple r (reverse accum)))
165- (\(Tuple rs a) -> go (Cons a accum) rs)
166- (r2a r)
162+ where
163+ go :: List a -> Route -> V (Free MatchError ) (Tuple Route (List a ))
164+ go accum r =
165+ validation
166+ (const $ pure (Tuple r (reverse accum)))
167+ (\(Tuple rs a) -> go (Cons a accum) rs)
168+ (r2a r)
167169
168170-- It groups `Free MatchError` -> [[MatchError]] -map with showMatchError ->
169171-- [[String]] -fold with semicolon-> [String] -fold with newline-> String
@@ -174,8 +176,7 @@ runMatch (Match fn) route =
174176 foldErrors errs =
175177 Left $ foldl (\b a -> a <> " \n " <> b) " " do
176178 es <- reverse <$> unwrap errs
177- pure $ foldl (\b a -> a <> " ;" <> b) " " $ showMatchError <$> es
178-
179+ pure $ foldl (\b a -> a <> " ;" <> b) " " $ showMatchError <$> es
179180
180181-- | if we match something that can fail then we have to
181182-- | match `Either a b`. This function converts matching on such
0 commit comments