{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeOperators #-}
module Data.Functor.Contravariant (
Contravariant(..)
, phantom
, (>$<), (>$$<), ($<)
, Predicate(..)
, Comparison(..)
, defaultComparison
, Equivalence(..)
, defaultEquivalence
, comparisonEquivalence
, Op(..)
) where
import Control.Applicative
import Control.Category
import Data.Function (on)
import Data.Functor.Product
import Data.Functor.Sum
import Data.Functor.Compose
import Data.Monoid (Alt(..))
import Data.Proxy
import GHC.Generics
import Prelude hiding ((.),id)
class Contravariant f where
contramap :: (a -> b) -> f b -> f a
(>$) :: b -> f b -> f a
(>$) = (a -> b) -> f b -> f a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap ((a -> b) -> f b -> f a) -> (b -> a -> b) -> b -> f b -> f a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a -> b
forall a b. a -> b -> a
const
phantom :: (Functor f, Contravariant f) => f a -> f b
phantom :: f a -> f b
phantom x :: f a
x = () () -> f a -> f ()
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ f a
x f () -> () -> f b
forall (f :: * -> *) b a. Contravariant f => f b -> b -> f a
$< ()
infixl 4 >$, $<, >$<, >$$<
($<) :: Contravariant f => f b -> b -> f a
$< :: f b -> b -> f a
($<) = (b -> f b -> f a) -> f b -> b -> f a
forall a b c. (a -> b -> c) -> b -> a -> c
flip b -> f b -> f a
forall (f :: * -> *) b a. Contravariant f => b -> f b -> f a
(>$)
(>$<) :: Contravariant f => (a -> b) -> f b -> f a
>$< :: (a -> b) -> f b -> f a
(>$<) = (a -> b) -> f b -> f a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap
(>$$<) :: Contravariant f => f b -> (a -> b) -> f a
>$$< :: f b -> (a -> b) -> f a
(>$$<) = ((a -> b) -> f b -> f a) -> f b -> (a -> b) -> f a
forall a b c. (a -> b -> c) -> b -> a -> c
flip (a -> b) -> f b -> f a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap
deriving instance Contravariant f => Contravariant (Alt f)
deriving instance Contravariant f => Contravariant (Rec1 f)
deriving instance Contravariant f => Contravariant (M1 i c f)
instance Contravariant V1 where
contramap :: (a -> b) -> V1 b -> V1 a
contramap _ x :: V1 b
x = case V1 b
x of
instance Contravariant U1 where
contramap :: (a -> b) -> U1 b -> U1 a
contramap _ _ = U1 a
forall k (p :: k). U1 p
U1
instance Contravariant (K1 i c) where
contramap :: (a -> b) -> K1 i c b -> K1 i c a
contramap _ (K1 c :: c
c) = c -> K1 i c a
forall k i c (p :: k). c -> K1 i c p
K1 c
c
instance (Contravariant f, Contravariant g) => Contravariant (f :*: g) where
contramap :: (a -> b) -> (:*:) f g b -> (:*:) f g a
contramap f :: a -> b
f (xs :: f b
xs :*: ys :: g b
ys) = (a -> b) -> f b -> f a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap a -> b
f f b
xs f a -> g a -> (:*:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k).
f p -> g p -> (:*:) f g p
:*: (a -> b) -> g b -> g a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap a -> b
f g b
ys
instance (Functor f, Contravariant g) => Contravariant (f :.: g) where
contramap :: (a -> b) -> (:.:) f g b -> (:.:) f g a
contramap f :: a -> b
f (Comp1 fg :: f (g b)
fg) = f (g a) -> (:.:) f g a
forall k2 k1 (f :: k2 -> *) (g :: k1 -> k2) (p :: k1).
f (g p) -> (:.:) f g p
Comp1 ((g b -> g a) -> f (g b) -> f (g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> g b -> g a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap a -> b
f) f (g b)
fg)
instance (Contravariant f, Contravariant g) => Contravariant (f :+: g) where
contramap :: (a -> b) -> (:+:) f g b -> (:+:) f g a
contramap f :: a -> b
f (L1 xs :: f b
xs) = f a -> (:+:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k). f p -> (:+:) f g p
L1 ((a -> b) -> f b -> f a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap a -> b
f f b
xs)
contramap f :: a -> b
f (R1 ys :: g b
ys) = g a -> (:+:) f g a
forall k (f :: k -> *) (g :: k -> *) (p :: k). g p -> (:+:) f g p
R1 ((a -> b) -> g b -> g a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap a -> b
f g b
ys)
instance (Contravariant f, Contravariant g) => Contravariant (Sum f g) where
contramap :: (a -> b) -> Sum f g b -> Sum f g a
contramap f :: a -> b
f (InL xs :: f b
xs) = f a -> Sum f g a
forall k (f :: k -> *) (g :: k -> *) (a :: k). f a -> Sum f g a
InL ((a -> b) -> f b -> f a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap a -> b
f f b
xs)
contramap f :: a -> b
f (InR ys :: g b
ys) = g a -> Sum f g a
forall k (f :: k -> *) (g :: k -> *) (a :: k). g a -> Sum f g a
InR ((a -> b) -> g b -> g a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap a -> b
f g b
ys)
instance (Contravariant f, Contravariant g)
=> Contravariant (Product f g) where
contramap :: (a -> b) -> Product f g b -> Product f g a
contramap f :: a -> b
f (Pair a :: f b
a b :: g b
b) = f a -> g a -> Product f g a
forall k (f :: k -> *) (g :: k -> *) (a :: k).
f a -> g a -> Product f g a
Pair ((a -> b) -> f b -> f a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap a -> b
f f b
a) ((a -> b) -> g b -> g a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap a -> b
f g b
b)
instance Contravariant (Const a) where
contramap :: (a -> b) -> Const a b -> Const a a
contramap _ (Const a :: a
a) = a -> Const a a
forall k a (b :: k). a -> Const a b
Const a
a
instance (Functor f, Contravariant g) => Contravariant (Compose f g) where
contramap :: (a -> b) -> Compose f g b -> Compose f g a
contramap f :: a -> b
f (Compose fga :: f (g b)
fga) = f (g a) -> Compose f g a
forall k k (f :: k -> *) (g :: k -> k) (a :: k).
f (g a) -> Compose f g a
Compose ((g b -> g a) -> f (g b) -> f (g a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> g b -> g a
forall (f :: * -> *) a b. Contravariant f => (a -> b) -> f b -> f a
contramap a -> b
f) f (g b)
fga)
instance Contravariant Proxy where
contramap :: (a -> b) -> Proxy b -> Proxy a
contramap _ _ = Proxy a
forall k (t :: k). Proxy t
Proxy
newtype Predicate a = Predicate { Predicate a -> a -> Bool
getPredicate :: a -> Bool }
instance Contravariant Predicate where
contramap :: (a -> b) -> Predicate b -> Predicate a
contramap f :: a -> b
f g :: Predicate b
g = (a -> Bool) -> Predicate a
forall a. (a -> Bool) -> Predicate a
Predicate ((a -> Bool) -> Predicate a) -> (a -> Bool) -> Predicate a
forall a b. (a -> b) -> a -> b
$ Predicate b -> b -> Bool
forall a. Predicate a -> a -> Bool
getPredicate Predicate b
g (b -> Bool) -> (a -> b) -> a -> Bool
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> b
f
instance Semigroup (Predicate a) where
Predicate p :: a -> Bool
p <> :: Predicate a -> Predicate a -> Predicate a
<> Predicate q :: a -> Bool
q = (a -> Bool) -> Predicate a
forall a. (a -> Bool) -> Predicate a
Predicate ((a -> Bool) -> Predicate a) -> (a -> Bool) -> Predicate a
forall a b. (a -> b) -> a -> b
$ \a :: a
a -> a -> Bool
p a
a Bool -> Bool -> Bool
&& a -> Bool
q a
a
instance Monoid (Predicate a) where
mempty :: Predicate a
mempty = (a -> Bool) -> Predicate a
forall a. (a -> Bool) -> Predicate a
Predicate ((a -> Bool) -> Predicate a) -> (a -> Bool) -> Predicate a
forall a b. (a -> b) -> a -> b
$ Bool -> a -> Bool
forall a b. a -> b -> a
const Bool
True
newtype Comparison a = Comparison { Comparison a -> a -> a -> Ordering
getComparison :: a -> a -> Ordering }
deriving instance Semigroup (Comparison a)
deriving instance Monoid (Comparison a)
instance Contravariant Comparison where
contramap :: (a -> b) -> Comparison b -> Comparison a
contramap f :: a -> b
f g :: Comparison b
g = (a -> a -> Ordering) -> Comparison a
forall a. (a -> a -> Ordering) -> Comparison a
Comparison ((a -> a -> Ordering) -> Comparison a)
-> (a -> a -> Ordering) -> Comparison a
forall a b. (a -> b) -> a -> b
$ (b -> b -> Ordering) -> (a -> b) -> a -> a -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on (Comparison b -> b -> b -> Ordering
forall a. Comparison a -> a -> a -> Ordering
getComparison Comparison b
g) a -> b
f
defaultComparison :: Ord a => Comparison a
defaultComparison :: Comparison a
defaultComparison = (a -> a -> Ordering) -> Comparison a
forall a. (a -> a -> Ordering) -> Comparison a
Comparison a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
compare
newtype Equivalence a = Equivalence { Equivalence a -> a -> a -> Bool
getEquivalence :: a -> a -> Bool }
instance Contravariant Equivalence where
contramap :: (a -> b) -> Equivalence b -> Equivalence a
contramap f :: a -> b
f g :: Equivalence b
g = (a -> a -> Bool) -> Equivalence a
forall a. (a -> a -> Bool) -> Equivalence a
Equivalence ((a -> a -> Bool) -> Equivalence a)
-> (a -> a -> Bool) -> Equivalence a
forall a b. (a -> b) -> a -> b
$ (b -> b -> Bool) -> (a -> b) -> a -> a -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on (Equivalence b -> b -> b -> Bool
forall a. Equivalence a -> a -> a -> Bool
getEquivalence Equivalence b
g) a -> b
f
instance Semigroup (Equivalence a) where
Equivalence p :: a -> a -> Bool
p <> :: Equivalence a -> Equivalence a -> Equivalence a
<> Equivalence q :: a -> a -> Bool
q = (a -> a -> Bool) -> Equivalence a
forall a. (a -> a -> Bool) -> Equivalence a
Equivalence ((a -> a -> Bool) -> Equivalence a)
-> (a -> a -> Bool) -> Equivalence a
forall a b. (a -> b) -> a -> b
$ \a :: a
a b :: a
b -> a -> a -> Bool
p a
a a
b Bool -> Bool -> Bool
&& a -> a -> Bool
q a
a a
b
instance Monoid (Equivalence a) where
mempty :: Equivalence a
mempty = (a -> a -> Bool) -> Equivalence a
forall a. (a -> a -> Bool) -> Equivalence a
Equivalence (\_ _ -> Bool
True)
defaultEquivalence :: Eq a => Equivalence a
defaultEquivalence :: Equivalence a
defaultEquivalence = (a -> a -> Bool) -> Equivalence a
forall a. (a -> a -> Bool) -> Equivalence a
Equivalence a -> a -> Bool
forall a. Eq a => a -> a -> Bool
(==)
comparisonEquivalence :: Comparison a -> Equivalence a
comparisonEquivalence :: Comparison a -> Equivalence a
comparisonEquivalence (Comparison p :: a -> a -> Ordering
p) = (a -> a -> Bool) -> Equivalence a
forall a. (a -> a -> Bool) -> Equivalence a
Equivalence ((a -> a -> Bool) -> Equivalence a)
-> (a -> a -> Bool) -> Equivalence a
forall a b. (a -> b) -> a -> b
$ \a :: a
a b :: a
b -> a -> a -> Ordering
p a
a a
b Ordering -> Ordering -> Bool
forall a. Eq a => a -> a -> Bool
== Ordering
EQ
newtype Op a b = Op { Op a b -> b -> a
getOp :: b -> a }
deriving instance Semigroup a => Semigroup (Op a b)
deriving instance Monoid a => Monoid (Op a b)
instance Category Op where
id :: Op a a
id = (a -> a) -> Op a a
forall a b. (b -> a) -> Op a b
Op a -> a
forall k (cat :: k -> k -> *) (a :: k). Category cat => cat a a
id
Op f :: c -> b
f . :: Op b c -> Op a b -> Op a c
. Op g :: b -> a
g = (c -> a) -> Op a c
forall a b. (b -> a) -> Op a b
Op (b -> a
g (b -> a) -> (c -> b) -> c -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. c -> b
f)
instance Contravariant (Op a) where
contramap :: (a -> b) -> Op a b -> Op a a
contramap f :: a -> b
f g :: Op a b
g = (a -> a) -> Op a a
forall a b. (b -> a) -> Op a b
Op (Op a b -> b -> a
forall a b. Op a b -> b -> a
getOp Op a b
g (b -> a) -> (a -> b) -> a -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> b
f)
instance Num a => Num (Op a b) where
Op f :: b -> a
f + :: Op a b -> Op a b -> Op a b
+ Op g :: b -> a
g = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ \a :: b
a -> b -> a
f b
a a -> a -> a
forall a. Num a => a -> a -> a
+ b -> a
g b
a
Op f :: b -> a
f * :: Op a b -> Op a b -> Op a b
* Op g :: b -> a
g = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ \a :: b
a -> b -> a
f b
a a -> a -> a
forall a. Num a => a -> a -> a
* b -> a
g b
a
Op f :: b -> a
f - :: Op a b -> Op a b -> Op a b
- Op g :: b -> a
g = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ \a :: b
a -> b -> a
f b
a a -> a -> a
forall a. Num a => a -> a -> a
- b -> a
g b
a
abs :: Op a b -> Op a b
abs (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Num a => a -> a
abs (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
signum :: Op a b -> Op a b
signum (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Num a => a -> a
signum (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
fromInteger :: Integer -> Op a b
fromInteger = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (Integer -> b -> a) -> Integer -> Op a b
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> b -> a
forall a b. a -> b -> a
const (a -> b -> a) -> (Integer -> a) -> Integer -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Integer -> a
forall a. Num a => Integer -> a
fromInteger
instance Fractional a => Fractional (Op a b) where
Op f :: b -> a
f / :: Op a b -> Op a b -> Op a b
/ Op g :: b -> a
g = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ \a :: b
a -> b -> a
f b
a a -> a -> a
forall a. Fractional a => a -> a -> a
/ b -> a
g b
a
recip :: Op a b -> Op a b
recip (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Fractional a => a -> a
recip (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
fromRational :: Rational -> Op a b
fromRational = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (Rational -> b -> a) -> Rational -> Op a b
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. a -> b -> a
forall a b. a -> b -> a
const (a -> b -> a) -> (Rational -> a) -> Rational -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Rational -> a
forall a. Fractional a => Rational -> a
fromRational
instance Floating a => Floating (Op a b) where
pi :: Op a b
pi = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> b -> a
forall a b. a -> b -> a
const a
forall a. Floating a => a
pi
exp :: Op a b -> Op a b
exp (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
exp (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
sqrt :: Op a b -> Op a b
sqrt (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
sqrt (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
log :: Op a b -> Op a b
log (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
log (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
sin :: Op a b -> Op a b
sin (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
sin (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
tan :: Op a b -> Op a b
tan (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
tan (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
cos :: Op a b -> Op a b
cos (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
cos (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
asin :: Op a b -> Op a b
asin (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
asin (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
atan :: Op a b -> Op a b
atan (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
atan (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
acos :: Op a b -> Op a b
acos (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
acos (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
sinh :: Op a b -> Op a b
sinh (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
sinh (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
tanh :: Op a b -> Op a b
tanh (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
tanh (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
cosh :: Op a b -> Op a b
cosh (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
cosh (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
asinh :: Op a b -> Op a b
asinh (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
asinh (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
atanh :: Op a b -> Op a b
atanh (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
atanh (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
acosh :: Op a b -> Op a b
acosh (Op f :: b -> a
f) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ a -> a
forall a. Floating a => a -> a
acosh (a -> a) -> (b -> a) -> b -> a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. b -> a
f
Op f :: b -> a
f ** :: Op a b -> Op a b -> Op a b
** Op g :: b -> a
g = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ \a :: b
a -> b -> a
f b
a a -> a -> a
forall a. Floating a => a -> a -> a
** b -> a
g b
a
logBase :: Op a b -> Op a b -> Op a b
logBase (Op f :: b -> a
f) (Op g :: b -> a
g) = (b -> a) -> Op a b
forall a b. (b -> a) -> Op a b
Op ((b -> a) -> Op a b) -> (b -> a) -> Op a b
forall a b. (a -> b) -> a -> b
$ \a :: b
a -> a -> a -> a
forall a. Floating a => a -> a -> a
logBase (b -> a
f b
a) (b -> a
g b
a)