Skip to content
This repository was archived by the owner on Aug 25, 2022. It is now read-only.

Use Ptime for time argument#160

Merged
Drup merged 1 commit intomirage:masterfrom
emillon:use-ptime
Oct 9, 2018
Merged

Use Ptime for time argument#160
Drup merged 1 commit intomirage:masterfrom
emillon:use-ptime

Conversation

@emillon
Copy link
Copy Markdown
Contributor

@emillon emillon commented Oct 6, 2018

Cf #159 (comment)

cc @hannesm

Is the extra dependency OK?

Thanks!

@hannesm
Copy link
Copy Markdown
Member

hannesm commented Oct 6, 2018

this looks good to me. the additional dependency (ptime) is fine with me (it only affects the functoria package, not functoria-runtime).

@Drup
Copy link
Copy Markdown
Member

Drup commented Oct 6, 2018

I'm sorry, but do we gain anything by that? We don't use Ptime here, we simply embeded the current time in a file, we don't manipulate it, and we certainly don't use a clock, posix or not.

I know we have a sort of moral obligation of using all the good modern minilibs in the ecosystem, but I would prefer if we had an actual reason to do that.

@emillon
Copy link
Copy Markdown
Contributor Author

emillon commented Oct 6, 2018

If I see time:float, I'll have several things to guess: does this expect seconds? microseconds? nanoseconds? what is the epoch? With Ptime.t this is documented by the type itself.

@hannesm
Copy link
Copy Markdown
Member

hannesm commented Oct 6, 2018

an actual reason for me would be to use Ptime.pp_rfc3339 instead of the 10 lines printing a timestamp.

@emillon
Copy link
Copy Markdown
Contributor Author

emillon commented Oct 7, 2018

Good idea. I used this. The time setting code needs an extra branch because of_float_s is partial. Would it be OK to depend on ptime.clock.os and call Ptime_clock.now instead?

@samoht
Copy link
Copy Markdown
Member

samoht commented Oct 7, 2018

LGTM

@Drup
Copy link
Copy Markdown
Member

Drup commented Oct 7, 2018

an actual reason for me would be to use Ptime.pp_rfc3339 instead of the 10 lines printing a timestamp.

Ah, that's a bit more convincing to me. :)

begin
match Ptime.of_float_s (Unix.gettimeofday ()) with
| Some t -> t
| None -> failwith "cannot convert current time"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call directly Ptime_clock.now () here, please.

@emillon
Copy link
Copy Markdown
Contributor Author

emillon commented Oct 9, 2018

I used Ptime_clock - it looks way better than before.

@Drup
Copy link
Copy Markdown
Member

Drup commented Oct 9, 2018

I like the current version much more than the original one, since we actually use ptime to remove a bunch of code previously needed!

@Drup Drup merged commit 91947f5 into mirage:master Oct 9, 2018
((name functoria)
(public_name functoria)
(libraries (unix cmdliner rresult fmt astring fpath))
(libraries (unix cmdliner rresult fmt astring fpath ptime.clock.os))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about best current practises: should ptime be included here as well, or is transitivity (via ptime.clock.os) sufficient? I'm in favour of the former.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general I agree that transitive dependencies are a potential source of bugs, but within a single ocamlfind lib it's probably acceptable.

hannesm added a commit to hannesm/opam-repository that referenced this pull request Nov 16, 2018
CHANGES:

* compute all transitive opam dependencies for info (mirage/functoria#151, by @hannesm)
* support pin-depends in generated opam file (mirage/functoria#163, by @hannesm)
* use dune as build system (mirage/functoria#158, by @emillon)
* use Ptime for time printing (mirage/functoria#160, by @emillon)
* inject global arguments into generated header (mirage/functoria#159, by @emillon)
* add Functoria_key.add_to_context (mirage/functoria#161, by @emillon)
* output opam2 files (mirage/functoria#157, by @hannesm)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants