Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Data.Convertible.Tiny
Synopsis
- convert :: Convertible a b => a -> b
- class Convertible a b where
- safeConvert :: a -> ConvertResult b
- type ConvertResult a = Either ConvertError a
- data ConvertError = ConvertError {}
- convError :: (Show a, Typeable a, Typeable b) => String -> a -> ConvertResult b
- prettyConvertError :: ConvertError -> String
The conversion process
convert :: Convertible a b => a -> b #
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 safeConvert
.
class Convertible a b where #
A typeclass that represents something that can be converted.
A Convertible a b
instance represents an a
that can be converted to a b
.
Methods
safeConvert :: a -> ConvertResult b #
Convert a
to b
, returning Right on success and Left on error.
For a simpler interface, see convert
.
Instances
Convertible a a Source # | Any type can be converted to itself. |
Defined in Data.Convertible.Tiny Methods safeConvert :: a -> ConvertResult a # | |
Convertible String QualName Source # | |
Defined in Data.Model.Types Methods safeConvert :: String -> ConvertResult QualName # | |
Convertible QualName String Source # | |
Defined in Data.Model.Types Methods safeConvert :: QualName -> ConvertResult String # |
Handling the results
type ConvertResult a = Either ConvertError a #
The result of a safe conversion via safeConvert
.
data ConvertError #
How we indicate that there was an error.
Constructors
ConvertError | |
Fields |
Instances
Eq ConvertError | |
Defined in Data.Convertible.Base | |
Read ConvertError | |
Defined in Data.Convertible.Base Methods readsPrec :: Int -> ReadS ConvertError # readList :: ReadS [ConvertError] # | |
Show ConvertError | |
Defined in Data.Convertible.Base Methods showsPrec :: Int -> ConvertError -> ShowS # show :: ConvertError -> String # showList :: [ConvertError] -> ShowS # | |
Error ConvertError | |
Defined in Data.Convertible.Base |
Orphan instances
Convertible a a Source # | Any type can be converted to itself. |
Methods safeConvert :: a -> ConvertResult a # |