```{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  Data.Ord
-- Copyright   :  (c) The University of Glasgow 2005
-- License     :  BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer  :  libraries@haskell.org
-- Stability   :  stable
-- Portability :  portable
--
-- Orderings
--
-----------------------------------------------------------------------------

module Data.Ord (
Ord(..),
Ordering(..),
Down(..),
comparing,
clamp,
) where

import Data.Bits (Bits, FiniteBits)
import Foreign.Storable (Storable)
import GHC.Ix (Ix)
import GHC.Base
import GHC.Enum (Bounded(..))
import GHC.Float (Floating, RealFloat)
import GHC.Num
import GHC.Real (Fractional, Real, RealFrac)
import GHC.Show

-- \$setup
-- >>> import Prelude

-- |
-- > comparing p x y = compare (p x) (p y)
--
-- Useful combinator for use in conjunction with the @xxxBy@ family
-- of functions from "Data.List", for example:
--
-- >   ... sortBy (comparing fst) ...
comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering
comparing :: forall a b. Ord a => (b -> a) -> b -> b -> Ordering
comparing b -> a
p b
x b
y = a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (b -> a
p b
x) (b -> a
p b
y)

-- |
-- > clamp (low, high) a = min high (max a low)
--
-- Function for ensursing the value @a@ is within the inclusive bounds given by
-- @low@ and @high@. If it is, @a@ is returned unchanged. The result
-- is otherwise @low@ if @a <= low@, or @high@ if @high <= a@.
--
-- When clamp is used at Double and Float, it has NaN propagating semantics in
-- its second argument. That is, @clamp (l,h) NaN = NaN@, but @clamp (NaN, NaN)
-- x = x@.
--
-- >>> clamp (0, 10) 2
-- 2
--
-- >>> clamp ('a', 'm') 'x'
-- 'm'
clamp :: (Ord a) => (a, a) -> a -> a
clamp :: forall a. Ord a => (a, a) -> a -> a
clamp (a
low, a
high) a
a = a -> a -> a
forall a. Ord a => a -> a -> a
min a
high (a -> a -> a
forall a. Ord a => a -> a -> a
max a
a a
low)

-- | The 'Down' type allows you to reverse sort order conveniently.  A value of type
-- @'Down' a@ contains a value of type @a@ (represented as @'Down' a@).
--
-- If @a@ has an @'Ord'@ instance associated with it then comparing two
-- values thus wrapped will give you the opposite of their normal sort order.
-- This is particularly useful when sorting in generalised list comprehensions,
-- as in: @then sortWith by 'Down' x@.
--
-- >>> compare True False
-- GT
--
-- >>> compare (Down True) (Down False)
-- LT
--
-- If @a@ has a @'Bounded'@ instance then the wrapped instance also respects
-- the reversed ordering by exchanging the values of @'minBound'@ and
-- @'maxBound'@.
--
-- >>> minBound :: Int
-- -9223372036854775808
--
-- >>> minBound :: Down Int
-- Down 9223372036854775807
--
-- All other instances of @'Down' a@ behave as they do for @a@.
--
-- @since 4.6.0.0
newtype Down a = Down
{ forall a. Down a -> a
getDown :: a -- ^ @since 4.14.0.0
}
deriving
( Down a -> Down a -> Bool
(Down a -> Down a -> Bool)
-> (Down a -> Down a -> Bool) -> Eq (Down a)
forall a. Eq a => Down a -> Down a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
\$c== :: forall a. Eq a => Down a -> Down a -> Bool
== :: Down a -> Down a -> Bool
\$c/= :: forall a. Eq a => Down a -> Down a -> Bool
/= :: Down a -> Down a -> Bool
Eq        -- ^ @since 4.6.0.0
, Integer -> Down a
Down a -> Down a
Down a -> Down a -> Down a
(Down a -> Down a -> Down a)
-> (Down a -> Down a -> Down a)
-> (Down a -> Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Integer -> Down a)
-> Num (Down a)
forall a. Num a => Integer -> Down a
forall a. Num a => Down a -> Down a
forall a. Num a => Down a -> Down a -> Down a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
\$c+ :: forall a. Num a => Down a -> Down a -> Down a
+ :: Down a -> Down a -> Down a
\$c- :: forall a. Num a => Down a -> Down a -> Down a
- :: Down a -> Down a -> Down a
\$c* :: forall a. Num a => Down a -> Down a -> Down a
* :: Down a -> Down a -> Down a
\$cnegate :: forall a. Num a => Down a -> Down a
negate :: Down a -> Down a
\$cabs :: forall a. Num a => Down a -> Down a
abs :: Down a -> Down a
\$csignum :: forall a. Num a => Down a -> Down a
signum :: Down a -> Down a
\$cfromInteger :: forall a. Num a => Integer -> Down a
fromInteger :: Integer -> Down a
Num       -- ^ @since 4.11.0.0
, NonEmpty (Down a) -> Down a
Down a -> Down a -> Down a
(Down a -> Down a -> Down a)
-> (NonEmpty (Down a) -> Down a)
-> (forall b. Integral b => b -> Down a -> Down a)
-> Semigroup (Down a)
forall b. Integral b => b -> Down a -> Down a
forall a. Semigroup a => NonEmpty (Down a) -> Down a
forall a. Semigroup a => Down a -> Down a -> Down a
forall a b. (Semigroup a, Integral b) => b -> Down a -> Down a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
\$c<> :: forall a. Semigroup a => Down a -> Down a -> Down a
<> :: Down a -> Down a -> Down a
\$csconcat :: forall a. Semigroup a => NonEmpty (Down a) -> Down a
sconcat :: NonEmpty (Down a) -> Down a
\$cstimes :: forall a b. (Semigroup a, Integral b) => b -> Down a -> Down a
stimes :: forall b. Integral b => b -> Down a -> Down a
Semigroup -- ^ @since 4.11.0.0
, Semigroup (Down a)
Down a
Semigroup (Down a)
-> Down a
-> (Down a -> Down a -> Down a)
-> ([Down a] -> Down a)
-> Monoid (Down a)
[Down a] -> Down a
Down a -> Down a -> Down a
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall {a}. Monoid a => Semigroup (Down a)
forall a. Monoid a => Down a
forall a. Monoid a => [Down a] -> Down a
forall a. Monoid a => Down a -> Down a -> Down a
\$cmempty :: forall a. Monoid a => Down a
mempty :: Down a
\$cmappend :: forall a. Monoid a => Down a -> Down a -> Down a
mappend :: Down a -> Down a -> Down a
\$cmconcat :: forall a. Monoid a => [Down a] -> Down a
mconcat :: [Down a] -> Down a
Monoid    -- ^ @since 4.11.0.0
, Eq (Down a)
Down a
Eq (Down a)
-> (Down a -> Down a -> Down a)
-> (Down a -> Down a -> Down a)
-> (Down a -> Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Int -> Down a)
-> (Down a -> Int -> Down a)
-> Down a
-> (Int -> Down a)
-> (Down a -> Int -> Down a)
-> (Down a -> Int -> Down a)
-> (Down a -> Int -> Down a)
-> (Down a -> Int -> Bool)
-> (Down a -> Maybe Int)
-> (Down a -> Int)
-> (Down a -> Bool)
-> (Down a -> Int -> Down a)
-> (Down a -> Int -> Down a)
-> (Down a -> Int -> Down a)
-> (Down a -> Int -> Down a)
-> (Down a -> Int -> Down a)
-> (Down a -> Int -> Down a)
-> (Down a -> Int)
-> Bits (Down a)
Int -> Down a
Down a -> Bool
Down a -> Int
Down a -> Maybe Int
Down a -> Down a
Down a -> Int -> Bool
Down a -> Int -> Down a
Down a -> Down a -> Down a
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
forall {a}. Bits a => Eq (Down a)
forall a. Bits a => Down a
forall a. Bits a => Int -> Down a
forall a. Bits a => Down a -> Bool
forall a. Bits a => Down a -> Int
forall a. Bits a => Down a -> Maybe Int
forall a. Bits a => Down a -> Down a
forall a. Bits a => Down a -> Int -> Bool
forall a. Bits a => Down a -> Int -> Down a
forall a. Bits a => Down a -> Down a -> Down a
\$c.&. :: forall a. Bits a => Down a -> Down a -> Down a
.&. :: Down a -> Down a -> Down a
\$c.|. :: forall a. Bits a => Down a -> Down a -> Down a
.|. :: Down a -> Down a -> Down a
\$cxor :: forall a. Bits a => Down a -> Down a -> Down a
xor :: Down a -> Down a -> Down a
\$ccomplement :: forall a. Bits a => Down a -> Down a
complement :: Down a -> Down a
\$cshift :: forall a. Bits a => Down a -> Int -> Down a
shift :: Down a -> Int -> Down a
\$crotate :: forall a. Bits a => Down a -> Int -> Down a
rotate :: Down a -> Int -> Down a
\$czeroBits :: forall a. Bits a => Down a
zeroBits :: Down a
\$cbit :: forall a. Bits a => Int -> Down a
bit :: Int -> Down a
\$csetBit :: forall a. Bits a => Down a -> Int -> Down a
setBit :: Down a -> Int -> Down a
\$cclearBit :: forall a. Bits a => Down a -> Int -> Down a
clearBit :: Down a -> Int -> Down a
\$ccomplementBit :: forall a. Bits a => Down a -> Int -> Down a
complementBit :: Down a -> Int -> Down a
\$ctestBit :: forall a. Bits a => Down a -> Int -> Bool
testBit :: Down a -> Int -> Bool
\$cbitSizeMaybe :: forall a. Bits a => Down a -> Maybe Int
bitSizeMaybe :: Down a -> Maybe Int
\$cbitSize :: forall a. Bits a => Down a -> Int
bitSize :: Down a -> Int
\$cisSigned :: forall a. Bits a => Down a -> Bool
isSigned :: Down a -> Bool
\$cshiftL :: forall a. Bits a => Down a -> Int -> Down a
shiftL :: Down a -> Int -> Down a
\$cunsafeShiftL :: forall a. Bits a => Down a -> Int -> Down a
unsafeShiftL :: Down a -> Int -> Down a
\$cshiftR :: forall a. Bits a => Down a -> Int -> Down a
shiftR :: Down a -> Int -> Down a
\$cunsafeShiftR :: forall a. Bits a => Down a -> Int -> Down a
unsafeShiftR :: Down a -> Int -> Down a
\$crotateL :: forall a. Bits a => Down a -> Int -> Down a
rotateL :: Down a -> Int -> Down a
\$crotateR :: forall a. Bits a => Down a -> Int -> Down a
rotateR :: Down a -> Int -> Down a
\$cpopCount :: forall a. Bits a => Down a -> Int
popCount :: Down a -> Int
Bits       -- ^ @since 4.14.0.0
, Bits (Down a)
Bits (Down a)
-> (Down a -> Int)
-> (Down a -> Int)
-> (Down a -> Int)
-> FiniteBits (Down a)
Down a -> Int
forall {a}. FiniteBits a => Bits (Down a)
forall a. FiniteBits a => Down a -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
\$cfiniteBitSize :: forall a. FiniteBits a => Down a -> Int
finiteBitSize :: Down a -> Int
\$ccountLeadingZeros :: forall a. FiniteBits a => Down a -> Int
countLeadingZeros :: Down a -> Int
\$ccountTrailingZeros :: forall a. FiniteBits a => Down a -> Int
countTrailingZeros :: Down a -> Int
FiniteBits -- ^ @since 4.14.0.0
, Fractional (Down a)
Down a
Fractional (Down a)
-> Down a
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a -> Down a)
-> (Down a -> Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> (Down a -> Down a)
-> Floating (Down a)
Down a -> Down a
Down a -> Down a -> Down a
forall {a}. Floating a => Fractional (Down a)
forall a. Floating a => Down a
forall a. Floating a => Down a -> Down a
forall a. Floating a => Down a -> Down a -> Down a
forall a.
Fractional a
-> a
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> Floating a
\$cpi :: forall a. Floating a => Down a
pi :: Down a
\$cexp :: forall a. Floating a => Down a -> Down a
exp :: Down a -> Down a
\$clog :: forall a. Floating a => Down a -> Down a
log :: Down a -> Down a
\$csqrt :: forall a. Floating a => Down a -> Down a
sqrt :: Down a -> Down a
\$c** :: forall a. Floating a => Down a -> Down a -> Down a
** :: Down a -> Down a -> Down a
\$clogBase :: forall a. Floating a => Down a -> Down a -> Down a
logBase :: Down a -> Down a -> Down a
\$csin :: forall a. Floating a => Down a -> Down a
sin :: Down a -> Down a
\$ccos :: forall a. Floating a => Down a -> Down a
cos :: Down a -> Down a
\$ctan :: forall a. Floating a => Down a -> Down a
tan :: Down a -> Down a
\$casin :: forall a. Floating a => Down a -> Down a
asin :: Down a -> Down a
\$cacos :: forall a. Floating a => Down a -> Down a
acos :: Down a -> Down a
\$catan :: forall a. Floating a => Down a -> Down a
atan :: Down a -> Down a
\$csinh :: forall a. Floating a => Down a -> Down a
sinh :: Down a -> Down a
\$ccosh :: forall a. Floating a => Down a -> Down a
cosh :: Down a -> Down a
\$ctanh :: forall a. Floating a => Down a -> Down a
tanh :: Down a -> Down a
\$casinh :: forall a. Floating a => Down a -> Down a
asinh :: Down a -> Down a
\$cacosh :: forall a. Floating a => Down a -> Down a
acosh :: Down a -> Down a
\$catanh :: forall a. Floating a => Down a -> Down a
atanh :: Down a -> Down a
\$clog1p :: forall a. Floating a => Down a -> Down a
log1p :: Down a -> Down a
\$cexpm1 :: forall a. Floating a => Down a -> Down a
expm1 :: Down a -> Down a
\$clog1pexp :: forall a. Floating a => Down a -> Down a
log1pexp :: Down a -> Down a
\$clog1mexp :: forall a. Floating a => Down a -> Down a
log1mexp :: Down a -> Down a
Floating   -- ^ @since 4.14.0.0
, Num (Down a)
Num (Down a)
-> (Down a -> Down a -> Down a)
-> (Down a -> Down a)
-> (Rational -> Down a)
-> Fractional (Down a)
Rational -> Down a
Down a -> Down a
Down a -> Down a -> Down a
forall {a}. Fractional a => Num (Down a)
forall a. Fractional a => Rational -> Down a
forall a. Fractional a => Down a -> Down a
forall a. Fractional a => Down a -> Down a -> Down a
forall a.
Num a
-> (a -> a -> a) -> (a -> a) -> (Rational -> a) -> Fractional a
\$c/ :: forall a. Fractional a => Down a -> Down a -> Down a
/ :: Down a -> Down a -> Down a
\$crecip :: forall a. Fractional a => Down a -> Down a
recip :: Down a -> Down a
\$cfromRational :: forall a. Fractional a => Rational -> Down a
fromRational :: Rational -> Down a
Fractional -- ^ @since 4.14.0.0
, Ord (Down a)
Ord (Down a)
-> ((Down a, Down a) -> [Down a])
-> ((Down a, Down a) -> Down a -> Int)
-> ((Down a, Down a) -> Down a -> Int)
-> ((Down a, Down a) -> Down a -> Bool)
-> ((Down a, Down a) -> Int)
-> ((Down a, Down a) -> Int)
-> Ix (Down a)
(Down a, Down a) -> Int
(Down a, Down a) -> [Down a]
(Down a, Down a) -> Down a -> Bool
(Down a, Down a) -> Down a -> Int
forall a.
Ord a
-> ((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
forall {a}. Ix a => Ord (Down a)
forall a. Ix a => (Down a, Down a) -> Int
forall a. Ix a => (Down a, Down a) -> [Down a]
forall a. Ix a => (Down a, Down a) -> Down a -> Bool
forall a. Ix a => (Down a, Down a) -> Down a -> Int
\$crange :: forall a. Ix a => (Down a, Down a) -> [Down a]
range :: (Down a, Down a) -> [Down a]
\$cindex :: forall a. Ix a => (Down a, Down a) -> Down a -> Int
index :: (Down a, Down a) -> Down a -> Int
\$cunsafeIndex :: forall a. Ix a => (Down a, Down a) -> Down a -> Int
unsafeIndex :: (Down a, Down a) -> Down a -> Int
\$cinRange :: forall a. Ix a => (Down a, Down a) -> Down a -> Bool
inRange :: (Down a, Down a) -> Down a -> Bool
\$crangeSize :: forall a. Ix a => (Down a, Down a) -> Int
rangeSize :: (Down a, Down a) -> Int
\$cunsafeRangeSize :: forall a. Ix a => (Down a, Down a) -> Int
unsafeRangeSize :: (Down a, Down a) -> Int
Ix         -- ^ @since 4.14.0.0
, Num (Down a)
Ord (Down a)
Num (Down a)
-> Ord (Down a) -> (Down a -> Rational) -> Real (Down a)
Down a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall {a}. Real a => Num (Down a)
forall {a}. Real a => Ord (Down a)
forall a. Real a => Down a -> Rational
\$ctoRational :: forall a. Real a => Down a -> Rational
toRational :: Down a -> Rational
Real       -- ^ @since 4.14.0.0
, Fractional (Down a)
Real (Down a)
Real (Down a)
-> Fractional (Down a)
-> (forall b. Integral b => Down a -> (b, Down a))
-> (forall b. Integral b => Down a -> b)
-> (forall b. Integral b => Down a -> b)
-> (forall b. Integral b => Down a -> b)
-> (forall b. Integral b => Down a -> b)
-> RealFrac (Down a)
forall b. Integral b => Down a -> b
forall b. Integral b => Down a -> (b, Down a)
forall a.
Real a
-> Fractional a
-> (forall b. Integral b => a -> (b, a))
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> RealFrac a
forall {a}. RealFrac a => Fractional (Down a)
forall {a}. RealFrac a => Real (Down a)
forall a b. (RealFrac a, Integral b) => Down a -> b
forall a b. (RealFrac a, Integral b) => Down a -> (b, Down a)
\$cproperFraction :: forall a b. (RealFrac a, Integral b) => Down a -> (b, Down a)
properFraction :: forall b. Integral b => Down a -> (b, Down a)
\$ctruncate :: forall a b. (RealFrac a, Integral b) => Down a -> b
truncate :: forall b. Integral b => Down a -> b
\$cround :: forall a b. (RealFrac a, Integral b) => Down a -> b
round :: forall b. Integral b => Down a -> b
\$cceiling :: forall a b. (RealFrac a, Integral b) => Down a -> b
ceiling :: forall b. Integral b => Down a -> b
\$cfloor :: forall a b. (RealFrac a, Integral b) => Down a -> b
floor :: forall b. Integral b => Down a -> b
RealFrac   -- ^ @since 4.14.0.0
, Floating (Down a)
RealFrac (Down a)
RealFrac (Down a)
-> Floating (Down a)
-> (Down a -> Integer)
-> (Down a -> Int)
-> (Down a -> (Int, Int))
-> (Down a -> (Integer, Int))
-> (Integer -> Int -> Down a)
-> (Down a -> Int)
-> (Down a -> Down a)
-> (Int -> Down a -> Down a)
-> (Down a -> Bool)
-> (Down a -> Bool)
-> (Down a -> Bool)
-> (Down a -> Bool)
-> (Down a -> Bool)
-> (Down a -> Down a -> Down a)
-> RealFloat (Down a)
Int -> Down a -> Down a
Integer -> Int -> Down a
Down a -> Bool
Down a -> Int
Down a -> Integer
Down a -> (Int, Int)
Down a -> (Integer, Int)
Down a -> Down a
Down a -> Down a -> Down a
forall {a}. RealFloat a => Floating (Down a)
forall {a}. RealFloat a => RealFrac (Down a)
forall a. RealFloat a => Int -> Down a -> Down a
forall a. RealFloat a => Integer -> Int -> Down a
forall a. RealFloat a => Down a -> Bool
forall a. RealFloat a => Down a -> Int
forall a. RealFloat a => Down a -> Integer
forall a. RealFloat a => Down a -> (Int, Int)
forall a. RealFloat a => Down a -> (Integer, Int)
forall a. RealFloat a => Down a -> Down a
forall a. RealFloat a => Down a -> Down a -> Down a
forall a.
RealFrac a
-> Floating a
-> (a -> Integer)
-> (a -> Int)
-> (a -> (Int, Int))
-> (a -> (Integer, Int))
-> (Integer -> Int -> a)
-> (a -> Int)
-> (a -> a)
-> (Int -> a -> a)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> a -> a)
-> RealFloat a
\$cfloatRadix :: forall a. RealFloat a => Down a -> Integer
floatRadix :: Down a -> Integer
\$cfloatDigits :: forall a. RealFloat a => Down a -> Int
floatDigits :: Down a -> Int
\$cfloatRange :: forall a. RealFloat a => Down a -> (Int, Int)
floatRange :: Down a -> (Int, Int)
\$cdecodeFloat :: forall a. RealFloat a => Down a -> (Integer, Int)
decodeFloat :: Down a -> (Integer, Int)
\$cencodeFloat :: forall a. RealFloat a => Integer -> Int -> Down a
encodeFloat :: Integer -> Int -> Down a
\$cexponent :: forall a. RealFloat a => Down a -> Int
exponent :: Down a -> Int
\$csignificand :: forall a. RealFloat a => Down a -> Down a
significand :: Down a -> Down a
\$cscaleFloat :: forall a. RealFloat a => Int -> Down a -> Down a
scaleFloat :: Int -> Down a -> Down a
\$cisNaN :: forall a. RealFloat a => Down a -> Bool
isNaN :: Down a -> Bool
\$cisInfinite :: forall a. RealFloat a => Down a -> Bool
isInfinite :: Down a -> Bool
\$cisDenormalized :: forall a. RealFloat a => Down a -> Bool
isDenormalized :: Down a -> Bool
\$cisNegativeZero :: forall a. RealFloat a => Down a -> Bool
isNegativeZero :: Down a -> Bool
\$cisIEEE :: forall a. RealFloat a => Down a -> Bool
isIEEE :: Down a -> Bool
\$catan2 :: forall a. RealFloat a => Down a -> Down a -> Down a
atan2 :: Down a -> Down a -> Down a
RealFloat  -- ^ @since 4.14.0.0
, Ptr (Down a) -> IO (Down a)
Ptr (Down a) -> Int -> IO (Down a)
Ptr (Down a) -> Int -> Down a -> IO ()
Ptr (Down a) -> Down a -> IO ()
Down a -> Int
(Down a -> Int)
-> (Down a -> Int)
-> (Ptr (Down a) -> Int -> IO (Down a))
-> (Ptr (Down a) -> Int -> Down a -> IO ())
-> (forall b. Ptr b -> Int -> IO (Down a))
-> (forall b. Ptr b -> Int -> Down a -> IO ())
-> (Ptr (Down a) -> IO (Down a))
-> (Ptr (Down a) -> Down a -> IO ())
-> Storable (Down a)
forall b. Ptr b -> Int -> IO (Down a)
forall b. Ptr b -> Int -> Down a -> IO ()
forall a. Storable a => Ptr (Down a) -> IO (Down a)
forall a. Storable a => Ptr (Down a) -> Int -> IO (Down a)
forall a. Storable a => Ptr (Down a) -> Int -> Down a -> IO ()
forall a. Storable a => Ptr (Down a) -> Down a -> IO ()
forall a. Storable a => Down a -> Int
forall a b. Storable a => Ptr b -> Int -> IO (Down a)
forall a b. Storable a => Ptr b -> Int -> Down a -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
\$csizeOf :: forall a. Storable a => Down a -> Int
sizeOf :: Down a -> Int
\$calignment :: forall a. Storable a => Down a -> Int
alignment :: Down a -> Int
\$cpeekElemOff :: forall a. Storable a => Ptr (Down a) -> Int -> IO (Down a)
peekElemOff :: Ptr (Down a) -> Int -> IO (Down a)
\$cpokeElemOff :: forall a. Storable a => Ptr (Down a) -> Int -> Down a -> IO ()
pokeElemOff :: Ptr (Down a) -> Int -> Down a -> IO ()
\$cpeekByteOff :: forall a b. Storable a => Ptr b -> Int -> IO (Down a)
peekByteOff :: forall b. Ptr b -> Int -> IO (Down a)
\$cpokeByteOff :: forall a b. Storable a => Ptr b -> Int -> Down a -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> Down a -> IO ()
\$cpeek :: forall a. Storable a => Ptr (Down a) -> IO (Down a)
peek :: Ptr (Down a) -> IO (Down a)
\$cpoke :: forall a. Storable a => Ptr (Down a) -> Down a -> IO ()
poke :: Ptr (Down a) -> Down a -> IO ()
Storable   -- ^ @since 4.14.0.0
)

-- | This instance would be equivalent to the derived instances of the
-- 'Down' newtype if the 'getDown' field were removed
--
-- @since 4.7.0.0
instance (Read a) => Read (Down a) where
readsPrec :: Int -> ReadS (Down a)
d = Bool -> ReadS (Down a) -> ReadS (Down a)
forall a. Bool -> ReadS a -> ReadS a
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ReadS (Down a) -> ReadS (Down a))
-> ReadS (Down a) -> ReadS (Down a)
forall a b. (a -> b) -> a -> b
\$ \ String
r ->
[(a -> Down a
forall a. a -> Down a
Down a
x,String
t) | (String
"Down",String
s) <- ReadS String
lex String
r, (a
x,String
t) <- Int -> ReadS a
forall a. Read a => Int -> ReadS a
11 String
s]

-- | This instance would be equivalent to the derived instances of the
-- 'Down' newtype if the 'getDown' field were removed
--
-- @since 4.7.0.0
instance (Show a) => Show (Down a) where
showsPrec :: Int -> Down a -> ShowS
showsPrec Int
d (Down a
x) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
\$
String -> ShowS
showString String
"Down " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 a
x

-- | @since 4.6.0.0
instance Ord a => Ord (Down a) where
compare :: Down a -> Down a -> Ordering
compare (Down a
x) (Down a
y) = a
y a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` a
x

-- | Swaps @'minBound'@ and @'maxBound'@ of the underlying type.
--
-- @since 4.14.0.0
instance Bounded a => Bounded (Down a) where
minBound :: Down a
minBound = a -> Down a
forall a. a -> Down a
Down a
forall a. Bounded a => a
maxBound
maxBound :: Down a
maxBound = a -> Down a
forall a. a -> Down a
Down a
forall a. Bounded a => a
minBound

-- | @since 4.11.0.0
instance Functor Down where
fmap :: forall a b. (a -> b) -> Down a -> Down b
fmap = (a -> b) -> Down a -> Down b
forall a b. Coercible a b => a -> b
coerce

-- | @since 4.11.0.0
instance Applicative Down where
pure :: forall a. a -> Down a
pure = a -> Down a
forall a. a -> Down a
Down
<*> :: forall a b. Down (a -> b) -> Down a -> Down b
(<*>) = Down (a -> b) -> Down a -> Down b
forall a b. Coercible a b => a -> b
coerce

-- | @since 4.11.0.0
instance Monad Down where
Down a
a >>= :: forall a b. Down a -> (a -> Down b) -> Down b
>>= a -> Down b
k = a -> Down b
k a
a
```