Correct behaviour of Bounded (Down a)

Carter Schonwald carter.schonwald at gmail.com
Mon Sep 21 18:28:18 UTC 2020


i mean, if we straightup cant have a coherent definition for it, by
all means! (i think one lint for stuff being in base is "is there
reasonably a unique most general usable defiinition/ semantics/meaning",
and perhaps we dont have one here?)

On Mon, Sep 21, 2020 at 1:47 PM David Beacham <mail at dbeacham.co.uk> wrote:

> I think that would be my preferred solution
>
> You can keep the numbering the same in the Enum instance if you wish and
> hide the negation in the implementation, but I'm not convince the Enum
> instance is of general use.
>
>
>
> On Mon, Sep 21, 2020 at 6:21 PM David Feuer <david.feuer at gmail.com> wrote:
>
>> That strikes me as quite reasonable.
>>
>> On Mon, Sep 21, 2020, 1:09 PM Krzysztof Gogolewski <
>> krz.gogolewski at gmail.com> wrote:
>>
>>> I would consider removing Enum a => Enum (Down a), and fixing Bounded
>>> (Down a).
>>>
>>> There isn't really a good equivalent of `enumFromThenTo` for Down and
>>> performing negation in `toEnum` is not obvious to me.
>>>
>>> On Sat, Sep 19, 2020 at 3:00 AM Kim-Ee Yeoh <ky3 at atamo.com> wrote:
>>> >
>>> >
>>> >
>>> > On Sat, Sep 19, 2020 at 1:34 AM Asad Saeeduddin <masaeedu at gmail.com>
>>> wrote:
>>> >>
>>> >> This is something I've never understood about `Enum`. How can a
>>> >>
>>> >> type be in bijection with the integers, but simultaneously have a
>>> >>
>>> >> minimum and maximum bound?
>>> >
>>> >
>>> > It's not a bijection with the integers.
>>> >
>>> > In the method fromEnum :: a -> Int, the Int stands in for the disjoint
>>> sum of all possible types with an Enum instance.
>>> >
>>> > And the way Int finesses that impersonation is by conflating together
>>> the parts of the disjoint sum.
>>> >
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On 9/18/20 10:40 AM, Oleg Grenrus
>>> >>
>>> >> wrote:
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> Is it (a bug)?
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> What about [minBound .. maxBound]. If you change `Bounded`, you
>>> >>
>>> >> need to change `Enum` too.
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> From
>>> >>
>>> >>
>>> https://hackage.haskell.org/package/base-4.14.0.0/docs/GHC-Enum.html#t:Enum
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> - The calls succ maxBound and pred minBound should result in a
>>> >>
>>> >> runtime error.
>>> >>
>>> >>
>>> >> - enumFrom and enumFromThen should be defined with an implicit
>>> >>
>>> >> bound
>>> >>
>>> >>
>>> >>
>>> >> The `min` and `max` in `minBound/maxBound` are related to
>>> >>
>>> >> `succ`, `pred`, not to `compare`. If you argue against, then we
>>> >>
>>> >> should add `Ord` super-class to `Enum` (and `Bounded`).
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> - Oleg
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On 18.9.2020 16.54, Carter Schonwald
>>> >>
>>> >> wrote:
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> Def a bug! Plz at myself and the core libraries
>>> >>
>>> >> handle for code review plz.
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> This sounds kinda related to an MR that has
>>> >>
>>> >> languished too long regarding the behavior of Down on Ord1,
>>> >>
>>> >> which I think is related??? (I tried to arbitrate / layout
>>> >>
>>> >> possible answers for the related issue in the associated mr,
>>> >>
>>> >> but none of the clc members have engaged in the design space
>>> >>
>>> >> challenge)
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On Fri, Sep 18, 2020 at
>>> >>
>>> >> 7:44 AM David Beacham <mail at dbeacham.co.uk>
>>> >>
>>> >> wrote:
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> Hi all,
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> The current instance for `Bounded a => Bounded
>>> >>>
>>> >>> (Down a)` derives the `minBound` and `maxBound`
>>> >>>
>>> >>> exactly as they are for the underlying type `a` where
>>> >>>
>>> >>> I think they should be flipped to respect the flipped
>>> >>>
>>> >>> ordering of `Down a`?
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> I have a feeling this has been come up in some
>>> >>>
>>> >>> other context/list before but I couldn't find a
>>> >>>
>>> >>> reference to it when searching - so sorry if this is a
>>> >>>
>>> >>> duplicate.
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> I've got a corresponding MR here:
>>> https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4081
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> Thanks, David.
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> _______________________________________________
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> Libraries mailing list
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> Libraries at haskell.org
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >>
>>> >> Libraries mailing list
>>> >>
>>> >> Libraries at haskell.org
>>> >>
>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >>
>>> >> Libraries mailing list
>>> >>
>>> >> Libraries at haskell.org
>>> >>
>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >>
>>> >> Libraries mailing list
>>> >>
>>> >> Libraries at haskell.org
>>> >>
>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>> >>
>>> > --
>>> > -- Kim-Ee
>>> > _______________________________________________
>>> > Libraries mailing list
>>> > Libraries at haskell.org
>>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>> _______________________________________________
>>> Libraries mailing list
>>> Libraries at haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
> _______________________________________________
> 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/20200921/4d392fa4/attachment.html>


More information about the Libraries mailing list