Sean Matthews seanmatthews1 at gmail.com
Tue Nov 21 12:24:55 UTC 2017

```After working through the other problems, that fills the last remaining
hole (at least for the moment).

Many thanks,

Sean

On Tue, Nov 21, 2017 at 7:48 AM, Li-yao Xia <lysxia at gmail.com> wrote:

> Hi Sean,
>
> differentiated.
>
> f :: Num a => m1 (m2 a) -> m3 a -> a
>
> By looking at the type of "grad", one can see that f will be specialized
> at type "Reverse s Double":
>
> f :: m1 (m2 (Reverse s Double)) -> m3 (Reverse s Double) -> Reverse s
> Double
>
> So if "x :: m1 (m2 Double)", you will need to apply "auto :: Double ->
> Reverse s Double" to lift x to the right type.
>
> df x theta = grad (f x') theta
>   where x' = (fmap . fmap) auto x
>
> Cheers,
> Li-yao
>
> On 11/20/2017 05:05 PM, Sean Matthews wrote:
>
>> I'm having some problems with Numeric.AD (translation, things are not
>> working for reason that I don't understand).  Note I don't have much
>> experience with this package, so these are newbie questions, thus
>> appropriate answers may involve pointing me to a document somewhere out
>> there on the net.
>>
>> Anyway,  here is my problem:
>>
>> I have a function (call it f x theta) which I have defined purely in terms
>> of basic arithmetic functions  (+/-/(/)/*/**) glued together using
>> standard
>> applicative functor operations has type
>>
>> f  :: m1 (m2 Double) -> m3 Double -> Double
>> f x theta = ...
>>
>> m1 m2 and m3 are all Traversable.
>> f is defined purely in terms of basic arithmetic operations,
>> (+/-/(/)/*/**)
>> glued together using standard applicative functor operations, and m1 m2
>> and
>> m3 are all pretty trivial record types (no recursion, even).
>>
>> I would like to write
>>
>> df x theta = grad (f x) theta
>>
>> But it refuses to type, even though (admittedly quite a lot) simpler
>> versions do.
>>
>> So what am I missing? Does AD not go through Applicative?  That seems
>> unlikely to me.
>>
>>
>> Sean Matthews
>>
>>
>>
>>
>>
>> _______________________________________________
>> To (un)subscribe, modify options or view archives go to:
>> Only members subscribed via the mailman list are allowed to post.
>>
>>

--
Sean Matthews
seanmatthews1 at gmail.com / +49 1515 800 1901
-------------- next part --------------
An HTML attachment was scrubbed...