I am working with Haskell for quite a while now, but I am far from being an expert. But I see that the functional approach to programming suits me the best.
So far I am working on a project to calculate some serious stuff, like currents and potentials radiated from a given structure.
I followed the blog written by Conal Elliott (here is some more Linear Maps) which is very nice and fundamental.
Unfortunately, I am lacking a simple example :)
To be more precise, I have a curve
f:[0,1] in R -> R³
t -> a*e_y + 2*t*e_z
which is a simple straight line at (0,a,2*t). When I want to calculate the derivative of f, e.g. for the length of the curve, I know the mathematical result, which is quite simple (0,0,2), but how do I accomplish this in Haskell, especially with the vector-space package?
I really want to use this library because of its functionality, it is exactly the approach I would have take too (but I am not that far ahead on the Haskell road)
What I have so far is this:
{-# LANGUAGE Rank2Types, TypeOperators, FlexibleContexts, TypeFamilies #-}
{-# OPTIONS_GHC -Wall #-}
import Numeric.GSL.Integration
import Data.VectorSpace
import Data.Basis
import Data.Cross
import Data.Derivative
import Data.LinearMap
type Vec3 s = Three s
prec :: Double
prec = 1E-9
f1 :: (Floating s, VectorSpace s, Scalar s ~ s) => s -> s
f1 = id
c1 :: Double -> Vec3 Double
c1 = \t -> linearCombo [((v 0 0 1),f1 t),(( v 0 1 0),2)]
derivC :: Double -> Vec3 (Double :> Double)
derivC t = c1 (pureD t)
It is the the actual implementation of the pureD function, so far nothing that I have tried works to get this snippet to compile. I get the following error:
tests.hs:26:12:
Couldn't match expected type `Double :> Double'
with actual type `Double'
Expected type: Vec3 (Double :> Double)
Actual type: Vec3 Double
In the return type of a call of `c1'
In the expression: c1 (pureD t)
Failed, modules loaded: none.
There is also a graphics library which uses vector-space and there is even an example on a torus, where pureD is used. I tried to deduce the example but I don't see how I can map it to my problem.
Any help would be greatly appreciated.
Thanks in advance
PS: I cannot post all the links I'd like to, but am willing to provide