ganeti-3.1: Cluster-based virtualization management software
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ganeti.PartialParams

Description

Common functions for partial parameters

Synopsis

Documentation

class PartialParams f p | p -> f, f -> p where #

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 -> f #

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

toPartial :: f -> p #

Fill all fields of p from f.

toFilled :: p -> Maybe f #

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

isComplete :: PartialParams f p => p -> Bool #

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