Correct behaviour of Bounded (Down a)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

Correct behaviour of Bounded (Down a)

David Beacham-2
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.


Thanks, David.

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Carter Schonwald
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 <[hidden email]> 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.


Thanks, David.


_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Oleg Grenrus

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 <[hidden email]> 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.


Thanks, David.


_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

David Feuer
We should add an Ord constraint to Enum and Bounded. The more constraints we add to Enum, the fewer instances we will have and the sooner my ultimate goal of removing it altogether will be achieved. Mwahahahaha!

On Fri, Sep 18, 2020, 10:41 AM Oleg Grenrus <[hidden email]> 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 <[hidden email]> 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.


Thanks, David.


_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

David Beacham-2
In reply to this post by Oleg Grenrus
That is a good spot - I had wondered if the minBound/maxBound changes would affect other classes but had missed Enum.

I wouldn't be surprised that `Down a` had a reversed enumeration despite the `Ord`/`Enum` separation.

Looking at the `Bounded` docs

> The Bounded class is used to name the upper and lower limits of a type. Ord is not a superclass of Bounded since types that are not totally ordered may also have upper and lower bounds.

does suggest that flipping minBound and maxBound is correct? That would then require `Enum a => Enum (Down a)` should also be flipped given the way it interacts with `Bounded`?

I think the instance is achievable by

1. flipping pred/succ
2. carefully using "negated Int"s when looking at `fromEnumThenTo` etc.

I think you get the choice of keeping the same `Int` conversions, `toEnum = Down . toEnum`, or negating it, `toEnum = Down . toEnum . negate`, so e.g. 0 -> False, 1 -> True becomes 0 -> Down False, -1 -> Down True.

I can add potential implementations to the MR so that there is something concrete to look at (and check it all works) or do it here.

But I think it all needs a bit more discussion than I'd initially thought!

David.

On Fri, Sep 18, 2020 at 3:41 PM Oleg Grenrus <[hidden email]> 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 <[hidden email]> 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.


Thanks, David.


_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Carter Schonwald
In reply to this post by David Feuer
Indeed. Enum as it’s currently defined is totally broken and actively a bad interface :)

On Fri, Sep 18, 2020 at 11:04 AM David Feuer <[hidden email]> wrote:
We should add an Ord constraint to Enum and Bounded. The more constraints we add to Enum, the fewer instances we will have and the sooner my ultimate goal of removing it altogether will be achieved. Mwahahahaha!

On Fri, Sep 18, 2020, 10:41 AM Oleg Grenrus <[hidden email]> 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 <[hidden email]> 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.














Thanks, David.












_______________________________________________





Libraries mailing list





[hidden email]





http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
















_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries









_______________________________________________


Libraries mailing list


[hidden email]


http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries




_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Ganesh Sittampalam
In reply to this post by David Beacham-2

Is the fundamental question whether we require that types that implement both Ord and Enum have these laws?

succ x > x

x > y == fromEnum x > fromEnum y

If we require it then this change is mandatory, if we don't require that then it's optional and whatever argument we have against the laws might be an argument against this change.


On 18/09/2020 17:19, David Beacham wrote:
That is a good spot - I had wondered if the minBound/maxBound changes would affect other classes but had missed Enum.

I wouldn't be surprised that `Down a` had a reversed enumeration despite the `Ord`/`Enum` separation.

Looking at the `Bounded` docs

> The Bounded class is used to name the upper and lower limits of a type. Ord is not a superclass of Bounded since types that are not totally ordered may also have upper and lower bounds.

does suggest that flipping minBound and maxBound is correct? That would then require `Enum a => Enum (Down a)` should also be flipped given the way it interacts with `Bounded`?

I think the instance is achievable by

1. flipping pred/succ
2. carefully using "negated Int"s when looking at `fromEnumThenTo` etc.

I think you get the choice of keeping the same `Int` conversions, `toEnum = Down . toEnum`, or negating it, `toEnum = Down . toEnum . negate`, so e.g. 0 -> False, 1 -> True becomes 0 -> Down False, -1 -> Down True.

I can add potential implementations to the MR so that there is something concrete to look at (and check it all works) or do it here.

But I think it all needs a bit more discussion than I'd initially thought!

David.

On Fri, Sep 18, 2020 at 3:41 PM Oleg Grenrus <[hidden email]> 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 <[hidden email]> 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.


Thanks, David.


_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

David Beacham-2
I think the fundamental question is what is fundamental to `Bounded`/`Enum`?

1. Do the suggested `Bounded` laws:

     minBound <= x
     maxBound >= x

   hold independently of an `Enum` instance? The docs suggests the `Ord` constraint on `Bounded` is only missing because there is no partial ordering class in base.

