| Portability | portable |
|---|---|
| Stability | provisional |
| Maintainer | Michael Snoyman <michael@snoyman.com> |
Data.Convertible.Base
Description
- class ConvertAttempt a b where
- convertAttempt :: a -> Attempt b
- failure :: Failure e f => forall v. e -> f v
- class ConvertSuccess a b where
- convertSuccess :: a -> b
- cs :: ConvertSuccess x y => x -> y
- ca :: ConvertAttempt x y => x -> Attempt y
- data ConversionException = forall e . Exception e => ConversionException e
- convertUnsafe :: ConvertAttempt a b => a -> b
- convertAttemptWrap :: (ConvertAttempt a b, Failure ConversionException m) => a -> m b
- deriveAttempts :: [(Name, Name)] -> Q [Dec]
Documentation
class ConvertAttempt a b whereSource
A typeclass that represents something that can attempt a conversion.
An ConvertAttempt a b instance represents an a that might be convertible to a b.
Methods
convertAttempt :: a -> Attempt bSource
Instances
class ConvertSuccess a b whereSource
A typeclass that represents something that guarantees a successful conversion.
A ConvertSuccess a b instance represents an a that can be converted to a b.
Instances
cs :: ConvertSuccess x y => x -> ySource
A convenience synonym for convertSuccess
ca :: ConvertAttempt x y => x -> Attempt ySource
A convenience synonym for convertAttempt
data ConversionException Source
Wraps any Exception which could occur during a convertAttempt.
Constructors
| forall e . Exception e => ConversionException e |
convertUnsafe :: ConvertAttempt a b => a -> bSource
Convert from one type of data to another. Raises an exception if there is
an error with the conversion. For a function that does not raise an exception
in that case, see convertAttempt.
convertAttemptWrap :: (ConvertAttempt a b, Failure ConversionException m) => a -> m bSource
Calls convertAttempt, wrapping any Exceptions in a
ConversionException
deriveAttempts :: [(Name, Name)] -> Q [Dec]Source
Template Haskell to derive ConvertAttempt instances from the
corresponding ConvertSuccess instances.