[Haskell-cafe] Beautiful Differentiation using VectorSpace
Christopher Witte
chris at witte.net.au
Fri Aug 13 10:36:02 EDT 2010
Hi all,
I'm trying to go through the paper Beautiful Differentiation by Conal
Elliott and got a bit stuck. So I decided to download the VectorSpace
package, which as far as I know implements the paper, and just try and play
around with it. Unfortunately when I tried the simple examples at the
beginning of the paper I got an error:
Prelude Data.VectorSpace> :m Data.Derivative
Prelude Data.Derivative> let f1 z = sqrt(3*sin z)
Prelude Data.Derivative> f1 (D 2 1)
Top level:
Couldn't match expected type `Data.VectorSpace.Scalar a'
against inferred type `Data.VectorSpace.Scalar
(Data.VectorSpace.Scalar a)'
NB: `Data.VectorSpace.Scalar' is a type function, and may not be
injective
<interactive>:1:0:
No instances for (Data.MemoTrie.HasTrie (Data.Basis.Basis a),
Floating (Data.VectorSpace.Scalar a),
Data.VectorSpace.VectorSpace (Data.VectorSpace.Scalar
a))
arising from a use of `f1' at <interactive>:1:0-9
Possible fix:
add an instance declaration for
(Data.MemoTrie.HasTrie (Data.Basis.Basis a),
Floating (Data.VectorSpace.Scalar a),
Data.VectorSpace.VectorSpace (Data.VectorSpace.Scalar a))
In the expression: f1 (D 2 1)
In the definition of `it': it = f1 (D 2 1)
<interactive>:1:8:
No instance for (Num
(a Data.LinearMap.:-* (a :> Data.VectorSpace.Scalar
a)))
arising from the literal `1' at <interactive>:1:8
Possible fix:
add an instance declaration for
(Num (a Data.LinearMap.:-* (a :> Data.VectorSpace.Scalar a)))
In the second argument of `D', namely `1'
In the first argument of `f1', namely `(D 2 1)'
In the expression: f1 (D 2 1)
Which was completely incomprehensible to me. I tried looking at the
documentation but I couldn't find anything about actually using the
library. Does anyone have any experience using this library and maybe have
some examples of it's use?
Thanks
Chris Witte
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100813/abe350a2/attachment.html
More information about the Haskell-Cafe
mailing list