Data.Checked

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

Safe Haskell | Safe
Language | Haskell98

Data.Checked

Description

Type-indexed runtime-checked properties.

Synopsis

- data Checked p v
- trustMe :: v -> Checked p v
- trustThat :: p -> v -> Checked p v
- trustMap :: (v -> v) -> Checked p v -> Checked p v
- checked :: Checked p v -> v
- class Property p v where
- maybeHolds :: Property p v => p -> v -> Maybe v
- check :: forall p v. Property p v => v -> Maybe (Checked p v)

# Documentation

data Checked p v #

Wrapper-evidence for property p.

Instances

NFData v => NFData (Checked p v) # |
Methods rnf :: Checked p v -> () #

trustMe :: v -> Checked p v #

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

trustThat :: p -> v -> Checked p v #

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

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

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

checked :: Checked p v -> v #

Unwrap the checked value.

class Property p v where #

Minimal complete definition

holds

Methods

holds :: p -> v -> Bool #

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

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

Return `Just` v if p holds and `Nothing` overwise.

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

Wrap the value if the property holds.