more docs about bimap

This commit is contained in:
Tom Sydney Kerckhove 2021-11-15 10:52:16 +01:00
parent 2ba58cb1d3
commit ba37cd65e9

View File

@ -441,14 +441,12 @@ eitherCodec = EitherCodec
-- --
-- This function allows you to have the parsing fail in a new way. -- This function allows you to have the parsing fail in a new way.
-- --
-- If you use this function, then you will most likely want to add documentation about how not every value that the schema specifies will be accepted.
--
-- === Example usage -- === Example usage
-- --
-- > boundedIntegerCodec :: (Integral i, Bounded i) => JSONCodec i -- logLevelCodec :: JSONCodec LogLevel
-- > boundedIntegerCodec = bimapCodec go fromIntegral $ NumberCodec Nothing -- logLevelCodec = bimapCodec parseLogLevel renderLogLevel codec <?> "Valid values include DEBUG, INFO, WARNING, ERROR."
-- > where
-- > go s = case Scientific.toBoundedInteger s of
-- > Nothing -> Left $ "Number too big: " <> show s
-- > Just i -> Right i
bimapCodec :: bimapCodec ::
(oldOutput -> Either String newOutput) -> (oldOutput -> Either String newOutput) ->
(newInput -> oldInput) -> (newInput -> oldInput) ->