    {-# OPTIONS_GHC -Wall -fno-warn-orphans #-}
    ----------------------------------------------------------------------
    -- |
    -- Module      :  Data.NumInstances.Function
    -- Copyright   :  (c) Conal Elliott 2008-2013
    -- License     :  BSD3
    --
    -- Maintainer  :  conal@conal.net
    -- Stability   :  experimental
    --
    -- Number class instances for functions
    ----------------------------------------------------------------------

    module Data.NumInstances.Function () where

    import Control.Applicative

    import Data.NumInstances.PreRequisites () -- Eq, Ord, Show, if necessary

    instance Num b => Num (a->b) where
      negate :: (a -> b) -> a -> b
    negate      = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Num a => a -> a
    negate
      + :: (a -> b) -> (a -> b) -> a -> b
    (+)         = (b -> b -> b) -> (a -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b c.
    Applicative f =>
    (a -> b -> c) -> f a -> f b -> f c
    liftA2 b -> b -> b
    forall a. Num a => a -> a -> a
    (+)
      * :: (a -> b) -> (a -> b) -> a -> b
    (*)         = (b -> b -> b) -> (a -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b c.
    Applicative f =>
    (a -> b -> c) -> f a -> f b -> f c
    liftA2 b -> b -> b
    forall a. Num a => a -> a -> a
    (*)
      fromInteger :: Integer -> a -> b
    fromInteger = b -> a -> b
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (b -> a -> b) -> (Integer -> b) -> Integer -> a -> b
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> b
    forall a. Num a => Integer -> a
    fromInteger
      abs :: (a -> b) -> a -> b
    abs         = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Num a => a -> a
    abs
      signum :: (a -> b) -> a -> b
    signum      = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Num a => a -> a
    signum

    instance Fractional b => Fractional (a->b) where
      recip :: (a -> b) -> a -> b
    recip        = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Fractional a => a -> a
    recip
      fromRational :: Rational -> a -> b
    fromRational = b -> a -> b
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (b -> a -> b) -> (Rational -> b) -> Rational -> a -> b
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Rational -> b
    forall a. Fractional a => Rational -> a
    fromRational

    instance Floating b => Floating (a->b) where
      pi :: a -> b
    pi    = b -> a -> b
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure b
    forall a. Floating a => a
    pi
      sqrt :: (a -> b) -> a -> b
    sqrt  = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    sqrt
      exp :: (a -> b) -> a -> b
    exp   = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    exp
      log :: (a -> b) -> a -> b
    log   = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    log
      sin :: (a -> b) -> a -> b
    sin   = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    sin
      cos :: (a -> b) -> a -> b
    cos   = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    cos
      asin :: (a -> b) -> a -> b
    asin  = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    asin
      atan :: (a -> b) -> a -> b
    atan  = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    atan
      acos :: (a -> b) -> a -> b
    acos  = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    acos
      sinh :: (a -> b) -> a -> b
    sinh  = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    sinh
      cosh :: (a -> b) -> a -> b
    cosh  = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    cosh
      asinh :: (a -> b) -> a -> b
    asinh = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    asinh
      atanh :: (a -> b) -> a -> b
    atanh = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    atanh
      acosh :: (a -> b) -> a -> b
    acosh = (b -> b) -> (a -> b) -> a -> b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap b -> b
    forall a. Floating a => a -> a
    acosh