Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data CollectErrors es v = CollectErrors {
- getMaybeValue :: Maybe v
- getErrors :: es
- class CanTestErrorsCertain es where
- hasCertainError :: es -> Bool
- class CanTestErrorsPresent es where
- type CanBeErrors es = (Monoid es, Eq es, Show es, CanTestErrorsCertain es, CanTestErrorsPresent es)
- noValue :: es -> CollectErrors es v
- removeValue :: Monoid es => CollectErrors es v -> es -> CollectErrors es v
- prependErrors :: Monoid es => es -> CollectErrors es v -> CollectErrors es v
- unCollectErrors :: Show es => CollectErrors es p -> p
- (~!) :: Show es => CollectErrors es p -> p
- toEither :: CanBeErrors es => CollectErrors es v -> Either es v
- withErrorOrValue :: CanBeErrors es => (es -> t) -> (v -> t) -> CollectErrors es v -> t
- filterValuesWithoutError :: CanBeErrors es => [CollectErrors es v] -> [v]
- lift :: Monoid es => (a -> b) -> CollectErrors es a -> CollectErrors es b
- liftCE :: Monoid es => (a -> CollectErrors es c) -> CollectErrors es a -> CollectErrors es c
- liftPair :: Monoid es => (a -> (c, d)) -> CollectErrors es a -> (CollectErrors es c, CollectErrors es d)
- lift2 :: Monoid es => (a -> b -> c) -> CollectErrors es a -> CollectErrors es b -> CollectErrors es c
- lift2CE :: Monoid es => (a -> b -> CollectErrors es c) -> CollectErrors es a -> CollectErrors es b -> CollectErrors es c
- lift1T :: Monoid es => (a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c
- lift1TCE :: Monoid es => (a -> b -> CollectErrors es c) -> CollectErrors es a -> b -> CollectErrors es c
- liftT1 :: Monoid es => (a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c
- liftT1CE :: Monoid es => (a -> b -> CollectErrors es c) -> a -> CollectErrors es b -> CollectErrors es c
- lift2pair :: Monoid es => (a -> b -> (c, d)) -> CollectErrors es a -> CollectErrors es b -> (CollectErrors es c, CollectErrors es d)
- lift1Tpair :: Monoid es => (a -> b -> (c, d)) -> CollectErrors es a -> b -> (CollectErrors es c, CollectErrors es d)
- liftT1pair :: Monoid es => (a -> b -> (c, d)) -> a -> CollectErrors es b -> (CollectErrors es c, CollectErrors es d)
- liftTakeErrors :: CanTakeErrors es t2 => (t1 -> t2) -> CollectErrors es t1 -> t2
- class CanTakeErrors es t where
- takeErrors :: es -> t -> t
- takeErrorsNoValue :: es -> t
Documentation
data CollectErrors es v Source #
A wrapper around values which can accommodate a list of (potential) errors that have (maybe) occurred during the computation of a value. A value may be missing, leaving only the error(s).
Such error collection allows one to write expressions with partial functions (ie functions that fail for some inputs) instead of branching after each application of such function. Dealing with the errors can be moved outside the expression. If the error data contain enough information, their list can be used to trace the source of the errors.
CollectErrors | |
|
Instances
class CanTestErrorsCertain es where Source #
hasCertainError :: es -> Bool Source #
Instances
CanTestErrorsCertain NumErrorLevel Source # | |
Defined in Numeric.CollectErrors.Type hasCertainError :: NumErrorLevel -> Bool Source # | |
CanTestErrorsCertain NumErrors Source # | |
Defined in Numeric.CollectErrors.Type hasCertainError :: NumErrors -> Bool Source # | |
CanTestErrorsCertain es => CanTestErrorsCertain [es] Source # | |
Defined in Control.CollectErrors.Type hasCertainError :: [es] -> Bool Source # | |
CanTestErrorsCertain es => CanTestErrorsCertain (Set es) Source # | |
Defined in Control.CollectErrors.Type hasCertainError :: Set es -> Bool Source # | |
CanTestErrorsCertain es => CanTestErrorsCertain (CollectErrors es v) Source # | |
Defined in Control.CollectErrors.Type hasCertainError :: CollectErrors es v -> Bool Source # |
class CanTestErrorsPresent es where Source #
Instances
CanTestErrorsPresent NumErrors Source # | |
CanTestErrorsPresent [es] Source # | |
Defined in Control.CollectErrors.Type | |
CanTestErrorsPresent (Set es) Source # | |
CanTestErrorsPresent es => CanTestErrorsPresent (CollectErrors es v) Source # | |
Defined in Control.CollectErrors.Type hasError :: CollectErrors es v -> Bool Source # |
type CanBeErrors es = (Monoid es, Eq es, Show es, CanTestErrorsCertain es, CanTestErrorsPresent es) Source #
noValue :: es -> CollectErrors es v Source #
removeValue :: Monoid es => CollectErrors es v -> es -> CollectErrors es v Source #
Take a CE-value, add new errors into it and remove the value, if any
prependErrors :: Monoid es => es -> CollectErrors es v -> CollectErrors es v Source #
unCollectErrors :: Show es => CollectErrors es p -> p Source #
Unsafe way to get a value out of the CollectErrors wrapper.
(~!) :: Show es => CollectErrors es p -> p Source #
Unsafe way to get a value out of the CollectErrors wrapper.
toEither :: CanBeErrors es => CollectErrors es v -> Either es v Source #
A safe way to get a value out of the CollectErrors wrapper.
withErrorOrValue :: CanBeErrors es => (es -> t) -> (v -> t) -> CollectErrors es v -> t Source #
filterValuesWithoutError :: CanBeErrors es => [CollectErrors es v] -> [v] Source #
lift :: Monoid es => (a -> b) -> CollectErrors es a -> CollectErrors es b Source #
liftCE :: Monoid es => (a -> CollectErrors es c) -> CollectErrors es a -> CollectErrors es c Source #
liftPair :: Monoid es => (a -> (c, d)) -> CollectErrors es a -> (CollectErrors es c, CollectErrors es d) Source #
lift2 :: Monoid es => (a -> b -> c) -> CollectErrors es a -> CollectErrors es b -> CollectErrors es c Source #
lift2CE :: Monoid es => (a -> b -> CollectErrors es c) -> CollectErrors es a -> CollectErrors es b -> CollectErrors es c Source #
lift1T :: Monoid es => (a -> b -> c) -> CollectErrors es a -> b -> CollectErrors es c Source #
lift1TCE :: Monoid es => (a -> b -> CollectErrors es c) -> CollectErrors es a -> b -> CollectErrors es c Source #
liftT1 :: Monoid es => (a -> b -> c) -> a -> CollectErrors es b -> CollectErrors es c Source #
liftT1CE :: Monoid es => (a -> b -> CollectErrors es c) -> a -> CollectErrors es b -> CollectErrors es c Source #
lift2pair :: Monoid es => (a -> b -> (c, d)) -> CollectErrors es a -> CollectErrors es b -> (CollectErrors es c, CollectErrors es d) Source #
lift1Tpair :: Monoid es => (a -> b -> (c, d)) -> CollectErrors es a -> b -> (CollectErrors es c, CollectErrors es d) Source #
liftT1pair :: Monoid es => (a -> b -> (c, d)) -> a -> CollectErrors es b -> (CollectErrors es c, CollectErrors es d) Source #
liftTakeErrors :: CanTakeErrors es t2 => (t1 -> t2) -> CollectErrors es t1 -> t2 Source #
class CanTakeErrors es t where Source #
takeErrors :: es -> t -> t Source #
takeErrorsNoValue :: es -> t Source #
Instances
(CanTakeErrors es t1, CanTakeErrors es t2) => CanTakeErrors es (t1, t2) Source # | |
Defined in Control.CollectErrors.Type takeErrors :: es -> (t1, t2) -> (t1, t2) Source # takeErrorsNoValue :: es -> (t1, t2) Source # | |
Monoid es => CanTakeErrors es (CollectErrors es t) Source # | |
Defined in Control.CollectErrors.Type takeErrors :: es -> CollectErrors es t -> CollectErrors es t Source # takeErrorsNoValue :: es -> CollectErrors es t Source # |