Fractional precedences? Re: Operator precedence help

Carter Schonwald carter.schonwald at gmail.com
Mon Aug 17 01:49:53 UTC 2020


I do think that the work needed to actually support fractional precedence
in ghc is pretty minimal.  Or at least I remember having a conversation
about it a few years ago, and the conclusion was that  adding precedence
would be super easy to do, but just lacked any good motivating example from
real libraries.

David, maybe you could help with  that from the examples side of things?

On Sun, Aug 16, 2020 at 1:27 AM David Feuer <david.feuer at gmail.com> wrote:

> It sure does seem crowded around there. I'd love to have 4.5 or 5.5. Going
> up to 6 runs into arithmetic. Going down to 4 hits up against Functor and
> Applicative stuff, which is a tad unfortunate but I think probably not as
> bad in practice. So I think I'll go with 4 and 5. Thanks, y'all!
>
> On Sun, Aug 16, 2020, 1:04 AM Henning Thielemann <
> lemming at henning-thielemann.de> wrote:
>
>>
>> On Sat, 15 Aug 2020, David Feuer wrote:
>>
>> > Data.Sequence uses the same precedence for both, which strikes me as a
>> bit sad.
>> > Surprisingly, I am not seeing other packages on Hackage that define
>> similar
>> > operators.
>>
>> I have the same problem in the 'lapack' bindings.
>>
>> I like to allow people to write
>>
>>    (row) vector -*# matrix #*# matrix #*| (column) vector
>>
>>
>> I had no good idea, though, and also chose equal precedence for all
>> operators.
>>
>>
>> > On Thu, Aug 13, 2020 at 2:50 PM Andreas Abel <andreas.abel at ifi.lmu.de>
>> wrote:
>> >>
>> >> My hunch would be too look at what the others do to form an opinion.
>> >>
>> >> On 2020-08-13 19:26, David Feuer wrote:
>> >> > I'm trying to work out appropriate precedences for operators and
>> pattern
>> >> > synonyms in my brand-new compact-sequences package. I currently have
>> >> > stacks and queues, but I will soon have deques, so let's pretend. For
>> >> > consistency, operators will match pattern synonyms.
>> >> >
>> >> > (<|), pattern (:<) :: a -> Deque a -> Deque a
>> >> > (|>), pattern (:>) :: Deque a -> a -> Deque a
>> >> >
>> >> > :< and :> need to have different precedence to allow things like
>> >> >
>> >> >    a :< b :< xs :> c :> d
>> >> >
>> >> > to work nicely, but what numbers should I pick?
>> >> >
>> >> > I also have cons and snoc functions. Should I give their backticked
>> >> > spellings fixity declarations? If so, with what precedences?
>>
>> I would give them the precedence of their infix counterparts.
>>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20200816/0dac6ee4/attachment.html>


More information about the Libraries mailing list