Skip to content

Conversation

@MaisaMilena
Copy link
Contributor

Inspired in pretty-ms and parse-ms. Converts and show time from milliseconds to days, hours, minutes, etc.

Also, add some numbers.max as an example of how to write the numbers

need help:

I have to improve Time.ex but:

  • Following Buck example using The doesn't work because String.eql doesn't evaluate to a Bool
Time.ex.show_secs: The(_, Bool.true)
   let time = Time.show(Time.ex.parse, Bool.false)
   case time: 
   | The.value<>(String.eql(time.seconds, "20s"));
  • Using Victor's suggestion doesn't type check
Time.ex: Bool
   Bool.and(Time.ex.test_days, Bool.false)

Time.ex.test: Time.ex.test_days == Bool.true
  _

@MaisaMilena MaisaMilena added help wanted Extra attention is needed lib Related to Formality lib labels Aug 10, 2020
@VictorTaelin
Copy link
Contributor

@johnchandlerburnham I don't think the licenses belong here. What is your take on the matter?

@MaisaMilena
Copy link
Contributor Author

Despite I changed a lot of things in the parse-ms, the essence of the code is the same. For pretty-ms I just saw some examples on how it would output but it's my code.

I think that a lot of cases of copying libs to use in Formality will happen. In the MIT License, this is what made me copy the license as a code: "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software."

@johnchandlerburnham
Copy link
Contributor

Copyright doesn't cover the essence of the idea expressed in code, only the concrete implementation. If you directly copy files, functions or text, then it needs to preserve the license, but you haven't done that here. A port is generally a derivative work which generates a fresh copyright (covered here by the root LICENSE file). I would remove the license text and just include a comment that links to the repo you were inspired by and gives credit to its author as a matter of good open source friendliness.

@MaisaMilena MaisaMilena changed the title WIP: Add some Time functions Add some Time functions Aug 21, 2020
@VictorTaelin
Copy link
Contributor

The reason Text.ex.show_secs doesn't work is that, inside the case, time.seconds is a variable which isn't true yet, so you'd need a dependent motive. An alternative is to extract the seconds from time and use def:

Time.ex.show_secs: The(_, Bool.true)
  let time = Time.show(Time.ex.parse, Bool.false)
  def secs = case time: | time.seconds;
  The.value<>(String.eql(secs, "20s"))

But this also doesn't type-check because it depends on U64 functions that aren't implemented on lib yet, so they can't be normalized on the type level (even though they work in JS). We need those for the type-checker to get unstuck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed lib Related to Formality lib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants