ganeti

Safe HaskellSafe-Infered

Ganeti.PartialParams

Description

Common functions for partial parameters

Synopsis

Documentation

class PartialParams f p | p -> f, f -> p whereSource

Represents that data type p provides partial values for data type f.

Note: To avoid needless type annotations, the functional dependencies currently include f -> p. However, in theory it'd be possible for one filled data type to have several partially filled ones.

Laws:

  1. fillParams (fillParams f p) p = fillParams f p. 2. fillParams _ (toPartial x) = x. 3. toFilled (toPartial x) = Just x.

If p is also a Monoid (or just Semigroup), fillParams is a monoid (semigroup) action on f, therefore it should additionally satisfy:

  • fillParams f mempty = f - fillParams f (p1 p2) = fillParams (fillParams f p1) p2

Methods

fillParams :: f -> p -> fSource

Fill f with any data that are set in p. Leave other parts of f unchanged.

toPartial :: f -> pSource

Fill all fields of p from f.

toFilled :: p -> Maybe fSource

If all fields of p are filled, convert it into f.

isComplete :: PartialParams f p => p -> BoolSource

Returns True if a given partial parameters are complete. See toFilled.