sprout
Type members
Classlikes
Helper for various sprout constructors, because going from your new type to your old type is always the same.
Helper for various sprout constructors, because going from your new type to your old type is always the same.
This is extremely handy when defining various contravariant functor typeclasses, e.g. various encoders, ordering, etc.
The purpose of this type class is to give further application code a way to talk about this "new type" encoding. So that converting to and from the underlying type can be done with as little boilerplate as possible in inter-op with 3rd party libraries, and other classes.
The purpose of this type class is to give further application code a way to talk about this "new type" encoding. So that converting to and from the underlying type can be done with as little boilerplate as possible in inter-op with 3rd party libraries, and other classes.
- Type Params
- N
N for new type. i.e. the type that ought to live only in the compiler
- O
O for old type. i.e. the underlying runtime type
- See also
sprout.SproutShow as an example. We can easily provide a Show instance for N if the underlying representation has one. And it's opt in. This principle is then extended to a host of 3rd party libraries to eliminate boilerplate. See the sprout-interop github repo for many other examples.
- Companion
- object
- See also
sprout.NewType This typeclass is usefull for defining the contravariant functors. e.g. io.circe.Encoder for your new types.
- Companion
- object
Intended to be mixed into an object, or in certain cases a class, for them to act as the containers and constructors for your new type.
Intended to be mixed into an object, or in certain cases a class, for them to act as the containers and constructors for your new type.
e.g.
object FirstName extends Sprout[String]
type FirstName = FirstName.Type