{-|
    Module      :  Numeric.CatchingExceptions
    Description :  Wrapper type tracking numerical exceptions
    Copyright   :  (c) Michal Konecny
    License     :  BSD3

    Maintainer  :  mikkonecny@gmail.com
    Stability   :  experimental
    Portability :  portable

    A wrapper type CatchingNumExceptions that tracks errors such as DivByZero
    instead of throwing an exception.

    For example, using Prelude arithmetic:

    @
        > 1 / 1 :: CatchingNumExceptions Rational
        1 % 1

        > 1 / 0 :: CatchingNumExceptions Rational
        <no value>{![DivByZero]}
    @

    It is currently impossible to catch exceptions for Prelude
    ^ and ^^ in Prelude arithmetic.  The mixed-types-num power operator
    is correctly handled by CatchingNumExceptions:

    @
        > let x = catchingNumExceptions 1 in 1 / x
        1 % 1

        > let x = catchingNumExceptions 1 in 1 / (1 - x)
        <no value>{![DivByZero]}

        > let pi100 = piBallP (prec 100) -- using aern2-mp
        > let x = catchingNumExceptions (pi100 - pi100) in 1 / x
        <no value>{?[DivByZero]}

        > 0 ^ (catchingNumExceptions (-1))
        <no value>{![NumericalException "0^n for n < 0"]}

        > (-1) ^ (catchingNumExceptions (double $ -1/2))
        <no value>{![NumericalException "a^b for negative a and non-integer b (a=-1, b=-0.5)"]}
    @
-}
module Numeric.CatchingExceptions
(
  -- * Representation of numerical errors
  NumericalException(..)
  -- * Numerical wrapper type
  , CatchingNumExceptions(..), catchingNumExceptions
  , numEXC_maybeValue
  , numEXC_certainExceptions
  , numEXC_potentialExceptions
  , addCertainException, addPotentialException
  -- ** auxiliary functions
  , hasCertainException, ifCertainExceptionDie
  , filterNoException
  , gunzip, zipCatchingNumExceptionsWith
  -- * validity checking (eg to avoid Infinity, NaN)
  , CanTestValid(..), testValidity
)

where

-- import Prelude
-- import Numeric.MixedTypes

import Numeric.CatchingExceptions.Type
-- import Numeric.CatchingExceptions.Lifts
import Numeric.CatchingExceptions.Num ()
import Numeric.CatchingExceptions.MixedTypes.Conversions ()
import Numeric.CatchingExceptions.MixedTypes.Comparisons ()
import Numeric.CatchingExceptions.MixedTypes.Ring ()
import Numeric.CatchingExceptions.MixedTypes.Power ()
import Numeric.CatchingExceptions.MixedTypes.Field ()
import Numeric.CatchingExceptions.MixedTypes.Elementary ()
