@@ -16,7 +16,7 @@ import Data.Semiring.Free (Free, free)
1616import Data.String.NonEmpty (NonEmptyString )
1717import Data.String.NonEmpty as NES
1818import Data.Tuple (Tuple (..), snd )
19- import Data.Validation.Semiring (V , invalid , unV )
19+ import Data.Validation.Semiring (V , invalid , validation )
2020import Data.Number as Number
2121import Routing.Match.Error (MatchError (..), showMatchError )
2222import Routing.Types (Route , RoutePart (..))
@@ -27,7 +27,7 @@ derive instance newtypeMatch :: Newtype (Match a) _
2727
2828instance matchFunctor :: Functor Match where
2929 map fn (Match r2e) = Match $ \r ->
30- unV invalid (\(Tuple rs a) -> pure $ Tuple rs (fn a)) $ r2e r
30+ validation invalid (\(Tuple rs a) -> pure $ Tuple rs (fn a)) $ r2e r
3131
3232instance matchAlt :: Alt Match where
3333 alt (Match r2e1) (Match r2e2) = Match $ \r -> do
@@ -40,11 +40,11 @@ instance matchAlternative :: Alternative Match
4040
4141instance matchApply :: Apply Match where
4242 apply (Match r2a2b) (Match r2a) =
43- Match $ (\r -> unV (processFnErr r) processFnRes (r2a2b r))
43+ Match $ (\r -> validation (processFnErr r) processFnRes (r2a2b r))
4444 where processFnErr r err =
45- invalid $ err * unV identity (const one) (r2a r)
45+ invalid $ err * validation identity (const one) (r2a r)
4646 processFnRes (Tuple rs a2b) =
47- unV invalid (\(Tuple rss a) -> pure $ Tuple rss (a2b a)) (r2a rs)
47+ validation invalid (\(Tuple rss a) -> pure $ Tuple rss (a2b a)) (r2a rs)
4848
4949instance matchApplicative :: Applicative Match where
5050 pure a = Match \r -> pure $ Tuple r a
@@ -160,7 +160,7 @@ list (Match r2a) =
160160 Match $ go Nil
161161 where go :: List a -> Route -> V (Free MatchError ) (Tuple Route (List a ))
162162 go accum r =
163- unV
163+ validation
164164 (const $ pure (Tuple r (reverse accum)))
165165 (\(Tuple rs a) -> go (Cons a accum) rs)
166166 (r2a r)
@@ -169,7 +169,7 @@ list (Match r2a) =
169169-- [[String]] -fold with semicolon-> [String] -fold with newline-> String
170170runMatch :: forall a . Match a -> Route -> Either String a
171171runMatch (Match fn) route =
172- unV foldErrors (Right <<< snd) $ fn route
172+ validation foldErrors (Right <<< snd) $ fn route
173173 where
174174 foldErrors errs =
175175 Left $ foldl (\b a -> a <> " \n " <> b) " " do
@@ -195,7 +195,7 @@ runMatch (Match fn) route =
195195-- | ```
196196eitherMatch :: forall a b . Match (Either a b ) -> Match b
197197eitherMatch (Match r2eab) = Match $ \r ->
198- unV invalid runEither $ (r2eab r)
198+ validation invalid runEither $ (r2eab r)
199199 where
200200 runEither (Tuple rs eit) =
201201 case eit of
@@ -209,4 +209,4 @@ eitherMatch (Match r2eab) = Match $ \r ->
209209-- | -- (Right (fromFoldable [(Tuple "a" "1")]))
210210-- | ```
211211optionalMatch :: forall a . Match a -> Match (Maybe a )
212- optionalMatch (Match fn) = Match (\route -> unV (const $ pure (Tuple route Nothing )) (pure <<< map Just ) $ fn route)
212+ optionalMatch (Match fn) = Match (\route -> validation (const $ pure (Tuple route Nothing )) (pure <<< map Just ) $ fn route)
0 commit comments