Skip to content

Commit

Permalink
Fix haddock example
Browse files Browse the repository at this point in the history
  • Loading branch information
TotallyNotChase committed Aug 25, 2021
1 parent 79b87ab commit 5920208
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Valida/Combinators.hs
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,16 @@ optionally (Validator v) = Validator $ maybe (Success Nothing) (fmap Just . v)
Yields 'Success' when input is 'Nothing', and wrapped around the default value.
@vald \`withDefault\` deflt = 'Data.Maybe.fromMaybe' deflt <$> 'optionally' vald@
@vald \`withDefault\` deflt = 'Data.Maybe.fromMaybe' deflt '<$>' 'optionally' vald@
==== __Examples__
>>> runValidator (failureIf even "Even" `withDefault` 0) (Just 5)
Success (Just 5)
Success 5
>>> runValidator (failureIf even "Even" `withDefault` 0) (Just 6)
Failure ("Even" :| [])
>>> runValidator (failureIf even "Even" `withDefault` 0) Nothing
Success Nothing
Success 0
-}
withDefault :: Validator e inp a -> a -> Validator e (Maybe inp) a
withDefault (Validator v) deflt = Validator $ maybe (Success deflt) v
Expand Down

0 comments on commit 5920208

Please sign in to comment.