{-# LANGUAGE Rank2Types #-}
-----------------------------------------------------------------------------
-- |
-- Copyright   : (c) Edward Kmett 2010-2021
-- License     : BSD3
-- Maintainer  : ekmett@gmail.com
-- Stability   : experimental
-- Portability : GHC only
--
-- Higher order derivatives via a \"dual number tower\".
--
-----------------------------------------------------------------------------
module Numeric.AD.Mode.Tower
  ( AD
  , Tower
  , auto
  -- * Taylor Series
  , taylor
  , taylor0
  -- * Maclaurin Series
  , maclaurin
  , maclaurin0
  -- * Derivatives
  , diff    -- first derivative of (a -> a)
  , diff'   -- answer and first derivative of (a -> a)
  , diffs   -- answer and all derivatives of (a -> a)
  , diffs0  -- zero padded derivatives of (a -> a)
  , diffsF  -- answer and all derivatives of (a -> f a)
  , diffs0F -- zero padded derivatives of (a -> f a)
  -- * Directional Derivatives
  , du      -- directional derivative of (a -> a)
  , du'     -- answer and directional derivative of (a -> a)
  , dus     -- answer and all directional derivatives of (a -> a)
  , dus0    -- answer and all zero padded directional derivatives of (a -> a)
  , duF     -- directional derivative of (a -> f a)
  , duF'    -- answer and directional derivative of (a -> f a)
  , dusF    -- answer and all directional derivatives of (a -> f a)
  , dus0F   -- answer and all zero padded directional derivatives of (a -> a)
  ) where

import qualified Numeric.AD.Rank1.Tower as Rank1
import Numeric.AD.Internal.Tower (Tower)
import Numeric.AD.Internal.Type (AD(..))
import Numeric.AD.Mode

diffs :: Num a => (forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> [a]
diffs :: forall a.
Num a =>
(forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> [a]
diffs forall s. AD s (Tower a) -> AD s (Tower a)
f = (Tower a -> Tower a) -> a -> [a]
forall a. Num a => (Tower a -> Tower a) -> a -> [a]
Rank1.diffs (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (Tower a -> AD Any (Tower a)) -> Tower a -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any (Tower a) -> AD Any (Tower a)
forall s. AD s (Tower a) -> AD s (Tower a)
f(AD Any (Tower a) -> AD Any (Tower a))
-> (Tower a -> AD Any (Tower a)) -> Tower a -> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE diffs #-}

diffs0 :: Num a => (forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> [a]
diffs0 :: forall a.
Num a =>
(forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> [a]
diffs0 forall s. AD s (Tower a) -> AD s (Tower a)
f = (Tower a -> Tower a) -> a -> [a]
forall a. Num a => (Tower a -> Tower a) -> a -> [a]
Rank1.diffs0 (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (Tower a -> AD Any (Tower a)) -> Tower a -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any (Tower a) -> AD Any (Tower a)
forall s. AD s (Tower a) -> AD s (Tower a)
f(AD Any (Tower a) -> AD Any (Tower a))
-> (Tower a -> AD Any (Tower a)) -> Tower a -> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE diffs0 #-}

diffsF :: (Functor f, Num a) => (forall s. AD s (Tower a) -> f (AD s (Tower a))) -> a -> f [a]
diffsF :: forall (f :: * -> *) a.
(Functor f, Num a) =>
(forall s. AD s (Tower a) -> f (AD s (Tower a))) -> a -> f [a]
diffsF forall s. AD s (Tower a) -> f (AD s (Tower a))
f = (Tower a -> f (Tower a)) -> a -> f [a]
forall (f :: * -> *) a.
(Functor f, Num a) =>
(Tower a -> f (Tower a)) -> a -> f [a]
Rank1.diffsF ((AD Any (Tower a) -> Tower a)
-> f (AD Any (Tower a)) -> f (Tower a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(f (AD Any (Tower a)) -> f (Tower a))
-> (Tower a -> f (AD Any (Tower a))) -> Tower a -> f (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any (Tower a) -> f (AD Any (Tower a))
forall s. AD s (Tower a) -> f (AD s (Tower a))
f(AD Any (Tower a) -> f (AD Any (Tower a)))
-> (Tower a -> AD Any (Tower a)) -> Tower a -> f (AD Any (Tower a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE diffsF #-}

diffs0F :: (Functor f, Num a) => (forall s. AD s (Tower a) -> f (AD s (Tower a))) -> a -> f [a]
diffs0F :: forall (f :: * -> *) a.
(Functor f, Num a) =>
(forall s. AD s (Tower a) -> f (AD s (Tower a))) -> a -> f [a]
diffs0F forall s. AD s (Tower a) -> f (AD s (Tower a))
f = (Tower a -> f (Tower a)) -> a -> f [a]
forall (f :: * -> *) a.
(Functor f, Num a) =>
(Tower a -> f (Tower a)) -> a -> f [a]
Rank1.diffs0F ((AD Any (Tower a) -> Tower a)
-> f (AD Any (Tower a)) -> f (Tower a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(f (AD Any (Tower a)) -> f (Tower a))
-> (Tower a -> f (AD Any (Tower a))) -> Tower a -> f (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any (Tower a) -> f (AD Any (Tower a))
forall s. AD s (Tower a) -> f (AD s (Tower a))
f(AD Any (Tower a) -> f (AD Any (Tower a)))
-> (Tower a -> AD Any (Tower a)) -> Tower a -> f (AD Any (Tower a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE diffs0F #-}

taylor :: Fractional a => (forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> a -> [a]
taylor :: forall a.
Fractional a =>
(forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> a -> [a]
taylor forall s. AD s (Tower a) -> AD s (Tower a)
f = (Tower a -> Tower a) -> a -> a -> [a]
forall a. Fractional a => (Tower a -> Tower a) -> a -> a -> [a]
Rank1.taylor (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (Tower a -> AD Any (Tower a)) -> Tower a -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any (Tower a) -> AD Any (Tower a)
forall s. AD s (Tower a) -> AD s (Tower a)
f(AD Any (Tower a) -> AD Any (Tower a))
-> (Tower a -> AD Any (Tower a)) -> Tower a -> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)

taylor0 :: Fractional a => (forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> a -> [a]
taylor0 :: forall a.
Fractional a =>
(forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> a -> [a]
taylor0 forall s. AD s (Tower a) -> AD s (Tower a)
f = (Tower a -> Tower a) -> a -> a -> [a]
forall a. Fractional a => (Tower a -> Tower a) -> a -> a -> [a]
Rank1.taylor0 (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (Tower a -> AD Any (Tower a)) -> Tower a -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any (Tower a) -> AD Any (Tower a)
forall s. AD s (Tower a) -> AD s (Tower a)
f(AD Any (Tower a) -> AD Any (Tower a))
-> (Tower a -> AD Any (Tower a)) -> Tower a -> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE taylor0 #-}

maclaurin :: Fractional a => (forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> [a]
maclaurin :: forall a.
Fractional a =>
(forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> [a]
maclaurin forall s. AD s (Tower a) -> AD s (Tower a)
f = (Tower a -> Tower a) -> a -> [a]
forall a. Fractional a => (Tower a -> Tower a) -> a -> [a]
Rank1.maclaurin (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (Tower a -> AD Any (Tower a)) -> Tower a -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any (Tower a) -> AD Any (Tower a)
forall s. AD s (Tower a) -> AD s (Tower a)
f(AD Any (Tower a) -> AD Any (Tower a))
-> (Tower a -> AD Any (Tower a)) -> Tower a -> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE maclaurin #-}

maclaurin0 :: Fractional a => (forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> [a]
maclaurin0 :: forall a.
Fractional a =>
(forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> [a]
maclaurin0 forall s. AD s (Tower a) -> AD s (Tower a)
f = (Tower a -> Tower a) -> a -> [a]
forall a. Fractional a => (Tower a -> Tower a) -> a -> [a]
Rank1.maclaurin0 (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (Tower a -> AD Any (Tower a)) -> Tower a -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any (Tower a) -> AD Any (Tower a)
forall s. AD s (Tower a) -> AD s (Tower a)
f(AD Any (Tower a) -> AD Any (Tower a))
-> (Tower a -> AD Any (Tower a)) -> Tower a -> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE maclaurin0 #-}

diff :: Num a => (forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> a
diff :: forall a.
Num a =>
(forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> a
diff forall s. AD s (Tower a) -> AD s (Tower a)
f = (Tower a -> Tower a) -> a -> a
forall a. Num a => (Tower a -> Tower a) -> a -> a
Rank1.diff (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (Tower a -> AD Any (Tower a)) -> Tower a -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any (Tower a) -> AD Any (Tower a)
forall s. AD s (Tower a) -> AD s (Tower a)
f(AD Any (Tower a) -> AD Any (Tower a))
-> (Tower a -> AD Any (Tower a)) -> Tower a -> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE diff #-}

diff' :: Num a => (forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> (a, a)
diff' :: forall a.
Num a =>
(forall s. AD s (Tower a) -> AD s (Tower a)) -> a -> (a, a)
diff' forall s. AD s (Tower a) -> AD s (Tower a)
f = (Tower a -> Tower a) -> a -> (a, a)
forall a. Num a => (Tower a -> Tower a) -> a -> (a, a)
Rank1.diff' (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (Tower a -> AD Any (Tower a)) -> Tower a -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.AD Any (Tower a) -> AD Any (Tower a)
forall s. AD s (Tower a) -> AD s (Tower a)
f(AD Any (Tower a) -> AD Any (Tower a))
-> (Tower a -> AD Any (Tower a)) -> Tower a -> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE diff' #-}

du :: (Functor f, Num a) => (forall s. f (AD s (Tower a)) -> AD s (Tower a)) -> f (a, a) -> a
du :: forall (f :: * -> *) a.
(Functor f, Num a) =>
(forall s. f (AD s (Tower a)) -> AD s (Tower a)) -> f (a, a) -> a
du forall s. f (AD s (Tower a)) -> AD s (Tower a)
f = (f (Tower a) -> Tower a) -> f (a, a) -> a
forall (f :: * -> *) a.
(Functor f, Num a) =>
(f (Tower a) -> Tower a) -> f (a, a) -> a
Rank1.du (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (f (Tower a) -> AD Any (Tower a)) -> f (Tower a) -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any (Tower a)) -> AD Any (Tower a)
forall s. f (AD s (Tower a)) -> AD s (Tower a)
f(f (AD Any (Tower a)) -> AD Any (Tower a))
-> (f (Tower a) -> f (AD Any (Tower a)))
-> f (Tower a)
-> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tower a -> AD Any (Tower a))
-> f (Tower a) -> f (AD Any (Tower a))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE du #-}

du' :: (Functor f, Num a) => (forall s. f (AD s (Tower a)) -> AD s (Tower a)) -> f (a, a) -> (a, a)
du' :: forall (f :: * -> *) a.
(Functor f, Num a) =>
(forall s. f (AD s (Tower a)) -> AD s (Tower a))
-> f (a, a) -> (a, a)
du' forall s. f (AD s (Tower a)) -> AD s (Tower a)
f = (f (Tower a) -> Tower a) -> f (a, a) -> (a, a)
forall (f :: * -> *) a.
(Functor f, Num a) =>
(f (Tower a) -> Tower a) -> f (a, a) -> (a, a)
Rank1.du' (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (f (Tower a) -> AD Any (Tower a)) -> f (Tower a) -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any (Tower a)) -> AD Any (Tower a)
forall s. f (AD s (Tower a)) -> AD s (Tower a)
f(f (AD Any (Tower a)) -> AD Any (Tower a))
-> (f (Tower a) -> f (AD Any (Tower a)))
-> f (Tower a)
-> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Tower a -> AD Any (Tower a))
-> f (Tower a) -> f (AD Any (Tower a))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE du' #-}

duF :: (Functor f, Functor g, Num a) => (forall s. f (AD s (Tower a)) -> g (AD s (Tower a))) -> f (a, a) -> g a
duF :: forall (f :: * -> *) (g :: * -> *) a.
(Functor f, Functor g, Num a) =>
(forall s. f (AD s (Tower a)) -> g (AD s (Tower a)))
-> f (a, a) -> g a
duF forall s. f (AD s (Tower a)) -> g (AD s (Tower a))
f = (f (Tower a) -> g (Tower a)) -> f (a, a) -> g a
forall (f :: * -> *) (g :: * -> *) a.
(Functor f, Functor g, Num a) =>
(f (Tower a) -> g (Tower a)) -> f (a, a) -> g a
Rank1.duF ((AD Any (Tower a) -> Tower a)
-> g (AD Any (Tower a)) -> g (Tower a)
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(g (AD Any (Tower a)) -> g (Tower a))
-> (f (Tower a) -> g (AD Any (Tower a)))
-> f (Tower a)
-> g (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any (Tower a)) -> g (AD Any (Tower a))
forall s. f (AD s (Tower a)) -> g (AD s (Tower a))
f(f (AD Any (Tower a)) -> g (AD Any (Tower a)))
-> (f (Tower a) -> f (AD Any (Tower a)))
-> f (Tower a)
-> g (AD Any (Tower a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Tower a -> AD Any (Tower a))
-> f (Tower a) -> f (AD Any (Tower a))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE duF #-}

duF' :: (Functor f, Functor g, Num a) => (forall s. f (AD s (Tower a)) -> g (AD s (Tower a))) -> f (a, a) -> g (a, a)
duF' :: forall (f :: * -> *) (g :: * -> *) a.
(Functor f, Functor g, Num a) =>
(forall s. f (AD s (Tower a)) -> g (AD s (Tower a)))
-> f (a, a) -> g (a, a)
duF' forall s. f (AD s (Tower a)) -> g (AD s (Tower a))
f = (f (Tower a) -> g (Tower a)) -> f (a, a) -> g (a, a)
forall (f :: * -> *) (g :: * -> *) a.
(Functor f, Functor g, Num a) =>
(f (Tower a) -> g (Tower a)) -> f (a, a) -> g (a, a)
Rank1.duF' ((AD Any (Tower a) -> Tower a)
-> g (AD Any (Tower a)) -> g (Tower a)
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(g (AD Any (Tower a)) -> g (Tower a))
-> (f (Tower a) -> g (AD Any (Tower a)))
-> f (Tower a)
-> g (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any (Tower a)) -> g (AD Any (Tower a))
forall s. f (AD s (Tower a)) -> g (AD s (Tower a))
f(f (AD Any (Tower a)) -> g (AD Any (Tower a)))
-> (f (Tower a) -> f (AD Any (Tower a)))
-> f (Tower a)
-> g (AD Any (Tower a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Tower a -> AD Any (Tower a))
-> f (Tower a) -> f (AD Any (Tower a))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE duF' #-}

dus :: (Functor f, Num a) => (forall s. f (AD s (Tower a)) -> AD s (Tower a)) -> f [a] -> [a]
dus :: forall (f :: * -> *) a.
(Functor f, Num a) =>
(forall s. f (AD s (Tower a)) -> AD s (Tower a)) -> f [a] -> [a]
dus forall s. f (AD s (Tower a)) -> AD s (Tower a)
f = (f (Tower a) -> Tower a) -> f [a] -> [a]
forall (f :: * -> *) a.
(Functor f, Num a) =>
(f (Tower a) -> Tower a) -> f [a] -> [a]
Rank1.dus (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (f (Tower a) -> AD Any (Tower a)) -> f (Tower a) -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any (Tower a)) -> AD Any (Tower a)
forall s. f (AD s (Tower a)) -> AD s (Tower a)
f(f (AD Any (Tower a)) -> AD Any (Tower a))
-> (f (Tower a) -> f (AD Any (Tower a)))
-> f (Tower a)
-> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Tower a -> AD Any (Tower a))
-> f (Tower a) -> f (AD Any (Tower a))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE dus #-}

dus0 :: (Functor f, Num a) => (forall s. f (AD s (Tower a)) -> AD s (Tower a)) -> f [a] -> [a]
dus0 :: forall (f :: * -> *) a.
(Functor f, Num a) =>
(forall s. f (AD s (Tower a)) -> AD s (Tower a)) -> f [a] -> [a]
dus0 forall s. f (AD s (Tower a)) -> AD s (Tower a)
f = (f (Tower a) -> Tower a) -> f [a] -> [a]
forall (f :: * -> *) a.
(Functor f, Num a) =>
(f (Tower a) -> Tower a) -> f [a] -> [a]
Rank1.dus0 (AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(AD Any (Tower a) -> Tower a)
-> (f (Tower a) -> AD Any (Tower a)) -> f (Tower a) -> Tower a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any (Tower a)) -> AD Any (Tower a)
forall s. f (AD s (Tower a)) -> AD s (Tower a)
f(f (AD Any (Tower a)) -> AD Any (Tower a))
-> (f (Tower a) -> f (AD Any (Tower a)))
-> f (Tower a)
-> AD Any (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Tower a -> AD Any (Tower a))
-> f (Tower a) -> f (AD Any (Tower a))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE dus0 #-}

dusF :: (Functor f, Functor g, Num a) => (forall s. f (AD s (Tower a)) -> g (AD s (Tower a))) -> f [a] -> g [a]
dusF :: forall (f :: * -> *) (g :: * -> *) a.
(Functor f, Functor g, Num a) =>
(forall s. f (AD s (Tower a)) -> g (AD s (Tower a)))
-> f [a] -> g [a]
dusF forall s. f (AD s (Tower a)) -> g (AD s (Tower a))
f = (f (Tower a) -> g (Tower a)) -> f [a] -> g [a]
forall (f :: * -> *) (g :: * -> *) a.
(Functor f, Functor g, Num a) =>
(f (Tower a) -> g (Tower a)) -> f [a] -> g [a]
Rank1.dusF ((AD Any (Tower a) -> Tower a)
-> g (AD Any (Tower a)) -> g (Tower a)
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(g (AD Any (Tower a)) -> g (Tower a))
-> (f (Tower a) -> g (AD Any (Tower a)))
-> f (Tower a)
-> g (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any (Tower a)) -> g (AD Any (Tower a))
forall s. f (AD s (Tower a)) -> g (AD s (Tower a))
f(f (AD Any (Tower a)) -> g (AD Any (Tower a)))
-> (f (Tower a) -> f (AD Any (Tower a)))
-> f (Tower a)
-> g (AD Any (Tower a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Tower a -> AD Any (Tower a))
-> f (Tower a) -> f (AD Any (Tower a))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE dusF #-}

dus0F :: (Functor f, Functor g, Num a) => (forall s. f (AD s (Tower a)) -> g (AD s (Tower a))) -> f [a] -> g [a]
dus0F :: forall (f :: * -> *) (g :: * -> *) a.
(Functor f, Functor g, Num a) =>
(forall s. f (AD s (Tower a)) -> g (AD s (Tower a)))
-> f [a] -> g [a]
dus0F forall s. f (AD s (Tower a)) -> g (AD s (Tower a))
f = (f (Tower a) -> g (Tower a)) -> f [a] -> g [a]
forall (f :: * -> *) (g :: * -> *) a.
(Functor f, Functor g, Num a) =>
(f (Tower a) -> g (Tower a)) -> f [a] -> g [a]
Rank1.dus0F ((AD Any (Tower a) -> Tower a)
-> g (AD Any (Tower a)) -> g (Tower a)
forall a b. (a -> b) -> g a -> g b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AD Any (Tower a) -> Tower a
forall s a. AD s a -> a
runAD(g (AD Any (Tower a)) -> g (Tower a))
-> (f (Tower a) -> g (AD Any (Tower a)))
-> f (Tower a)
-> g (Tower a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.f (AD Any (Tower a)) -> g (AD Any (Tower a))
forall s. f (AD s (Tower a)) -> g (AD s (Tower a))
f(f (AD Any (Tower a)) -> g (AD Any (Tower a)))
-> (f (Tower a) -> f (AD Any (Tower a)))
-> f (Tower a)
-> g (AD Any (Tower a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
.(Tower a -> AD Any (Tower a))
-> f (Tower a) -> f (AD Any (Tower a))
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Tower a -> AD Any (Tower a)
forall s a. a -> AD s a
AD)
{-# INLINE dus0F #-}