Skip to content
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

No floating point ranges #12

Open
pya opened this issue Aug 1, 2015 · 2 comments
Open

No floating point ranges #12

pya opened this issue Aug 1, 2015 · 2 comments
Labels

Comments

@pya
Copy link
Contributor

pya commented Aug 1, 2015

Haskell allows floating point ranges:

Prelude> [0.1, 0.2 .. 0.5]
[0.1,0.2,0.30000000000000004,0.4000000000000001,0.5000000000000001]

This does not work in Hask:

>>> L[0.1, 0.2, ..., 0.5]
TypeError Traceback (most recent call last)
....
TypeError: No instance for 0.1

Because floating point ranges are tricky:

Prelude> [0.1, 0.3 .. 1]
[0.1,0.3,0.5,0.7,0.8999999999999999,1.0999999999999999]

it might not be a good idea to implement them at all. In this case a more descriptive error message or even a own, new exception type might be helpful.

@billpmurphy billpmurphy added the bug label Aug 1, 2015
@billpmurphy
Copy link
Owner

Good catch. I'd say float should probably be an instance of Enum, as it is in Haskell.

@mvaled
Copy link

mvaled commented Jul 18, 2018

But which is the smallest "increment", i.e. how to implement succ?

In Haskell: succ 0.1 gives 1.1...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants