These are chat archives for non/algebra

14th
Jan 2016
Ben Hutchison
@benhutchison
Jan 14 2016 07:33

I have a situation where I'd like to treat a number tuple as 2D Vector ietype Vec2d = (Double, Double). Only need to support Addition and Subtraction operations. Whats the smallest typeclass I can implement (or better, import..) that will give me element-wise +& - over(Double, Double)?

FWIW I ended up finding answers to my question about working with 2D vectors and algebra:

  1. The minimal typeclass for plus and minus is AdditiveGroup, but there's no syntax yet for infix + and -operators
  2. There are auto-generated instances for (Double, Double) in master, after you first sbt compile, but added after the published 0.3.1 jar so wont find in maven
  3. Unfortunately I realized I also need Euclidean distance between 2 vectors. Algebra currently doesn't offer a MetricSpace typeclass that would expose a distance operator. Given that Spire and Algebird do offer it, could it be added to algebra?
Erik Osheim
@striation
Jan 14 2016 13:27
@benhutchison i think metric spaces are potentially on the table, but maybe in a separate module
(i could imagine that same module also supporting group actions, torsors, vector spaces, and so on)
Tom Switzer
@tixxit
Jan 14 2016 15:24
Any reason to not just use Spire?
Rather than add it to algebra?
(ie is it actually used much in algebird that it is worth sharing?)
Erik Osheim
@non
Jan 14 2016 15:31
that's a good question. @johnynek do you know if algebird's metric spaces get a lot of use?
InTheNow
@InTheNow
Jan 14 2016 16:11
[(poor) Humor: "Contrary to all known FP best practices, @non intentionally mutated himself]
Erik Osheim
@non
Jan 14 2016 16:33
hahaha
non @non is actually quite unprincipled
InTheNow
@InTheNow
Jan 14 2016 16:33
:)
Dale Wijnand
@dwijnand
Jan 14 2016 16:38
do as I say not as I do :P
P. Oscar Boykin
@johnynek
Jan 14 2016 23:00
@non It does not get a lot of use, but it had some bit of use at Twitter