
Nathan Hüsken
Hey Thanks for the answer one thing to discuss remains for me: With applicative I could add TimeSeries like this:
print $ (+) <$> pure 4 <*> times (+) <$> times1 <*> times2
ok .. but actually I find that (for this case) clumpsy. I would much prefer to write times1 + times2 (especially in complex cases):
(times1 + times2)/(times3 * times4)
Don't you agree? Or do I oversee something?
I admit that applicative notation isn't quite as convenient as working with arithmetic expressions. As I've said in the past, overloading Num isn't terribly desireable as you'll pretty much need to resign yourself to partial implementations of some of the class members. A middle path would be to instead define your own combinators for the operations you need. For instance, %+% :: Num a => TimeSeries a -> TimeSeries a -> TimeSeries a %+% a b = (+) <$> a <*> b %*% :: Num a => TimeSeries a -> TimeSeries a -> TimeSeries a %*% a b = (*) <$> a <*> b ... For at least some of these you could (ab)use the additive group classes provided by vector-space[1] and linear[2] although there's no such class for point-wise multiplication. Cheers, - Ben [1] http://hackage.haskell.org/package/vector-space-0.7.1/docs/Data-AdditiveGrou... [2] http://hackage.haskell.org/package/linear-1.3/docs/Linear-Vector.html