Data.Convertible.Instances.Num

convertible-1.1.1.0: Typeclasses and instances for converting between types

Copyright | Copyright (C) 2009-2011 John Goerzen
License | BSD3
Maintainer | John Goerzen <jgoerzen@complete.org>
Stability | provisional
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Data.Convertible.Instances.Num

Contents

- Orphan instances

Description

Numeric instances for Convertible.

Copyright (C) 2009-2011 John Goerzen jgoerzen@complete.org

All rights reserved.

For license and copyright information, see the file LICENSE

These instances perform conversion between numeric types such as Double, Int, Integer, Rational, and the like. Here are some notes about the conversion process:

Conversions from floating-point types such as Double to integral types are done via the `truncate` function. This is a somewhat arbitrary decision; if you need different behavior, you will have to write your own instance or manually perform the conversion.

All conversions perform bounds checking. If a value is too large for its destination type, you will get a `ConvertError` informing you of this. Note that this behavior differs from functions in the Haskell standard libraries, which will perform the conversion without error, but give you garbage in the end.

Conversions do not perform precision checking; loss of precision is implied with certain conversions (for instance, Double to Float) and this is not an error.

# Orphan instances

Convertible Char Int # |
Methods safeConvert :: Char -> ConvertResult Int #
Convertible Char Int8 # |
Methods safeConvert :: Char -> ConvertResult Int8 #
Convertible Char Int16 # |
Methods safeConvert :: Char -> ConvertResult Int16 #
Convertible Char Int32 # |
Methods safeConvert :: Char -> ConvertResult Int32 #
Convertible Char Int64 # |
Methods safeConvert :: Char -> ConvertResult Int64 #
Convertible Char Integer # |
Methods safeConvert :: Char -> ConvertResult Integer #
Convertible Char Word # |
Methods safeConvert :: Char -> ConvertResult Word #
Convertible Char Word8 # |
Methods safeConvert :: Char -> ConvertResult Word8 #
Convertible Char Word16 # |
Methods safeConvert :: Char -> ConvertResult Word16 #
Convertible Char Word32 # |
Methods safeConvert :: Char -> ConvertResult Word32 #
Convertible Char Word64 # |
Methods safeConvert :: Char -> ConvertResult Word64 #
Convertible Double Float # |
Methods safeConvert :: Double -> ConvertResult Float #
Convertible Double Int # |
Methods safeConvert :: Double -> ConvertResult Int #
Convertible Double Int8 # |
Methods safeConvert :: Double -> ConvertResult Int8 #
Convertible Double Int16 # |
Methods safeConvert :: Double -> ConvertResult Int16 #
Convertible Double Int32 # |
Methods safeConvert :: Double -> ConvertResult Int32 #
Convertible Double Int64 # |
Methods safeConvert :: Double -> ConvertResult Int64 #
Convertible Double Integer # |
Methods safeConvert :: Double -> ConvertResult Integer #
Convertible Double Rational # |
Methods safeConvert :: Double -> ConvertResult Rational #
Convertible Double Word # |
Methods safeConvert :: Double -> ConvertResult Word #
Convertible Double Word8 # |
Methods safeConvert :: Double -> ConvertResult Word8 #
Convertible Double Word16 # |
Methods safeConvert :: Double -> ConvertResult Word16 #
Convertible Double Word32 # |
Methods safeConvert :: Double -> ConvertResult Word32 #
Convertible Double Word64 # |
Methods safeConvert :: Double -> ConvertResult Word64 #
Convertible Float Double # |
Methods safeConvert :: Float -> ConvertResult Double #
Convertible Float Int # |
Methods safeConvert :: Float -> ConvertResult Int #
Convertible Float Int8 # |
Methods safeConvert :: Float -> ConvertResult Int8 #
Convertible Float Int16 # |
Methods safeConvert :: Float -> ConvertResult Int16 #
Convertible Float Int32 # |
Methods safeConvert :: Float -> ConvertResult Int32 #
Convertible Float Int64 # |
Methods safeConvert :: Float -> ConvertResult Int64 #
Convertible Float Integer # |
Methods safeConvert :: Float -> ConvertResult Integer #
Convertible Float Rational # |
Methods safeConvert :: Float -> ConvertResult Rational #
Convertible Float Word # |
Methods safeConvert :: Float -> ConvertResult Word #
Convertible Float Word8 # |
Methods safeConvert :: Float -> ConvertResult Word8 #
Convertible Float Word16 # |
Methods safeConvert :: Float -> ConvertResult Word16 #
Convertible Float Word32 # |
Methods safeConvert :: Float -> ConvertResult Word32 #
Convertible Float Word64 # |
Methods safeConvert :: Float -> ConvertResult Word64 #
Convertible Int Char # |
Methods safeConvert :: Int -> ConvertResult Char #
Convertible Int Double # |
Methods safeConvert :: Int -> ConvertResult Double #
Convertible Int Float # |
Methods safeConvert :: Int -> ConvertResult Float #
Convertible Int Int8 # |
Methods safeConvert :: Int -> ConvertResult Int8 #
Convertible Int Int16 # |
Methods safeConvert :: Int -> ConvertResult Int16 #
Convertible Int Int32 # |
Methods safeConvert :: Int -> ConvertResult Int32 #
Convertible Int Int64 # |
Methods safeConvert :: Int -> ConvertResult Int64 #
Convertible Int Integer # |
Methods safeConvert :: Int -> ConvertResult Integer #
Convertible Int Rational # |
Methods safeConvert :: Int -> ConvertResult Rational #
Convertible Int Word # |
Methods safeConvert :: Int -> ConvertResult Word #
Convertible Int Word8 # |
Methods safeConvert :: Int -> ConvertResult Word8 #
Convertible Int Word16 # |
Methods safeConvert :: Int -> ConvertResult Word16 #
Convertible Int Word32 # |
Methods safeConvert :: Int -> ConvertResult Word32 #
Convertible Int Word64 # |
Methods safeConvert :: Int -> ConvertResult Word64 #
Convertible Int8 Char # |
Methods safeConvert :: Int8 -> ConvertResult Char #
Convertible Int8 Double # |
Methods safeConvert :: Int8 -> ConvertResult Double #
Convertible Int8 Float # |
Methods safeConvert :: Int8 -> ConvertResult Float #
Convertible Int8 Int # |
Methods safeConvert :: Int8 -> ConvertResult Int #
Convertible Int8 Int16 # |
Methods safeConvert :: Int8 -> ConvertResult Int16 #
Convertible Int8 Int32 # |
Methods safeConvert :: Int8 -> ConvertResult Int32 #
Convertible Int8 Int64 # |
Methods safeConvert :: Int8 -> ConvertResult Int64 #
Convertible Int8 Integer # |
Methods safeConvert :: Int8 -> ConvertResult Integer #
Convertible Int8 Rational # |
Methods safeConvert :: Int8 -> ConvertResult Rational #
Convertible Int8 Word # |
Methods safeConvert :: Int8 -> ConvertResult Word #
Convertible Int8 Word8 # |
Methods safeConvert :: Int8 -> ConvertResult Word8 #
Convertible Int8 Word16 # |
Methods safeConvert :: Int8 -> ConvertResult Word16 #
Convertible Int8 Word32 # |
Methods safeConvert :: Int8 -> ConvertResult Word32 #
Convertible Int8 Word64 # |
Methods safeConvert :: Int8 -> ConvertResult Word64 #
Convertible Int16 Char # |
Methods safeConvert :: Int16 -> ConvertResult Char #
Convertible Int16 Double # |
Methods safeConvert :: Int16 -> ConvertResult Double #
Convertible Int16 Float # |
Methods safeConvert :: Int16 -> ConvertResult Float #
Convertible Int16 Int # |
Methods safeConvert :: Int16 -> ConvertResult Int #
Convertible Int16 Int8 # |
Methods safeConvert :: Int16 -> ConvertResult Int8 #
Convertible Int16 Int32 # |
Methods safeConvert :: Int16 -> ConvertResult Int32 #
Convertible Int16 Int64 # |
Methods safeConvert :: Int16 -> ConvertResult Int64 #
Convertible Int16 Integer # |
Methods safeConvert :: Int16 -> ConvertResult Integer #
Convertible Int16 Rational # |
Methods safeConvert :: Int16 -> ConvertResult Rational #
Convertible Int16 Word # |
Methods safeConvert :: Int16 -> ConvertResult Word #
Convertible Int16 Word8 # |
Methods safeConvert :: Int16 -> ConvertResult Word8 #
Convertible Int16 Word16 # |
Methods safeConvert :: Int16 -> ConvertResult Word16 #
Convertible Int16 Word32 # |
Methods safeConvert :: Int16 -> ConvertResult Word32 #
Convertible Int16 Word64 # |
Methods safeConvert :: Int16 -> ConvertResult Word64 #
Convertible Int32 Char # |
Methods safeConvert :: Int32 -> ConvertResult Char #
Convertible Int32 Double # |
Methods safeConvert :: Int32 -> ConvertResult Double #
Convertible Int32 Float # |
Methods safeConvert :: Int32 -> ConvertResult Float #
Convertible Int32 Int # |
Methods safeConvert :: Int32 -> ConvertResult Int #
Convertible Int32 Int8 # |
Methods safeConvert :: Int32 -> ConvertResult Int8 #
Convertible Int32 Int16 # |
Methods safeConvert :: Int32 -> ConvertResult Int16 #
Convertible Int32 Int64 # |
Methods safeConvert :: Int32 -> ConvertResult Int64 #
Convertible Int32 Integer # |
Methods safeConvert :: Int32 -> ConvertResult Integer #
Convertible Int32 Rational # |
Methods safeConvert :: Int32 -> ConvertResult Rational #
Convertible Int32 Word # |
Methods safeConvert :: Int32 -> ConvertResult Word #
Convertible Int32 Word8 # |
Methods safeConvert :: Int32 -> ConvertResult Word8 #
Convertible Int32 Word16 # |
Methods safeConvert :: Int32 -> ConvertResult Word16 #
Convertible Int32 Word32 # |
Methods safeConvert :: Int32 -> ConvertResult Word32 #
Convertible Int32 Word64 # |
Methods safeConvert :: Int32 -> ConvertResult Word64 #
Convertible Int64 Char # |
Methods safeConvert :: Int64 -> ConvertResult Char #
Convertible Int64 Double # |
Methods safeConvert :: Int64 -> ConvertResult Double #
Convertible Int64 Float # |
Methods safeConvert :: Int64 -> ConvertResult Float #
Convertible Int64 Int # |
Methods safeConvert :: Int64 -> ConvertResult Int #
Convertible Int64 Int8 # |
Methods safeConvert :: Int64 -> ConvertResult Int8 #
Convertible Int64 Int16 # |
Methods safeConvert :: Int64 -> ConvertResult Int16 #
Convertible Int64 Int32 # |
Methods safeConvert :: Int64 -> ConvertResult Int32 #
Convertible Int64 Integer # |
Methods safeConvert :: Int64 -> ConvertResult Integer #
Convertible Int64 Rational # |
Methods safeConvert :: Int64 -> ConvertResult Rational #
Convertible Int64 Word # |
Methods safeConvert :: Int64 -> ConvertResult Word #
Convertible Int64 Word8 # |
Methods safeConvert :: Int64 -> ConvertResult Word8 #
Convertible Int64 Word16 # |
Methods safeConvert :: Int64 -> ConvertResult Word16 #
Convertible Int64 Word32 # |
Methods safeConvert :: Int64 -> ConvertResult Word32 #
Convertible Int64 Word64 # |
Methods safeConvert :: Int64 -> ConvertResult Word64 #
Convertible Integer Char # |
Methods safeConvert :: Integer -> ConvertResult Char #
Convertible Integer Double # |
Methods safeConvert :: Integer -> ConvertResult Double #
Convertible Integer Float # |
Methods safeConvert :: Integer -> ConvertResult Float #
Convertible Integer Int # |
Methods safeConvert :: Integer -> ConvertResult Int #
Convertible Integer Int8 # |
Methods safeConvert :: Integer -> ConvertResult Int8 #
Convertible Integer Int16 # |
Methods safeConvert :: Integer -> ConvertResult Int16 #
Convertible Integer Int32 # |
Methods safeConvert :: Integer -> ConvertResult Int32 #
Convertible Integer Int64 # |
Methods safeConvert :: Integer -> ConvertResult Int64 #
Convertible Integer Integer # |
Methods safeConvert :: Integer -> ConvertResult Integer #
Convertible Integer Rational # |
Methods safeConvert :: Integer -> ConvertResult Rational #
Convertible Integer Word # |
Methods safeConvert :: Integer -> ConvertResult Word #
Convertible Integer Word8 # |
Methods safeConvert :: Integer -> ConvertResult Word8 #
Convertible Integer Word16 # |
Methods safeConvert :: Integer -> ConvertResult Word16 #
Convertible Integer Word32 # |
Methods safeConvert :: Integer -> ConvertResult Word32 #
Convertible Integer Word64 # |
Methods safeConvert :: Integer -> ConvertResult Word64 #
Convertible Rational Double # |
Methods safeConvert :: Rational -> ConvertResult Double #
Convertible Rational Float # |
Methods safeConvert :: Rational -> ConvertResult Float #
Convertible Rational Int # |
Methods safeConvert :: Rational -> ConvertResult Int #
Convertible Rational Int8 # |
Methods safeConvert :: Rational -> ConvertResult Int8 #
Convertible Rational Int16 # |
Methods safeConvert :: Rational -> ConvertResult Int16 #
Convertible Rational Int32 # |
Methods safeConvert :: Rational -> ConvertResult Int32 #
Convertible Rational Int64 # |
Methods safeConvert :: Rational -> ConvertResult Int64 #
Convertible Rational Integer # |
Methods safeConvert :: Rational -> ConvertResult Integer #
Convertible Rational Word # |
Methods safeConvert :: Rational -> ConvertResult Word #
Convertible Rational Word8 # |
Methods safeConvert :: Rational -> ConvertResult Word8 #
Convertible Rational Word16 # |
Methods safeConvert :: Rational -> ConvertResult Word16 #
Convertible Rational Word32 # |
Methods safeConvert :: Rational -> ConvertResult Word32 #
Convertible Rational Word64 # |
Methods safeConvert :: Rational -> ConvertResult Word64 #
Convertible Word Char # |
Methods safeConvert :: Word -> ConvertResult Char #
Convertible Word Double # |
Methods safeConvert :: Word -> ConvertResult Double #
Convertible Word Float # |
Methods safeConvert :: Word -> ConvertResult Float #
Convertible Word Int # |
Methods safeConvert :: Word -> ConvertResult Int #
Convertible Word Int8 # |
Methods safeConvert :: Word -> ConvertResult Int8 #
Convertible Word Int16 # |
Methods safeConvert :: Word -> ConvertResult Int16 #
Convertible Word Int32 # |
Methods safeConvert :: Word -> ConvertResult Int32 #
Convertible Word Int64 # |
Methods safeConvert :: Word -> ConvertResult Int64 #
Convertible Word Integer # |
Methods safeConvert :: Word -> ConvertResult Integer #
Convertible Word Rational # |
Methods safeConvert :: Word -> ConvertResult Rational #
Convertible Word Word8 # |
Methods safeConvert :: Word -> ConvertResult Word8 #
Convertible Word Word16 # |
Methods safeConvert :: Word -> ConvertResult Word16 #
Convertible Word Word32 # |
Methods safeConvert :: Word -> ConvertResult Word32 #
Convertible Word Word64 # |
Methods safeConvert :: Word -> ConvertResult Word64 #
Convertible Word8 Char # |
Methods safeConvert :: Word8 -> ConvertResult Char #
Convertible Word8 Double # |
Methods safeConvert :: Word8 -> ConvertResult Double #
Convertible Word8 Float # |
Methods safeConvert :: Word8 -> ConvertResult Float #
Convertible Word8 Int # |
Methods safeConvert :: Word8 -> ConvertResult Int #
Convertible Word8 Int8 # |
Methods safeConvert :: Word8 -> ConvertResult Int8 #
Convertible Word8 Int16 # |
Methods safeConvert :: Word8 -> ConvertResult Int16 #
Convertible Word8 Int32 # |
Methods safeConvert :: Word8 -> ConvertResult Int32 #
Convertible Word8 Int64 # |
Methods safeConvert :: Word8 -> ConvertResult Int64 #
Convertible Word8 Integer # |
Methods safeConvert :: Word8 -> ConvertResult Integer #
Convertible Word8 Rational # |
Methods safeConvert :: Word8 -> ConvertResult Rational #
Convertible Word8 Word # |
Methods safeConvert :: Word8 -> ConvertResult Word #
Convertible Word8 Word16 # |
Methods safeConvert :: Word8 -> ConvertResult Word16 #
Convertible Word8 Word32 # |
Methods safeConvert :: Word8 -> ConvertResult Word32 #
Convertible Word8 Word64 # |
Methods safeConvert :: Word8 -> ConvertResult Word64 #
Convertible Word16 Char # |
Methods safeConvert :: Word16 -> ConvertResult Char #
Convertible Word16 Double # |
Methods safeConvert :: Word16 -> ConvertResult Double #
Convertible Word16 Float # |
Methods safeConvert :: Word16 -> ConvertResult Float #
Convertible Word16 Int # |
Methods safeConvert :: Word16 -> ConvertResult Int #
Convertible Word16 Int8 # |
Methods safeConvert :: Word16 -> ConvertResult Int8 #
Convertible Word16 Int16 # |
Methods safeConvert :: Word16 -> ConvertResult Int16 #
Convertible Word16 Int32 # |
Methods safeConvert :: Word16 -> ConvertResult Int32 #
Convertible Word16 Int64 # |
Methods safeConvert :: Word16 -> ConvertResult Int64 #
Convertible Word16 Integer # |
Methods safeConvert :: Word16 -> ConvertResult Integer #
Convertible Word16 Rational # |
Methods safeConvert :: Word16 -> ConvertResult Rational #
Convertible Word16 Word # |
Methods safeConvert :: Word16 -> ConvertResult Word #
Convertible Word16 Word8 # |
Methods safeConvert :: Word16 -> ConvertResult Word8 #
Convertible Word16 Word32 # |
Methods safeConvert :: Word16 -> ConvertResult Word32 #
Convertible Word16 Word64 # |
Methods safeConvert :: Word16 -> ConvertResult Word64 #
Convertible Word32 Char # |
Methods safeConvert :: Word32 -> ConvertResult Char #
Convertible Word32 Double # |
Methods safeConvert :: Word32 -> ConvertResult Double #
Convertible Word32 Float # |
Methods safeConvert :: Word32 -> ConvertResult Float #
Convertible Word32 Int # |
Methods safeConvert :: Word32 -> ConvertResult Int #
Convertible Word32 Int8 # |
Methods safeConvert :: Word32 -> ConvertResult Int8 #
Convertible Word32 Int16 # |
Methods safeConvert :: Word32 -> ConvertResult Int16 #
Convertible Word32 Int32 # |
Methods safeConvert :: Word32 -> ConvertResult Int32 #
Convertible Word32 Int64 # |
Methods safeConvert :: Word32 -> ConvertResult Int64 #
Convertible Word32 Integer # |
Methods safeConvert :: Word32 -> ConvertResult Integer #
Convertible Word32 Rational # |
Methods safeConvert :: Word32 -> ConvertResult Rational #
Convertible Word32 Word # |
Methods safeConvert :: Word32 -> ConvertResult Word #
Convertible Word32 Word8 # |
Methods safeConvert :: Word32 -> ConvertResult Word8 #
Convertible Word32 Word16 # |
Methods safeConvert :: Word32 -> ConvertResult Word16 #
Convertible Word32 Word64 # |
Methods safeConvert :: Word32 -> ConvertResult Word64 #
Convertible Word64 Char # |
Methods safeConvert :: Word64 -> ConvertResult Char #
Convertible Word64 Double # |
Methods safeConvert :: Word64 -> ConvertResult Double #
Convertible Word64 Float # |
Methods safeConvert :: Word64 -> ConvertResult Float #
Convertible Word64 Int # |
Methods safeConvert :: Word64 -> ConvertResult Int #
Convertible Word64 Int8 # |
Methods safeConvert :: Word64 -> ConvertResult Int8 #
Convertible Word64 Int16 # |
Methods safeConvert :: Word64 -> ConvertResult Int16 #
Convertible Word64 Int32 # |
Methods safeConvert :: Word64 -> ConvertResult Int32 #
Convertible Word64 Int64 # |
Methods safeConvert :: Word64 -> ConvertResult Int64 #
Convertible Word64 Integer # |
Methods safeConvert :: Word64 -> ConvertResult Integer #
Convertible Word64 Rational # |
Methods safeConvert :: Word64 -> ConvertResult Rational #
Convertible Word64 Word # |
Methods safeConvert :: Word64 -> ConvertResult Word #
Convertible Word64 Word8 # |
Methods safeConvert :: Word64 -> ConvertResult Word8 #
Convertible Word64 Word16 # |
Methods safeConvert :: Word64 -> ConvertResult Word16 #
Convertible Word64 Word32 # |
Methods safeConvert :: Word64 -> ConvertResult Word32 #