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 # |
Instance details Methods safeConvert :: Char -> ConvertResult Int #
Convertible Char Int8 # |
Instance details Methods safeConvert :: Char -> ConvertResult Int8 #
Convertible Char Int16 # |
Instance details Methods safeConvert :: Char -> ConvertResult Int16 #
Convertible Char Int32 # |
Instance details Methods safeConvert :: Char -> ConvertResult Int32 #
Convertible Char Int64 # |
Instance details Methods safeConvert :: Char -> ConvertResult Int64 #
Convertible Char Integer # |
Instance details Methods safeConvert :: Char -> ConvertResult Integer #
Convertible Char Word # |
Instance details Methods safeConvert :: Char -> ConvertResult Word #
Convertible Char Word8 # |
Instance details Methods safeConvert :: Char -> ConvertResult Word8 #
Convertible Char Word16 # |
Instance details Methods safeConvert :: Char -> ConvertResult Word16 #
Convertible Char Word32 # |
Instance details Methods safeConvert :: Char -> ConvertResult Word32 #
Convertible Char Word64 # |
Instance details Methods safeConvert :: Char -> ConvertResult Word64 #
Convertible Double Float # |
Instance details Methods safeConvert :: Double -> ConvertResult Float #
Convertible Double Int # |
Instance details Methods safeConvert :: Double -> ConvertResult Int #
Convertible Double Int8 # |
Instance details Methods safeConvert :: Double -> ConvertResult Int8 #
Convertible Double Int16 # |
Instance details Methods safeConvert :: Double -> ConvertResult Int16 #
Convertible Double Int32 # |
Instance details Methods safeConvert :: Double -> ConvertResult Int32 #
Convertible Double Int64 # |
Instance details Methods safeConvert :: Double -> ConvertResult Int64 #
Convertible Double Integer # |
Instance details Methods safeConvert :: Double -> ConvertResult Integer #
Convertible Double Rational # |
Instance details Methods safeConvert :: Double -> ConvertResult Rational #
Convertible Double Word # |
Instance details Methods safeConvert :: Double -> ConvertResult Word #
Convertible Double Word8 # |
Instance details Methods safeConvert :: Double -> ConvertResult Word8 #
Convertible Double Word16 # |
Instance details Methods safeConvert :: Double -> ConvertResult Word16 #
Convertible Double Word32 # |
Instance details Methods safeConvert :: Double -> ConvertResult Word32 #
Convertible Double Word64 # |
Instance details Methods safeConvert :: Double -> ConvertResult Word64 #
Convertible Float Double # |
Instance details Methods safeConvert :: Float -> ConvertResult Double #
Convertible Float Int # |
Instance details Methods safeConvert :: Float -> ConvertResult Int #
Convertible Float Int8 # |
Instance details Methods safeConvert :: Float -> ConvertResult Int8 #
Convertible Float Int16 # |
Instance details Methods safeConvert :: Float -> ConvertResult Int16 #
Convertible Float Int32 # |
Instance details Methods safeConvert :: Float -> ConvertResult Int32 #
Convertible Float Int64 # |
Instance details Methods safeConvert :: Float -> ConvertResult Int64 #
Convertible Float Integer # |
Instance details Methods safeConvert :: Float -> ConvertResult Integer #
Convertible Float Rational # |
Instance details Methods safeConvert :: Float -> ConvertResult Rational #
Convertible Float Word # |
Instance details Methods safeConvert :: Float -> ConvertResult Word #
Convertible Float Word8 # |
Instance details Methods safeConvert :: Float -> ConvertResult Word8 #
Convertible Float Word16 # |
Instance details Methods safeConvert :: Float -> ConvertResult Word16 #
Convertible Float Word32 # |
Instance details Methods safeConvert :: Float -> ConvertResult Word32 #
Convertible Float Word64 # |
Instance details Methods safeConvert :: Float -> ConvertResult Word64 #
Convertible Int Char # |
Instance details Methods safeConvert :: Int -> ConvertResult Char #
Convertible Int Double # |
Instance details Methods safeConvert :: Int -> ConvertResult Double #
Convertible Int Float # |
Instance details Methods safeConvert :: Int -> ConvertResult Float #
Convertible Int Int8 # |
Instance details Methods safeConvert :: Int -> ConvertResult Int8 #
Convertible Int Int16 # |
Instance details Methods safeConvert :: Int -> ConvertResult Int16 #
Convertible Int Int32 # |
Instance details Methods safeConvert :: Int -> ConvertResult Int32 #
Convertible Int Int64 # |
Instance details Methods safeConvert :: Int -> ConvertResult Int64 #
Convertible Int Integer # |
Instance details Methods safeConvert :: Int -> ConvertResult Integer #
Convertible Int Rational # |
Instance details Methods safeConvert :: Int -> ConvertResult Rational #
Convertible Int Word # |
Instance details Methods safeConvert :: Int -> ConvertResult Word #
Convertible Int Word8 # |
Instance details Methods safeConvert :: Int -> ConvertResult Word8 #
Convertible Int Word16 # |
Instance details Methods safeConvert :: Int -> ConvertResult Word16 #
Convertible Int Word32 # |
Instance details Methods safeConvert :: Int -> ConvertResult Word32 #
Convertible Int Word64 # |
Instance details Methods safeConvert :: Int -> ConvertResult Word64 #
Convertible Int8 Char # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Char #
Convertible Int8 Double # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Double #
Convertible Int8 Float # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Float #
Convertible Int8 Int # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Int #
Convertible Int8 Int16 # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Int16 #
Convertible Int8 Int32 # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Int32 #
Convertible Int8 Int64 # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Int64 #
Convertible Int8 Integer # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Integer #
Convertible Int8 Rational # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Rational #
Convertible Int8 Word # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Word #
Convertible Int8 Word8 # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Word8 #
Convertible Int8 Word16 # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Word16 #
Convertible Int8 Word32 # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Word32 #
Convertible Int8 Word64 # |
Instance details Methods safeConvert :: Int8 -> ConvertResult Word64 #
Convertible Int16 Char # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Char #
Convertible Int16 Double # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Double #
Convertible Int16 Float # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Float #
Convertible Int16 Int # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Int #
Convertible Int16 Int8 # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Int8 #
Convertible Int16 Int32 # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Int32 #
Convertible Int16 Int64 # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Int64 #
Convertible Int16 Integer # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Integer #
Convertible Int16 Rational # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Rational #
Convertible Int16 Word # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Word #
Convertible Int16 Word8 # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Word8 #
Convertible Int16 Word16 # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Word16 #
Convertible Int16 Word32 # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Word32 #
Convertible Int16 Word64 # |
Instance details Methods safeConvert :: Int16 -> ConvertResult Word64 #
Convertible Int32 Char # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Char #
Convertible Int32 Double # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Double #
Convertible Int32 Float # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Float #
Convertible Int32 Int # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Int #
Convertible Int32 Int8 # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Int8 #
Convertible Int32 Int16 # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Int16 #
Convertible Int32 Int64 # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Int64 #
Convertible Int32 Integer # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Integer #
Convertible Int32 Rational # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Rational #
Convertible Int32 Word # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Word #
Convertible Int32 Word8 # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Word8 #
Convertible Int32 Word16 # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Word16 #
Convertible Int32 Word32 # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Word32 #
Convertible Int32 Word64 # |
Instance details Methods safeConvert :: Int32 -> ConvertResult Word64 #
Convertible Int64 Char # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Char #
Convertible Int64 Double # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Double #
Convertible Int64 Float # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Float #
Convertible Int64 Int # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Int #
Convertible Int64 Int8 # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Int8 #
Convertible Int64 Int16 # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Int16 #
Convertible Int64 Int32 # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Int32 #
Convertible Int64 Integer # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Integer #
Convertible Int64 Rational # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Rational #
Convertible Int64 Word # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Word #
Convertible Int64 Word8 # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Word8 #
Convertible Int64 Word16 # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Word16 #
Convertible Int64 Word32 # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Word32 #
Convertible Int64 Word64 # |
Instance details Methods safeConvert :: Int64 -> ConvertResult Word64 #
Convertible Integer Char # |
Instance details Methods safeConvert :: Integer -> ConvertResult Char #
Convertible Integer Double # |
Instance details Methods safeConvert :: Integer -> ConvertResult Double #
Convertible Integer Float # |
Instance details Methods safeConvert :: Integer -> ConvertResult Float #
Convertible Integer Int # |
Instance details Methods safeConvert :: Integer -> ConvertResult Int #
Convertible Integer Int8 # |
Instance details Methods safeConvert :: Integer -> ConvertResult Int8 #
Convertible Integer Int16 # |
Instance details Methods safeConvert :: Integer -> ConvertResult Int16 #
Convertible Integer Int32 # |
Instance details Methods safeConvert :: Integer -> ConvertResult Int32 #
Convertible Integer Int64 # |
Instance details Methods safeConvert :: Integer -> ConvertResult Int64 #
Convertible Integer Integer # |
Instance details Methods safeConvert :: Integer -> ConvertResult Integer #
Convertible Integer Rational # |
Instance details Methods safeConvert :: Integer -> ConvertResult Rational #
Convertible Integer Word # |
Instance details Methods safeConvert :: Integer -> ConvertResult Word #
Convertible Integer Word8 # |
Instance details Methods safeConvert :: Integer -> ConvertResult Word8 #
Convertible Integer Word16 # |
Instance details Methods safeConvert :: Integer -> ConvertResult Word16 #
Convertible Integer Word32 # |
Instance details Methods safeConvert :: Integer -> ConvertResult Word32 #
Convertible Integer Word64 # |
Instance details Methods safeConvert :: Integer -> ConvertResult Word64 #
Convertible Rational Double # |
Instance details Methods safeConvert :: Rational -> ConvertResult Double #
Convertible Rational Float # |
Instance details Methods safeConvert :: Rational -> ConvertResult Float #
Convertible Rational Int # |
Instance details Methods safeConvert :: Rational -> ConvertResult Int #
Convertible Rational Int8 # |
Instance details Methods safeConvert :: Rational -> ConvertResult Int8 #
Convertible Rational Int16 # |
Instance details Methods safeConvert :: Rational -> ConvertResult Int16 #
Convertible Rational Int32 # |
Instance details Methods safeConvert :: Rational -> ConvertResult Int32 #
Convertible Rational Int64 # |
Instance details Methods safeConvert :: Rational -> ConvertResult Int64 #
Convertible Rational Integer # |
Instance details Methods safeConvert :: Rational -> ConvertResult Integer #
Convertible Rational Word # |
Instance details Methods safeConvert :: Rational -> ConvertResult Word #
Convertible Rational Word8 # |
Instance details Methods safeConvert :: Rational -> ConvertResult Word8 #
Convertible Rational Word16 # |
Instance details Methods safeConvert :: Rational -> ConvertResult Word16 #
Convertible Rational Word32 # |
Instance details Methods safeConvert :: Rational -> ConvertResult Word32 #
Convertible Rational Word64 # |
Instance details Methods safeConvert :: Rational -> ConvertResult Word64 #
Convertible Word Char # |
Instance details Methods safeConvert :: Word -> ConvertResult Char #
Convertible Word Double # |
Instance details Methods safeConvert :: Word -> ConvertResult Double #
Convertible Word Float # |
Instance details Methods safeConvert :: Word -> ConvertResult Float #
Convertible Word Int # |
Instance details Methods safeConvert :: Word -> ConvertResult Int #
Convertible Word Int8 # |
Instance details Methods safeConvert :: Word -> ConvertResult Int8 #
Convertible Word Int16 # |
Instance details Methods safeConvert :: Word -> ConvertResult Int16 #
Convertible Word Int32 # |
Instance details Methods safeConvert :: Word -> ConvertResult Int32 #
Convertible Word Int64 # |
Instance details Methods safeConvert :: Word -> ConvertResult Int64 #
Convertible Word Integer # |
Instance details Methods safeConvert :: Word -> ConvertResult Integer #
Convertible Word Rational # |
Instance details Methods safeConvert :: Word -> ConvertResult Rational #
Convertible Word Word8 # |
Instance details Methods safeConvert :: Word -> ConvertResult Word8 #
Convertible Word Word16 # |
Instance details Methods safeConvert :: Word -> ConvertResult Word16 #
Convertible Word Word32 # |
Instance details Methods safeConvert :: Word -> ConvertResult Word32 #
Convertible Word Word64 # |
Instance details Methods safeConvert :: Word -> ConvertResult Word64 #
Convertible Word8 Char # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Char #
Convertible Word8 Double # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Double #
Convertible Word8 Float # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Float #
Convertible Word8 Int # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Int #
Convertible Word8 Int8 # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Int8 #
Convertible Word8 Int16 # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Int16 #
Convertible Word8 Int32 # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Int32 #
Convertible Word8 Int64 # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Int64 #
Convertible Word8 Integer # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Integer #
Convertible Word8 Rational # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Rational #
Convertible Word8 Word # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Word #
Convertible Word8 Word16 # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Word16 #
Convertible Word8 Word32 # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Word32 #
Convertible Word8 Word64 # |
Instance details Methods safeConvert :: Word8 -> ConvertResult Word64 #
Convertible Word16 Char # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Char #
Convertible Word16 Double # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Double #
Convertible Word16 Float # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Float #
Convertible Word16 Int # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Int #
Convertible Word16 Int8 # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Int8 #
Convertible Word16 Int16 # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Int16 #
Convertible Word16 Int32 # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Int32 #
Convertible Word16 Int64 # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Int64 #
Convertible Word16 Integer # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Integer #
Convertible Word16 Rational # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Rational #
Convertible Word16 Word # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Word #
Convertible Word16 Word8 # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Word8 #
Convertible Word16 Word32 # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Word32 #
Convertible Word16 Word64 # |
Instance details Methods safeConvert :: Word16 -> ConvertResult Word64 #
Convertible Word32 Char # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Char #
Convertible Word32 Double # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Double #
Convertible Word32 Float # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Float #
Convertible Word32 Int # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Int #
Convertible Word32 Int8 # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Int8 #
Convertible Word32 Int16 # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Int16 #
Convertible Word32 Int32 # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Int32 #
Convertible Word32 Int64 # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Int64 #
Convertible Word32 Integer # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Integer #
Convertible Word32 Rational # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Rational #
Convertible Word32 Word # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Word #
Convertible Word32 Word8 # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Word8 #
Convertible Word32 Word16 # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Word16 #
Convertible Word32 Word64 # |
Instance details Methods safeConvert :: Word32 -> ConvertResult Word64 #
Convertible Word64 Char # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Char #
Convertible Word64 Double # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Double #
Convertible Word64 Float # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Float #
Convertible Word64 Int # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Int #
Convertible Word64 Int8 # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Int8 #
Convertible Word64 Int16 # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Int16 #
Convertible Word64 Int32 # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Int32 #
Convertible Word64 Int64 # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Int64 #
Convertible Word64 Integer # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Integer #
Convertible Word64 Rational # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Rational #
Convertible Word64 Word # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Word #
Convertible Word64 Word8 # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Word8 #
Convertible Word64 Word16 # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Word16 #
Convertible Word64 Word32 # |
Instance details Methods safeConvert :: Word64 -> ConvertResult Word32 #