data-checked-0.2: Type-indexed runtime-checked properties

Safe HaskellSafe-Inferred

Data.Checked

Description

Type-indexed runtime-checked properties.

Synopsis

Documentation

data Checked p v Source

Wrapper-evidence for property p.

Instances

trustMe :: v -> Checked p vSource

Use when the property can be deduced without a runtime check.

trustThat :: p -> v -> Checked p vSource

Use when the property can be deduced without a runtime check.

trustMap :: (v -> v) -> Checked p v -> Checked p vSource

Apply a fuction that preserves the property to the checked value.

checked :: Checked p v -> vSource

Unwrap the checked value.

class Property p v whereSource

Methods

holds :: p -> v -> BoolSource

Test if the property holds for the given value. The first argument is supposed to be ignored.

maybeHolds :: Property p v => p -> v -> Maybe vSource

Return Just v if p holds and Nothing overwise.

check :: forall p v. Property p v => v -> Maybe (Checked p v)Source

Wrap the value if the property holds.