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

Edward Kmett ekmett at gmail.com
Mon Mar 30 18:02:20 UTC 2015


Then, tentatively, I'll file an issue and make the change for next time we
push out linear.

-Edward

On Mon, Mar 30, 2015 at 12:16 PM, Brent Yorgey <byorgey at gmail.com> wrote:

> Sorry for the delay in responding.  I am not sure what it would mean to
> multiply matrices where one or both dimensions are given by Points.
> Indeed, such things seem very strange, precisely because Points are not
> additive.  I am certainly in favor of removing the instance, and I doubt
> anyone will miss being able to make Point-structured matrices.
>
> -Brent
>
>
> On Wed, Mar 18, 2015 at 1:23 PM Edward Kmett <ekmett at gmail.com> wrote:
>
>> On Tue, Mar 17, 2015 at 10:41 PM, Brent Yorgey <byorgey at gmail.com> wrote:
>>
>>> 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.
>>>
>>>
>> The name Additive is a bit of a misnomer, like you said. The real reason
>> it exists is to support matrix operations on both sparse/dense matrices.
>>
>> Matrix multiplication looks like:
>>
>> (!*!) :: (Functor m, Foldable t, Additive t, Additive n, Num a) => m (t
>> a) -> t (n a) -> m (n a)
>>
>> Without that instance you'd be unable to build matrices with Point's as
>> one or both of the dimensions, which are intended to transform points.
>>
>> If we can decide that that doesn't make sense (as after all points aren't
>> additive), so such matrices _are_ kinda weird, we can remove the instance.
>>
>> I'm happy to bend the way Point works, as I stick to the projective
>> machinery almost exclusively, myself.
>>
>> Thoughts?
>>
>> -Edward
>>
>> 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
>>>>
>>>
>>> _______________________________________________
>>> 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/20150330/4f3857ff/attachment.html>


More information about the Haskell-Cafe mailing list