Hoogle Search

Within LTS Haskell 24.34 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. conversionMap :: (Ok a -> Ok b) -> Conversion a -> Conversion b

    postgresql-simple Database.PostgreSQL.Simple.Internal

    No documentation available.

  2. BimapCodec :: forall oldOutput output input oldInput context . (oldOutput -> Either String output) -> (input -> oldInput) -> Codec context oldInput oldOutput -> Codec context input output

    autodocodec Autodocodec

    Map a codec in both directions. This is not strictly dimap, because the decoding function is allowed to fail, but we can implement dimap using this function by using a decoding function that does not fail. Otherwise we would have to have another constructor here.

  3. HashMapCodec :: forall k input v output . (Eq k, Hashable k, FromJSONKey k, ToJSONKey k, Coercible input (HashMap k v), Coercible output (HashMap k v)) => JSONCodec v -> Codec Value input output

    autodocodec Autodocodec

    Encode a HashMap, and decode any HashMap.

  4. bimapCodec :: (oldOutput -> Either String newOutput) -> (newInput -> oldInput) -> Codec context oldInput oldOutput -> Codec context newInput newOutput

    autodocodec Autodocodec

    Map a codec's input and output types. 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. This function is like BimapCodec except it also combines one level of a nested BimapCodecs.

    Example usage

    logLevelCodec :: JSONCodec LogLevel logLevelCodec = bimapCodec parseLogLevel renderLogLevel codec ? "Valid values include DEBUG, INFO, WARNING, ERROR."

  5. dimapCodec :: (oldOutput -> newOutput) -> (newInput -> oldInput) -> Codec context oldInput oldOutput -> Codec context newInput newOutput

    autodocodec Autodocodec

    Map both directions of a codec You can use this function to change the type of a codec as long as the two functions are inverses.

    HasCodec instance for newtypes

    A good use-case is implementing HasCodec for newtypes:
    newtype MyInt = MyInt { unMyInt :: Int }
    instance HasCodec MyInt where
    codec = dimapCodec MyInt unMyInt codec
    

  6. lmapCodec :: (newInput -> oldInput) -> Codec context oldInput output -> Codec context newInput output

    autodocodec Autodocodec

    Map the input part of a codec You can use this function if you only need to map the rendering-side of a codec. This function is probably only useful if the function you map does not change the codec type. WARNING: This can be used to produce a codec that does not roundtrip.

    >>> toJSONVia (lmapCodec (*2) (codec :: JSONCodec Int)) 5
    Number 10.0
    

  7. rmapCodec :: (oldOutput -> newOutput) -> Codec context input oldOutput -> Codec context input newOutput

    autodocodec Autodocodec

    Map the output part of a codec You can use this function if you only need to map the parsing-side of a codec. This function is probably only useful if the function you map does not change the codec type. WARNING: This can be used to produce a codec that does not roundtrip.

    >>> JSON.parseMaybe (parseJSONVia (rmapCodec (*2) codec)) (Number 5) :: Maybe Int
    Just 10
    

  8. BimapCodec :: forall oldOutput output input oldInput context . (oldOutput -> Either String output) -> (input -> oldInput) -> Codec context oldInput oldOutput -> Codec context input output

    autodocodec Autodocodec.Codec

    Map a codec in both directions. This is not strictly dimap, because the decoding function is allowed to fail, but we can implement dimap using this function by using a decoding function that does not fail. Otherwise we would have to have another constructor here.

  9. HashMapCodec :: forall k input v output . (Eq k, Hashable k, FromJSONKey k, ToJSONKey k, Coercible input (HashMap k v), Coercible output (HashMap k v)) => JSONCodec v -> Codec Value input output

    autodocodec Autodocodec.Codec

    Encode a HashMap, and decode any HashMap.

  10. bimapCodec :: (oldOutput -> Either String newOutput) -> (newInput -> oldInput) -> Codec context oldInput oldOutput -> Codec context newInput newOutput

    autodocodec Autodocodec.Codec

    Map a codec's input and output types. 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. This function is like BimapCodec except it also combines one level of a nested BimapCodecs.

    Example usage

    logLevelCodec :: JSONCodec LogLevel logLevelCodec = bimapCodec parseLogLevel renderLogLevel codec ? "Valid values include DEBUG, INFO, WARNING, ERROR."

Page 488 of many | Previous | Next