{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Algebra.Morphism.Pointwise where
import Prelude (Functor(..), (.))
import Control.Applicative
import Algebra.Classes
newtype Pointwise x a = Pointwise (x -> a) deriving ((forall a b. (a -> b) -> Pointwise x a -> Pointwise x b)
-> (forall a b. a -> Pointwise x b -> Pointwise x a)
-> Functor (Pointwise x)
forall a b. a -> Pointwise x b -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall x a b. a -> Pointwise x b -> Pointwise x a
forall x a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall x a b. (a -> b) -> Pointwise x a -> Pointwise x b
fmap :: forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
$c<$ :: forall x a b. a -> Pointwise x b -> Pointwise x a
<$ :: forall a b. a -> Pointwise x b -> Pointwise x a
Functor, Pointwise x a
Natural -> Pointwise x a -> Pointwise x a
Pointwise x a -> Pointwise x a -> Pointwise x a
(Pointwise x a -> Pointwise x a -> Pointwise x a)
-> Pointwise x a
-> (Natural -> Pointwise x a -> Pointwise x a)
-> Additive (Pointwise x a)
forall a. (a -> a -> a) -> a -> (Natural -> a -> a) -> Additive a
forall x a. Additive a => Pointwise x a
forall x a. Additive a => Natural -> Pointwise x a -> Pointwise x a
forall x a.
Additive a =>
Pointwise x a -> Pointwise x a -> Pointwise x a
$c+ :: forall x a.
Additive a =>
Pointwise x a -> Pointwise x a -> Pointwise x a
+ :: Pointwise x a -> Pointwise x a -> Pointwise x a
$czero :: forall x a. Additive a => Pointwise x a
zero :: Pointwise x a
$ctimes :: forall x a. Additive a => Natural -> Pointwise x a -> Pointwise x a
times :: Natural -> Pointwise x a -> Pointwise x a
Additive, Additive (Pointwise x a)
Natural -> Pointwise x a -> Pointwise x a
Additive (Pointwise x a) =>
(Pointwise x a -> Pointwise x a -> Pointwise x a)
-> (Pointwise x a -> Pointwise x a -> Pointwise x a)
-> (Pointwise x a -> Pointwise x a)
-> (Natural -> Pointwise x a -> Pointwise x a)
-> Group (Pointwise x a)
Pointwise x a -> Pointwise x a
Pointwise x a -> Pointwise x a -> Pointwise x a
forall a.
Additive a =>
(a -> a -> a)
-> (a -> a -> a) -> (a -> a) -> (Natural -> a -> a) -> Group a
forall x a. Group a => Additive (Pointwise x a)
forall x a. Group a => Natural -> Pointwise x a -> Pointwise x a
forall x a. Group a => Pointwise x a -> Pointwise x a
forall x a.
Group a =>
Pointwise x a -> Pointwise x a -> Pointwise x a
$c- :: forall x a.
Group a =>
Pointwise x a -> Pointwise x a -> Pointwise x a
- :: Pointwise x a -> Pointwise x a -> Pointwise x a
$csubtract :: forall x a.
Group a =>
Pointwise x a -> Pointwise x a -> Pointwise x a
subtract :: Pointwise x a -> Pointwise x a -> Pointwise x a
$cnegate :: forall x a. Group a => Pointwise x a -> Pointwise x a
negate :: Pointwise x a -> Pointwise x a
$cmult :: forall x a. Group a => Natural -> Pointwise x a -> Pointwise x a
mult :: Natural -> Pointwise x a -> Pointwise x a
Group, Additive (Pointwise x a)
Additive (Pointwise x a) => AbelianAdditive (Pointwise x a)
forall a. Additive a => AbelianAdditive a
forall x a. Additive a => Additive (Pointwise x a)
AbelianAdditive, Functor (Pointwise x)
Functor (Pointwise x) =>
(forall a. a -> Pointwise x a)
-> (forall a b.
Pointwise x (a -> b) -> Pointwise x a -> Pointwise x b)
-> (forall a b c.
(a -> b -> c) -> Pointwise x a -> Pointwise x b -> Pointwise x c)
-> (forall a b. Pointwise x a -> Pointwise x b -> Pointwise x b)
-> (forall a b. Pointwise x a -> Pointwise x b -> Pointwise x a)
-> Applicative (Pointwise x)
forall x. Functor (Pointwise x)
forall a. a -> Pointwise x a
forall x a. a -> Pointwise x a
forall a b. Pointwise x a -> Pointwise x b -> Pointwise x a
forall a b. Pointwise x a -> Pointwise x b -> Pointwise x b
forall a b. Pointwise x (a -> b) -> Pointwise x a -> Pointwise x b
forall x a b. Pointwise x a -> Pointwise x b -> Pointwise x a
forall x a b. Pointwise x a -> Pointwise x b -> Pointwise x b
forall x a b.
Pointwise x (a -> b) -> Pointwise x a -> Pointwise x b
forall a b c.
(a -> b -> c) -> Pointwise x a -> Pointwise x b -> Pointwise x c
forall x a b c.
(a -> b -> c) -> Pointwise x a -> Pointwise x b -> Pointwise x c
forall (f :: * -> *).
Functor f =>
(forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
$cpure :: forall x a. a -> Pointwise x a
pure :: forall a. a -> Pointwise x a
$c<*> :: forall x a b.
Pointwise x (a -> b) -> Pointwise x a -> Pointwise x b
<*> :: forall a b. Pointwise x (a -> b) -> Pointwise x a -> Pointwise x b
$cliftA2 :: forall x a b c.
(a -> b -> c) -> Pointwise x a -> Pointwise x b -> Pointwise x c
liftA2 :: forall a b c.
(a -> b -> c) -> Pointwise x a -> Pointwise x b -> Pointwise x c
$c*> :: forall x a b. Pointwise x a -> Pointwise x b -> Pointwise x b
*> :: forall a b. Pointwise x a -> Pointwise x b -> Pointwise x b
$c<* :: forall x a b. Pointwise x a -> Pointwise x b -> Pointwise x a
<* :: forall a b. Pointwise x a -> Pointwise x b -> Pointwise x a
Applicative)
fromPointwise :: Pointwise x a -> x -> a
fromPointwise :: forall x a. Pointwise x a -> x -> a
fromPointwise (Pointwise x -> a
x) = x -> a
x
instance Multiplicative a => Multiplicative (Pointwise x a) where
one :: Pointwise x a
one = a -> Pointwise x a
forall a. a -> Pointwise x a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Multiplicative a => a
one
* :: Pointwise x a -> Pointwise x a -> Pointwise x a
(*) = (a -> a -> a) -> Pointwise x a -> Pointwise x a -> Pointwise x a
forall a b c.
(a -> b -> c) -> Pointwise x a -> Pointwise x b -> Pointwise x c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Multiplicative a => a -> a -> a
(*)
instance Division a => Division (Pointwise x a) where
recip :: Pointwise x a -> Pointwise x a
recip = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Division a => a -> a
recip
/ :: Pointwise x a -> Pointwise x a -> Pointwise x a
(/) = (a -> a -> a) -> Pointwise x a -> Pointwise x a -> Pointwise x a
forall a b c.
(a -> b -> c) -> Pointwise x a -> Pointwise x b -> Pointwise x c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Division a => a -> a -> a
(/)
instance Roots a => Roots (Pointwise x a) where
root :: Natural -> Pointwise x a -> Pointwise x a
root Natural
n = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Natural -> a -> a
forall a. Roots a => Natural -> a -> a
root Natural
n)
instance Transcendental a => Transcendental (Pointwise x a) where
pi :: Pointwise x a
pi = a -> Pointwise x a
forall a. a -> Pointwise x a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Transcendental a => a
pi
log :: Pointwise x a -> Pointwise x a
log = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
log
sin :: Pointwise x a -> Pointwise x a
sin = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
sin
cos :: Pointwise x a -> Pointwise x a
cos = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
cos
asin :: Pointwise x a -> Pointwise x a
asin = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
asin
acos :: Pointwise x a -> Pointwise x a
acos = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
acos
atan :: Pointwise x a -> Pointwise x a
atan = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
atan
sinh :: Pointwise x a -> Pointwise x a
sinh = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
sinh
cosh :: Pointwise x a -> Pointwise x a
cosh = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
cosh
asinh :: Pointwise x a -> Pointwise x a
asinh = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
asinh
acosh :: Pointwise x a -> Pointwise x a
acosh = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
acosh
atanh :: Pointwise x a -> Pointwise x a
atanh = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
atanh
exp :: Pointwise x a -> Pointwise x a
exp = (a -> a) -> Pointwise x a -> Pointwise x a
forall a b. (a -> b) -> Pointwise x a -> Pointwise x b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
forall a. Transcendental a => a -> a
exp
instance Multiplicative a => Scalable (Pointwise x a) (Pointwise x a) where
*^ :: Pointwise x a -> Pointwise x a -> Pointwise x a
(*^) = Pointwise x a -> Pointwise x a -> Pointwise x a
forall a. Multiplicative a => a -> a -> a
(*)
instance Ring a => Ring (Pointwise x a) where
fromInteger :: Natural -> Pointwise x a
fromInteger = a -> Pointwise x a
forall a. a -> Pointwise x a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Pointwise x a) -> (Natural -> a) -> Natural -> Pointwise x a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Natural -> a
forall a. Ring a => Natural -> a
fromInteger
instance Field a => Field (Pointwise x a) where
fromRational :: Rational -> Pointwise x a
fromRational = a -> Pointwise x a
forall a. a -> Pointwise x a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Pointwise x a)
-> (Rational -> a) -> Rational -> Pointwise x a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rational -> a
forall a. Field a => Rational -> a
fromRational