2. Are `Enum`/`Bounded` defined as a pair that is independent of `Ord` with `minBound`/`maxBound` only reasoned about in the context of a possible `Enum` instance.

With (1) we get the problematic derived `Enum a => Enum (Down a)` instance because that gives e.g. `succ (maxBound :: Down Bool) = succ (Down False) = (derived instance uses underlying Enum) = succ False = True /= error`

In this instance, would need a different `Enum a => Enum (Down a)` instance where the laws you suggest would fix the choice of `fromEnum` to one of the form `fromEnum = negate . fromEnum . getDown` rather than `fromEnum = fromEnum . getDown`.

With (2), everything works OK and as before for `Enum`/`Bounded` but we do get e.g. `forall (x :: Down Int). minBound @(Down Int) >= x`.

David.

On Fri, Sep 18, 2020 at 5:57 PM Ganesh Sittampalam <[hidden email]> wrote:

Is the fundamental question whether we require that types that implement both Ord and Enum have these laws?

succ x > x

x > y == fromEnum x > fromEnum y

If we require it then this change is mandatory, if we don't require that then it's optional and whatever argument we have against the laws might be an argument against this change.


On 18/09/2020 17:19, David Beacham wrote:
That is a good spot - I had wondered if the minBound/maxBound changes would affect other classes but had missed Enum.

I wouldn't be surprised that `Down a` had a reversed enumeration despite the `Ord`/`Enum` separation.

Looking at the `Bounded` docs

> The Bounded class is used to name the upper and lower limits of a type. Ord is not a superclass of Bounded since types that are not totally ordered may also have upper and lower bounds.

does suggest that flipping minBound and maxBound is correct? That would then require `Enum a => Enum (Down a)` should also be flipped given the way it interacts with `Bounded`?

I think the instance is achievable by

1. flipping pred/succ
2. carefully using "negated Int"s when looking at `fromEnumThenTo` etc.

I think you get the choice of keeping the same `Int` conversions, `toEnum = Down . toEnum`, or negating it, `toEnum = Down . toEnum . negate`, so e.g. 0 -> False, 1 -> True becomes 0 -> Down False, -1 -> Down True.

I can add potential implementations to the MR so that there is something concrete to look at (and check it all works) or do it here.

But I think it all needs a bit more discussion than I'd initially thought!

David.

On Fri, Sep 18, 2020 at 3:41 PM Oleg Grenrus <[hidden email]> 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 <[hidden email]> 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.


Thanks, David.


_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Asad Saeeduddin
In reply to this post by Oleg Grenrus

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?

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 <[hidden email]> 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.


Thanks, David.


_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Carter Schonwald
Good questions!

1) enum unfortunately uses int 

2) there’s no reason for there not to be lots of bijections! The barrier or obstacle I think you’re envisioning is if you want the bijection to preserve ordering. Right?

On Fri, Sep 18, 2020 at 2:34 PM Asad Saeeduddin <[hidden email]> 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?




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 <[hidden email]>

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.














Thanks, David.












_______________________________________________





Libraries mailing list





[hidden email]





http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
















_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries










_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries









_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Kim-Ee Yeoh
Administrator
In reply to this post by Asad Saeeduddin


On Sat, Sep 19, 2020 at 1:34 AM Asad Saeeduddin <[hidden email]> 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 <[hidden email]>

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.














Thanks, David.












_______________________________________________





Libraries mailing list





[hidden email]





http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
















_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries










_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries









_______________________________________________

Libraries mailing list

[hidden email]

http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

--
-- Kim-Ee

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Krzysztof Gogolewski
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 <[hidden email]> wrote:

>
>
>
> On Sat, Sep 19, 2020 at 1:34 AM Asad Saeeduddin <[hidden email]> 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 <[hidden email]>
>>
>> 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
>>>
>>>
>>>
>>>
>>>
>>> [hidden email]
>>>
>>>
>>>
>>>
>>>
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
> --
> -- Kim-Ee
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

David Feuer
That strikes me as quite reasonable.

On Mon, Sep 21, 2020, 1:09 PM Krzysztof Gogolewski <[hidden email]> 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 <[hidden email]> wrote:
>
>
>
> On Sat, Sep 19, 2020 at 1:34 AM Asad Saeeduddin <[hidden email]> 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 <[hidden email]>
>>
>> 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
>>>
>>>
>>>
>>>
>>>
>>> [hidden email]
>>>
>>>
>>>
>>>
>>>
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
> --
> -- Kim-Ee
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

David Beacham-2
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 <[hidden email]> wrote:
That strikes me as quite reasonable.

