sprout

package sprout

Type members

Classlikes

trait Burry[O]

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.

trait NewType[O, N] extends OldType[O, N]

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
object NewType
Companion
class
trait OldType[O, N]
See also

sprout.NewType This typeclass is usefull for defining the contravariant functors. e.g. io.circe.Encoder for your new types.

Companion
object
object OldType
Companion
class
trait RefinedType[O, N, E] extends OldType[O, N]
Companion
object
object RefinedType
Companion
class
trait Sprout[O] extends Burry[O]

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
trait SproutEq[OT](using ot: Eq[OT])
trait SproutOrder[OT](using co: Order[OT])
trait SproutRefined[O, E] extends Burry[O]
trait SproutRefinedSub[O, E] extends SproutRefined[O, E]
trait SproutRefinedThrow[O] extends SproutRefined[O, Throwable]
trait SproutShow[OT](using ot: Show[OT])
trait SproutSub[O] extends Sprout[O]

Types

type RefinedTypeThrow[O, N] = RefinedType[O, N, Throwable]