{-
 - Copyright (C) 2009 Nick Bowler.
 -
 - License BSD2:  2-clause BSD license.  See LICENSE for full terms.
 - This is free software: you are free to change and redistribute it.
 - There is NO WARRANTY, to the extent permitted by law.
 -}

-- | Top level module for alternative floating point support.
module Data.Floating (
    Double, Float,
    module Data.Floating.Classes,
    module Data.Floating,
    toFloating
) where

import Prelude hiding (RealFloat(..), Double, Float)
import Data.Floating.Classes
import Data.Floating.Instances
import Data.Floating.Double
import Data.Floating.Types

import Control.Monad

isInfinite :: RealFloat a => a -> Bool
isInfinite = (== FPInfinite) . classify

isNaN :: RealFloat a => a -> Bool
isNaN = (== FPNaN) . classify

isNormal :: RealFloat a => a -> Bool
isNormal = (== FPNormal) . classify

isSubNormal :: RealFloat a => a -> Bool
isSubNormal = (== FPSubNormal) . classify

isFinite :: RealFloat a => a -> Bool
isFinite = not . liftM2 (||) isInfinite isNaN

isNegativeZero :: RealFloat a => a -> Bool
isNegativeZero = liftM2 (&&) ((== FPZero) . classify) ((== (-1)) . signum)