package codecs
- Alphabetic
- Public
- All
Type Members
-
trait
Codec[E, D, F, T] extends Decoder[E, D, F, T] with Encoder[E, D, T]
Combines a Decoder and an Encoder.
Combines a Decoder and an Encoder.
Codecs are only meant as a convenience, and should not be considered more powerful or desirable than encoders or decoders. Some types can be both encoded to and decoded from, and being able to define both instances in one call is convenient. It's however very poor practice to request a type to have a Codec instance - a much preferred alternative would be to require it to have a Decoder and an Encoder instance, which a Codec would fulfill.
- trait CodecCompanion[E, F, T] extends AnyRef
-
trait
Decoder[E, D, F, T] extends Serializable
Type class for types that can be decoded from other types.
Type class for types that can be decoded from other types.
- E
encoded type - what to decode from.
- D
decoded type - what to decode to.
- F
failure type - how to represent errors.
- T
tag type - used to specialise decoder instances, and usually where default implementations are declared.
-
trait
DecoderCompanion[E, F, T] extends Serializable
Provides methods commonly declared by companion objects for specialised decoder types.
Provides methods commonly declared by companion objects for specialised decoder types.
Most libraries that use kantan.codecs will declare type aliases for decoders -
CellDecoderin kantan.csv, for example. DecoderCompanion lets such types have a useful companion object without a lot of code duplication. -
trait
Encoder[E, D, T] extends Serializable
Type class for types that can be encoded into others.
Type class for types that can be encoded into others.
- E
encoded type - what to encode to.
- D
decoded type - what to encode from.
- T
tag type.
- trait EncoderCompanion[E, T] extends AnyRef
-
trait
Optional[A] extends Serializable
Type class that represents data types that have an "empty" value.
Type class that represents data types that have an "empty" value.
The purpose of this type class is to allow automatic derivation of Decoder for decoded types that might not have a value -
Option,List...In theory, there should rarely be a need to interact directly with this type class, and one is usually better served by obtaining the Decoder instance for
Optionand mapping on it.
Value Members
-
object
Codec extends Serializable
Provides instance creation methods for Codec.
- object Decoder extends Serializable
- object Encoder extends Serializable
- object Optional extends Serializable
- object Result
-
object
ResultCompanion
Provides trait that result companion object can extend.
Provides trait that result companion object can extend.
The idea is that libraries that rely on kantan.codecs are likely to provide type-constrained versions of result, such as
DecodeResultin kantan.csv. Users are likely to expect goodies such asfromTryorsequenceonDecodeResult's companion object, which can be achieved by extending kantan.codecs.ResultCompanion.WithDefault.