nikita-volkov / typeclasses / Typeclasses.Classes.Bounds

Bounds typeclass definition and its instances for basic types.

Definition


type alias Bounds a =
{ min : a, max : a }

Explicit typeclass which implements a bounded type a.

Instances

int : Bounds Basics.Int

Instance for Int.

char : Bounds Char

Instance for Char.

bool : Bounds Basics.Bool

Instance for Bool.

order : Bounds Basics.Order

Instance for Order.

unit : Bounds ()

Instance for ().

Composites

tuple2 : Bounds a -> Bounds b -> Bounds ( a, b )

Instance for tuple (pair), with instances for its members provided.

tuple3 : Bounds a -> Bounds b -> Bounds c -> Bounds ( a, b, c )

Instance for tuple (triple), with instances for its members provided.

Instance transformation utilities

map : (a -> b) -> Bounds a -> Bounds b

Map over the owner type of an instance to produce a new instance.

For example, to create a bounded record type:

map (\v -> { x = v }) int == Bounds { x = int.min } { x = int.max }