[Haskell-cafe] linear: instance Additive (Point f) ??

Brent Yorgey byorgey at gmail.com
Wed Mar 18 02:41:36 UTC 2015


I have EXACTLY the same question.  We recently switched from vector-space
to linear for diagrams.  There are quite a lot of reasons why this works
really well for us.  But I was very sad to find that we can now add points,
which indeed we do not want to be able to do.  At least there are still
different types for points and vectors, which allows transformations like
'translate' to act on them differently, which I actually find to be much
more critical from a correctness point of view.

I have had a brief explanation, but I forget the exact details.  Something
about 'Additive' not really being about 'additive groups' but instead being
a superclass of Applicative.  I remember being convinced at least that it's
a "pick your poison" sort of choice, i.e. removing the Additive instance
for Point would make certain other things ugly/annoying.  Hopefully someone
else can chime in with more detail.

-Brent

On Tue, Mar 17, 2015 at 5:47 PM Richard Eisenberg <eir at cis.upenn.edu> wrote:

> Hi café,
>
> I'm in the middle of responding to https://github.com/goldfirere/
> units/pull/45 and trying to learn the `linear` package, which I have yet
> to use.
>
> I have what may be a basic question: why is there an `instance Additive f
> => Additive (Point f)` (in the Affine module)? It would seem that the whole
> point of Point is that it is *not* Additive. We don't want to add Points!
>
> Could someone enlighten me?
>
> Thanks!
> Richard
>
> PS: Of course, this instance is directly hurting my use of the package.
> But it is hurting my understanding of the package, because it disagrees
> with the mental model I've built up of the definitions.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150318/0bbcdc35/attachment.html>


More information about the Haskell-Cafe mailing list