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

Naming convention from from/toTime #18

Open
KevinWMatthews opened this issue Nov 24, 2019 · 2 comments
Open

Naming convention from from/toTime #18

KevinWMatthews opened this issue Nov 24, 2019 · 2 comments
Assignees

Comments

@KevinWMatthews
Copy link

KevinWMatthews commented Nov 24, 2019

Is the naming convention for fromTime and toTime reversed? Intuitively I expect toTime to return a Time:

toTime :  Int -> Time

and fromTime to accept a Time as an input:

fromTime : Time -> Int

much like the fromPosix and toPosix functions. The actual API for Time is the opposite.

Perhaps fromInt/toInt? There is some precedent for fromMillis/toMillis in the elm/Time package.

I'm still new to Elm, so if you're willing to share your mental model it would help me out quite a bit. I see that you've touched these functions recently in #9 , so perhaps there's some reasoning behind the convention that I'm not aware of.

Thanks!

@jweir
Copy link
Owner

jweir commented Nov 24, 2019

Ah yes, good point.

The reason these are named this (and it took me a while to recall) is Elm used to represent Time as an Int.

The fromMillis/toMillis makes much more sense (until Elm adds a Millis type), so maybe fromInt / toInt. Let me chew on this for a bit.

@jweir jweir self-assigned this Nov 24, 2019
@KevinWMatthews
Copy link
Author

Ah, I see - I didn't know that corner of Elm history.

Take your time - this would be an API change, which warrants more than a moment's thought.

Thanks!

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

No branches or pull requests

2 participants