-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enum
instance of UFixed
is not Haskell conform
#2888
Comments
I get what you're saying, but I think a literal reading of the And so, if anything, we should read the carve out for
This all leads me to the conclusion that in 2025 On top of that, as Peter mentioned in the other thread, we already changed the To wrap it up: I don't think this is a bug on our end, nor would it be an improvement to abide by the mentioned laws. The only feasible way to improve on the situation would be to offer our own class, which I feel |
|
On the other hand, we are deviating in behavior from the base implementation of Fixed. Why?
I understood that there is a reason you don't like to implement similar behavior, but I don't understand the reason. Hence, it would really help if you could give some background on what's the actual issue here. [Edit] |
As already noted here, the
Enum
instances ofUFixed
is notHaskell2010
conform:(the arguments of the prior discussion are restated below for convenience)
I consider the successor of
1.5 :: UFixed 2 1
to be2
and not2.5
.The current
Enum (UFixed 2 1)
instance implements a similar behavior as theEnum
instance forFloat
, but the report makes an explicit exception for that particular type. It defines:For all four numeric types (which are only
Int
,Integer
,Float
, andDouble
) , succ adds 1, and pred subtracts 1.For any other type the semantics is:
Class
Enum
defines operations on sequentially ordered types. The functions succ and pred return thesuccessor and predecessor, respectively, of a value.
The sequential order of
UFixed 2 1
isand, thus, the successor of
1.5
must be2.0
.As
UFixed 2 1
also has aBounded
instance, there even is proof that the current implementation is wrong, because in that case it is also required thatwhich does not hold for
UFixed 2 1
,x = 2.5
andy = 2.0
, resulting inThe text was updated successfully, but these errors were encountered: