-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Type-indexed runtime-checked properties
--   
--   This package provides a (phantom) type-indexed newtype
--   evidence-wrapper for values that are checked to satisfy the property
--   associated with the type.
@package data-checked
@version 0.3


-- | Type-indexed runtime-checked properties.
module Data.Checked

-- | Wrapper-evidence for property <i>p</i>.
data Checked p v

-- | Use when the property can be deduced without a runtime check.
trustMe :: v -> Checked p v

-- | Use when the property can be deduced without a runtime check.
trustThat :: p -> v -> Checked p v

-- | Apply a fuction that preserves the property to the checked value.
trustMap :: (v -> v) -> Checked p v -> Checked p v

-- | Unwrap the checked value.
checked :: Checked p v -> v
class Property p v

-- | Test if the property holds for the given value. The first argument is
--   supposed to be ignored.
holds :: Property p v => p -> v -> Bool

-- | Return <a>Just</a> <i>v</i> if <i>p</i> holds and <a>Nothing</a>
--   overwise.
maybeHolds :: Property p v => p -> v -> Maybe v

-- | Wrap the value if the property holds.
check :: forall p v. Property p v => v -> Maybe (Checked p v)
instance Control.DeepSeq.NFData v => Control.DeepSeq.NFData (Data.Checked.Checked p v)


-- | A version of <a>Checked</a> that requires client code to provide a
--   non-bottom value of the property index type to use <tt>trust*</tt>
--   functions.
module Data.Checked.Strict

-- | Wrapper-evidence for property <i>p</i>.
data Checked p v

-- | Use when the property can be deduced without a runtime check. Note
--   that <i>p</i> is evaluated to WHNF, so you can't use <a>undefined</a>.
trustThat :: p -> v -> Checked p v

-- | Apply a fuction that preserves the property to the checked value. Note
--   that <i>p</i> is evaluated to WHNF, so you can't use <a>undefined</a>.
trustMap :: p -> (v -> v) -> Checked p v -> Checked p v

-- | Unwrap the checked value.
checked :: Checked p v -> v
class Property p v

-- | Test if the property holds for the given value. The first argument is
--   supposed to be ignored.
holds :: Property p v => p -> v -> Bool

-- | Return <a>Just</a> <i>v</i> if <i>p</i> holds and <a>Nothing</a>
--   overwise.
maybeHolds :: Property p v => p -> v -> Maybe v

-- | Wrap the value if the property holds.
check :: forall p v. Property p v => v -> Maybe (Checked p v)

-- | Rewrap a value into the less strict <a>Checked</a> type.
relax :: Checked p v -> Checked p v
instance Control.DeepSeq.NFData v => Control.DeepSeq.NFData (Data.Checked.Strict.Checked p v)
