Double tilda in dune file

What does a double tilda mean in a dune file?

example

(lang dune 2.8)
(name decathlon-stock)
(generate_opam_files true)


(package
 (name decathlon-stock)
 (synopsis "Check Decathlon online stock availability")
 (maintainers "Thibault Suzanne <thi.suzanne@gmail.com>")
 (authors "Thibault Suzanne <thi.suzanne@gmail.com>")
 (homepage "https://github.com/thizanne/decathlon-stock/")
 (bug_reports "https://github.com/thizanne/decathlon-stock/issues")
 (depends
  (core_kernel (>= ~~))
  (cmdliner (>= ~~))
  (async_smtp (>= ~~))
  (cohttp-lwt-unix (>= ~~))
  (cohttp-lwt (>= ~~))
  (lambdasoup (>= ~~))
  (fmt (>= ~~))
  (ppx_let (>= ~~))
  (yojson (>= ~~))
  )
 )

source

Thank you.

1 Like

As far as I know, the double tilde has no special meaning. Dune interprets it as a version “number” the same as any other & emits an .opam file to that effect.

Opam adopts Debian’s versioning policy, which uses ASCII-like lexical comparison with the modification that tilde characters sort before all other characters, including the empty string. (This has the convenience of making e.g. 1.0.0~alpha sort before 1.0.0.) In this light, the version number “~~” is just a particularly early version number – earlier even than "".

It was likely picked to mean “TODO: set lower bounds later”, but I can’t speak for the author :slight_smile:

2 Likes

That’s the correct answer. As far as I know dune forces me to be explicit about dependency versions, then when I’m too lazy to check them I’ll just write a constraint that is basically always fulfilled.

1 Like

Thank you @CraigFe @thizanne

So basically same as not have any dependency specified. Relying on the file doesnt add any information about dependency versions. Is that correct?

That’s correct, these lines don’t add any dep version information.

1 Like

You can omit dependency versions in dune-project, for example the following is accepted:

 (depends
  (a (>= va))
  b
  (c (>= vc))
  )

and it will emit:

depends: [
  "a" { >= va }
  "b"
  "c" { >= vc }
]
1 Like

Τhanks. I guess I didn’t try that syntax.

@emillon what does va and vc mean here?

Those are placeholders for version numbers. A more realistic example would be:

 (depends
  (lwt (>= 3.2.1))
  base
  (ocaml (>= 4.08))
  )
1 Like