Open
Description
I find this to be useful:
-- same as eitherMatch but Left must be string which will be used for error
eitherMatch' :: forall b. Match (Either String b) -> Match b
eitherMatch' (Match r2eab) = Match $ \r ->
ValidationSemiRing.unV ValidationSemiRing.invalid runEither $ (r2eab r)
where
runEither (Tuple rs eit) =
case eit of
Left err -> ValidationSemiRing.invalid $ free $ Fail err
Right res -> pure $ Tuple rs res
it can be used to reconstruct current eitherMatch
like this:
eitherMatch :: forall a b. Match (Either a b) -> Match b
eitherMatch = lmap (const "Nested check failed") >>> eitherMatch'
what you think of adding eitherMatch'
or even changing eitherMatch
to be eitherMatch'
Metadata
Metadata
Assignees
Labels
No labels