On Mon, Sep 21, 2020, 1:09 PM Krzysztof Gogolewski <[hidden email]> 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 <[hidden email]> wrote:
>
>
>
> On Sat, Sep 19, 2020 at 1:34 AM Asad Saeeduddin <[hidden email]> 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 <[hidden email]>
>>
>> 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
>>>
>>>
>>>
>>>
>>>
>>> [hidden email]
>>>
>>>
>>>
>>>
>>>
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
> --
> -- Kim-Ee
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Carter Schonwald
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 <[hidden email]> 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 <[hidden email]> wrote:
That strikes me as quite reasonable.

On Mon, Sep 21, 2020, 1:09 PM Krzysztof Gogolewski <[hidden email]> 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 <[hidden email]> wrote:
>
>
>
> On Sat, Sep 19, 2020 at 1:34 AM Asad Saeeduddin <[hidden email]> 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 <[hidden email]>
>>
>> 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
>>>
>>>
>>>
>>>
>>>
>>> [hidden email]
>>>
>>>
>>>
>>>
>>>
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
> --
> -- Kim-Ee
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Edward Kmett-2
The lack of a coherent notion for Enum seems to indicate it fails the uniquely/conventionally defined meaning for me. In particular enumFrom has to make some awkward choices to flip sense; it can't probe for pred without introducing spurious bottoms. It seems to me the only sensible action there is to rip out the instance.

-Edward

On Mon, Sep 21, 2020 at 11:29 AM Carter Schonwald <[hidden email]> wrote:
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 <[hidden email]> 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 <[hidden email]> wrote:
That strikes me as quite reasonable.

On Mon, Sep 21, 2020, 1:09 PM Krzysztof Gogolewski <[hidden email]> 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 <[hidden email]> wrote:
>
>
>
> On Sat, Sep 19, 2020 at 1:34 AM Asad Saeeduddin <[hidden email]> 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 <[hidden email]>
>>
>> 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
>>>
>>>
>>>
>>>
>>>
>>> [hidden email]
>>>
>>>
>>>
>>>
>>>
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>
>> Libraries mailing list
>>
>> [hidden email]
>>
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
> --
> -- Kim-Ee
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Krzysztof Gogolewski
Should we go forward with removing Enum for Down?

On Tue, Sep 22, 2020 at 7:57 PM Edward Kmett <[hidden email]> wrote:

>
> The lack of a coherent notion for Enum seems to indicate it fails the uniquely/conventionally defined meaning for me. In particular enumFrom has to make some awkward choices to flip sense; it can't probe for pred without introducing spurious bottoms. It seems to me the only sensible action there is to rip out the instance.
>
> -Edward
>
> On Mon, Sep 21, 2020 at 11:29 AM Carter Schonwald <[hidden email]> wrote:
>>
>> 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 <[hidden email]> 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 <[hidden email]> wrote:
>>>>
>>>> That strikes me as quite reasonable.
>>>>
>>>> On Mon, Sep 21, 2020, 1:09 PM Krzysztof Gogolewski <[hidden email]> 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 <[hidden email]> wrote:
>>>>> >
>>>>> >
>>>>> >
>>>>> > On Sat, Sep 19, 2020 at 1:34 AM Asad Saeeduddin <[hidden email]> 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 <[hidden email]>
>>>>> >>
>>>>> >> 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
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>> [hidden email]
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >> _______________________________________________
>>>>> >>
>>>>> >> Libraries mailing list
>>>>> >>
>>>>> >> [hidden email]
>>>>> >>
>>>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >> _______________________________________________
>>>>> >>
>>>>> >> Libraries mailing list
>>>>> >>
>>>>> >> [hidden email]
>>>>> >>
>>>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> >> _______________________________________________
>>>>> >>
>>>>> >> Libraries mailing list
>>>>> >>
>>>>> >> [hidden email]
>>>>> >>
>>>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>>> >>
>>>>> > --
>>>>> > -- Kim-Ee
>>>>> > _______________________________________________
>>>>> > Libraries mailing list
>>>>> > [hidden email]
>>>>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>>> _______________________________________________
>>>>> Libraries mailing list
>>>>> [hidden email]
>>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>>
>>>> _______________________________________________
>>>> Libraries mailing list
>>>> [hidden email]
>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>>
>>> _______________________________________________
>>> Libraries mailing list
>>> [hidden email]
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>> _______________________________________________
>> Libraries mailing list
>> [hidden email]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

Carter Schonwald
Yup! Seems like there’s a pretty clear concensus that it just kinda makes zero sense 

On Mon, Oct 5, 2020 at 10:21 AM Krzysztof Gogolewski <[hidden email]> wrote:
Should we go forward with removing Enum for Down?



On Tue, Sep 22, 2020 at 7:57 PM Edward Kmett <[hidden email]> wrote:

>

> The lack of a coherent notion for Enum seems to indicate it fails the uniquely/conventionally defined meaning for me. In particular enumFrom has to make some awkward choices to flip sense; it can't probe for pred without introducing spurious bottoms. It seems to me the only sensible action there is to rip out the instance.

