-
Notifications
You must be signed in to change notification settings - Fork 16
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
Removed the Enum instance for Dimensional. #27
Conversation
Hmm... I use this quite a bit. Mostly for time series, e.g. It is a bit of a wart, but I suppose I was able to justify it to myself by the arguing that the natural increment for a type revolving around the SI is by 1 [SI base unit]. See also the announcement. |
The announcement raises the same alternative of If interacting with something else that is a little weird absolutely requires an
|
So I agree clients could define it themselves. ;) I'm leaning towards agreeing with you. I'll try to find my |
Actually, speaking of syntactic convenience, does |
I believe it does. The problem is that you would no longer be able to do |
I just checked and it doesn't in 7.6. |
Mostly tongue-in-cheek proposal:
|
|
Take a look at 9a03614. Am I being too helpful providing all those trivial functions? |
Hmm, interesting question. I think they are generally useful, and the names they are taking aren't names that are going to be overlapping with anything, so I think it is good to have them. Having the documentation for them should serve to avoid what might otherwise be a FAQ. And I can't think of any logical submodule name where it would make sense to move them. So I vote to keep them. I don't personally expect to have much use for them, because all my time-stepping/integration is wrapped up with a lot of complicated signal function machinery, but certainly they are helpful for either more complicated (hence more explicit) or simpler uses. |
With regards to your comment on 9a03614: I've changed But even with the explicit step size
The question is, what semantics do we want, and are we qualified to “know better” than the Prelude? I myself would expect Or should we drop the |
Good question. I'd be inclined to say that we keep it up to the last value that is strictly <= the end point. Anyone who wants the exact last number is probably barking up the wrong tree anyway? I'd personally probably want the one with |
Do you mean?: nFromIncr :: (Ord a, Fractional a)
=> Int -> Quantity d a -> Quantity d a -> [Quantity d a]
nFromIncr n xi dx = take (n Prelude.+ 1) $ fromIncr xi dx
nFromTo :: (Ord a, Fractional a)
=> Int -> Quantity d a -> Quantity d a -> [Quantity d a]
nFromTo 0 xi _ = [xi]
nFromTo n xi xf = (++ [xf]) -- Avoid rounding errors on final element.
$ take n $ fromIncr xi ((xf - xi) / (fromIntegral n *~ one)) Or should Would e.g. |
I was thinking it's the total number of elements in the result, but the other way might be better. If you do total number of elements, then the n = 0 case is [], but when n = 1 do you get [xi], [xf], [(xi+xf) / 2] or something else? |
My |
I think the I had a thought that it would be really nice if this from/to business went into the This one would be really nice, together with the stuff in dimensional-dk-experimental. nFrom :: (AdditiveGroup a) => Interval a -> Int -> [a] -- or maybe flipped? I'm not really enthused by any of these name choices. It doesn't seem like this function should be difficult to name, but it is. |
|
(Whoops, the Some thoughts from around the internet:
|
I suspect this was closed implicitly by the removal of your branch? I've opened #47 to track this. |
Indeed, sorry about that. I got a little too aggressive trying to cleanup the fact that I had a lot of branches from closed merge requests. |
No problem. |
It seems like the
Enum
instance needlessly exposes the implementation details ofDimensional
, because there is no physical reason whysucc (1 *~ meter)
should be 2 meters, whilesucc (1 *~ foot)
is 1.3048 meters.Perhaps some analog of
enumFromTo
that increments by a specified quantity might better suit any existing clients? Or[0..1000] *~~ meter
?