| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Ganeti.PartialParams
Description
Common functions for partial parameters
Synopsis
- class PartialParams f p | p -> f, f -> p where
- fillParams :: f -> p -> f
- toPartial :: f -> p
- toFilled :: p -> Maybe f
- isComplete :: PartialParams f p => p -> Bool
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:
fillParams (fillParams f p) p = fillParams f p.fillParams _ (toPartial x) = x.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.
Fill all fields of p from f.
If all fields of p are filled, convert it into f.
Instances
isComplete :: PartialParams f p => p -> Bool #
Returns True if a given partial parameters are complete.
See toFilled.