Safe Haskell | Safe-Infered |
---|
Common functions for partial parameters
- 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 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:
-
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 -> p -> fSource
Fill f
with any data that are set in p
.
Leave other parts of f
unchanged.
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
.