 | convertible-1.0.9.1: Typeclasses and instances for converting between types | Contents | Index |
|
Data.Convertible.Utils | Portability | portable | Stability | provisional | Maintainer | John Goerzen <jgoerzen@complete.org> |
|
|
|
Description |
|
|
Synopsis |
|
|
|
Documentation |
|
boundedConversion |
|
|
mkTypeName :: String -> TypeRep |
Useful for defining Typeable instances. Example:
instance Typeable TimeOfDay where
typeOf _ = mkTypeName "TimeOfDay"
|
|
convertVia |
:: (Convertible a b, Convertible b c) | | => b | Dummy data to establish intermediate type - can be undefined
| -> a | Input value
| -> ConvertResult c | Result
| Useful for defining conversions that are implemented in terms of other
conversions via an intermediary type. Instead of:
instance Convertible CalendarTime POSIXTime where
safeConvert a = do r <- safeConvert a
safeConvert (r :: ClockTime)
we can now write:
instance Convertible CalendarTime POSIXTime where
safeConvert = convertVia (undefined::ClockTime)
which does the same thing -- converts a CalendarTime to a ClockTime, then a
ClockTime to a POSIXTime, both using existing Convertible instances.
|
|
|
Produced by Haddock version 2.7.2 |