>

> -Edward

>

> On Mon, Sep 21, 2020 at 11:29 AM Carter Schonwald <[hidden email]> wrote:

>>

>> 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 <[hidden email]> 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 <[hidden email]> wrote:

>>>>

>>>> That strikes me as quite reasonable.

>>>>

>>>> On Mon, Sep 21, 2020, 1:09 PM Krzysztof Gogolewski <[hidden email]> 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 <[hidden email]> wrote:

>>>>> >

>>>>> >

>>>>> >

>>>>> > On Sat, Sep 19, 2020 at 1:34 AM Asad Saeeduddin <[hidden email]> 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 <[hidden email]>

>>>>> >>

>>>>> >> 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

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>> [hidden email]

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >> _______________________________________________

>>>>> >>

>>>>> >> Libraries mailing list

>>>>> >>

>>>>> >> [hidden email]

>>>>> >>

>>>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >> _______________________________________________

>>>>> >>

>>>>> >> Libraries mailing list

>>>>> >>

>>>>> >> [hidden email]

>>>>> >>

>>>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >> _______________________________________________

>>>>> >>

>>>>> >> Libraries mailing list

>>>>> >>

>>>>> >> [hidden email]

>>>>> >>

>>>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>> >>

>>>>> > --

>>>>> > -- Kim-Ee

>>>>> > _______________________________________________

>>>>> > Libraries mailing list

>>>>> > [hidden email]

>>>>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>> _______________________________________________

>>>>> Libraries mailing list

>>>>> [hidden email]

>>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>

>>>> _______________________________________________

>>>> Libraries mailing list

>>>> [hidden email]

>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>

>>> _______________________________________________

>>> Libraries mailing list

>>> [hidden email]

>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>

>> _______________________________________________

>> Libraries mailing list

>> [hidden email]

>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>

> _______________________________________________

> Libraries mailing list

> [hidden email]

> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Correct behaviour of Bounded (Down a)

David Beacham-2
OK - I'll update the MR and tag the necessary people for code review.

FYI - removing the Enum instance requires removing the Integral instance too.

David.

On Mon, Oct 5, 2020 at 4:54 PM Carter Schonwald <[hidden email]> wrote:
Yup! Seems like there’s a pretty clear concensus that it just kinda makes zero sense 

On Mon, Oct 5, 2020 at 10:21 AM Krzysztof Gogolewski <[hidden email]> wrote:
Should we go forward with removing Enum for Down?



On Tue, Sep 22, 2020 at 7:57 PM Edward Kmett <[hidden email]> wrote:

>

> The lack of a coherent notion for Enum seems to indicate it fails the uniquely/conventionally defined meaning for me. In particular enumFrom has to make some awkward choices to flip sense; it can't probe for pred without introducing spurious bottoms. It seems to me the only sensible action there is to rip out the instance.

>

> -Edward

>

> On Mon, Sep 21, 2020 at 11:29 AM Carter Schonwald <[hidden email]> wrote:

>>

>> 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 <[hidden email]> 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 <[hidden email]> wrote:

>>>>

>>>> That strikes me as quite reasonable.

>>>>

>>>> On Mon, Sep 21, 2020, 1:09 PM Krzysztof Gogolewski <[hidden email]> 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 <[hidden email]> wrote:

>>>>> >

>>>>> >

>>>>> >

>>>>> > On Sat, Sep 19, 2020 at 1:34 AM Asad Saeeduddin <[hidden email]> 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 <[hidden email]>

>>>>> >>

>>>>> >> 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

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>> [hidden email]

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >> _______________________________________________

>>>>> >>

>>>>> >> Libraries mailing list

>>>>> >>

>>>>> >> [hidden email]

>>>>> >>

>>>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >> _______________________________________________

>>>>> >>

>>>>> >> Libraries mailing list

>>>>> >>

>>>>> >> [hidden email]

>>>>> >>

>>>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >>

>>>>> >> _______________________________________________

>>>>> >>

>>>>> >> Libraries mailing list

>>>>> >>

>>>>> >> [hidden email]

>>>>> >>

>>>>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>> >>

>>>>> > --

>>>>> > -- Kim-Ee

>>>>> > _______________________________________________

>>>>> > Libraries mailing list

>>>>> > [hidden email]

>>>>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>> _______________________________________________

>>>>> Libraries mailing list

>>>>> [hidden email]

>>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>>

>>>> _______________________________________________

>>>> Libraries mailing list

>>>> [hidden email]

>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>>

>>> _______________________________________________

>>> Libraries mailing list

>>> [hidden email]

>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>>

>> _______________________________________________

>> Libraries mailing list

>> [hidden email]

>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

>

> _______________________________________________

> Libraries mailing list

> [hidden email]

> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries