companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.12 released: https://ocaml.org/releases/4.12.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
leah2 has quit [Read error: Connection reset by peer]
jtck has quit [Remote host closed the connection]
jtck has joined #ocaml
<d_bot> <thangngoc89> @monk it’s 100% OCaml now
<d_bot> <thangngoc89> @Drup added a short description in README. Could you please take a took and tell me if that’s understandable https://github.com/thangngoc89/ocaml-slug
jinsun has quit [Read error: Connection reset by peer]
jinsun has joined #ocaml
<d_bot> <g_w1> anyone have good examples of idomatic small-ish ocaml codebases?
<d_bot> <antron> i could suggest lambda soup <https://github.com/aantron/lambdasoup> consisting of one source file and all the extras for testing it etc
<d_bot> <g_w1> thanks
waleee has quit [Ping timeout: 252 seconds]
<d_bot> <thangngoc89> It’s a joy to read github.com/aantron/* libraries
mbuf has joined #ocaml
zebrag has quit [Remote host closed the connection]
TakinOver has quit [Ping timeout: 272 seconds]
TakinOver has joined #ocaml
gravicappa has joined #ocaml
gravicappa has quit [Ping timeout: 240 seconds]
shawnw has quit [Ping timeout: 246 seconds]
cedric has joined #ocaml
wingsorc has quit [Quit: Leaving]
<d_bot> <Drup> looks good 🙂
<d_bot> <thangngoc89> Thank you. I’m patiently waiting for https://github.com/ocaml/opam-repository/pull/19012#issuecomment-875240826
welterde has quit [Quit: WeeChat 3.0.1]
welterde has joined #ocaml
Haudegen has joined #ocaml
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
<d_bot> <thangngoc89> What is the ocamlc flag that list all the references inside a module?
<d_bot> <octachron> What do you mean by references? References to other modules?
Tuplanolla has joined #ocaml
<d_bot> <thangngoc89> @octachron yes.
<d_bot> <thangngoc89> I want to know which module/identifier the current module is referring
<d_bot> <octachron> It is more ocamldep than ocamlc that you want. (You can use `ocamlc -depend` which does the same thing but outside of the compiler development, it is better to use ocamldep).
<d_bot> <thangngoc89> @octachron thank you very much.
leah2 has joined #ocaml
<d_bot> <thangngoc89> Should I use list or array for static list of 1000 elements that I would only iterate on it a single time?
bartholin has joined #ocaml
<d_bot> <octachron> How is the data created? If you control the representation, an array will be slightly more compact. But if you iterate on it only once, it would probably not matter either way.
<d_bot> <thangngoc89> @octachron it’s auto generated into a source code file. And will be turned into a hash table immediately at runtime.
<d_bot> <octachron> Then an array is better (you might need/want to split the array in chunks depending on its size).
<d_bot> <thangngoc89> @octachron around 600 items. Why does split the array in chunks would be better? Could you elaborate on that?
<d_bot> <octachron> The compiler makes no guarantee on having reasonable time/memory behaviors on generated code. `600` items is (probably) fine.
<d_bot> <octachron> However, huge literals are known to have issues.
<d_bot> <thangngoc89> I see. I guess I should just do it and see if any problems arose
<d_bot> <octachron> See https://github.com/daypack-dev/timere/issues/16 for an instance of the issue and a possible solution.
<d_bot> <thangngoc89> Thank you very much
<d_bot> <Kakadu> I'm trying to substitute a type parameter in module signature. I want to write
<d_bot> <Kakadu> ```
<d_bot> <Kakadu> # module type XXX = (Map.S with type 'a t := int XXX.t) ;;
<d_bot> <Kakadu> Error: Unbound module XXX
<d_bot> <Kakadu> ```
<d_bot> <Kakadu> The thing that works is `module type XXX = (Map.S with type 'a t := int Map.Make(Int).t)` but there I expose internals of type `_ XXX.t` and I don't want to do it.
<d_bot> <Kakadu> Any advice how to do it? Or why it should not be done this way because type system becomes inconsistent or something?..
<d_bot> <octachron> What is supposed to be `XXX` in `Map.S with type 'a t := int XXX.t`?
<d_bot> <Kakadu> The module type which I'm defining. I'm trying to specialise type parameter
glassofethanol has joined #ocaml
<d_bot> <octachron> A module type doesn't define any type. You need a concrete type to do the substitution.
<d_bot> <Kakadu> `Map.S` has `'a t` inside. Isn't it concrete enough?
<d_bot> <octachron> No, like I said a module type doesn't define a concrete type. It is a specification for a module.
<d_bot> <octachron> Also the replacement cannot work in this specific instance since `Map.S` requires `'a t` to be injective.
<d_bot> <octachron> Otherwise, you could do something like: `module type XXX = sig type 'a t include (Map.S with type 'a t := int t) end`
<d_bot> <Kakadu> It looks like 4.10 doesn't require injectivity and `module type XXX = sig type 'a t include (Map.S with type 'a t := int t) end;;` works almost as I need
<d_bot> <Kakadu> @octachron Thanks!
<d_bot> <Kakadu> Is there any short hack to write a short structure that suites module type above?
<d_bot> <Kakadu> ```
<d_bot> <Kakadu>
<d_bot> <Kakadu> module Env : sig
<d_bot> <Kakadu> type 'a t
<d_bot> <Kakadu>
<d_bot> <Kakadu> include Map.S with type 'a t := int t
<d_bot> <Kakadu> end = struct
<d_bot> <Kakadu> type 'a t
<d_bot> <Kakadu>
<d_bot> <Kakadu> include (Map.Make (String) : Map.S with type 'a t := int t)
<d_bot> <Kakadu> (* Values do not match:
<d_bot> <Kakadu> val empty : 'a t/1
<d_bot> <Kakadu> is not included in
<d_bot> <Kakadu> val empty : int t/2*)
<d_bot> <Kakadu> end
<d_bot> <Kakadu> ```
<zozozo> @Kakadu : please use an online paste service for such code blocks, ^^
<d_bot> <Kakadu> okay
<zozozo> (the reason is that such code blocks are not really great to read on the irc side of the channel)
<d_bot> <Kakadu> @guigui Although, on Discord it adds link preview that is not smaller then original peice of code
<zozozo> I see (also, note that irc users do not see message edits)
<d_bot> <mimoo> I'm getting an error: "Error: Syntax error" and that's it
<d_bot> <mimoo> any idea on how to debug that?
<d_bot> <thangngoc89> You should at least get a file location right?
<d_bot> <mimoo> first line of the main file
<d_bot> <mimoo> which seems like an incorrect error
<d_bot> <mimoo> "File "lib/randoml.ml", line 1: Error: Syntax error"
<d_bot> <thangngoc89> That’s when something doesn’t implement error handler correctly
<d_bot> <thangngoc89> Could be preprocessor or ppx
<d_bot> <Ulugbek> can you show us the code?
unyu has joined #ocaml
unyu has left #ocaml [#ocaml]
mbuf has quit [Quit: Leaving]
<d_bot> <mimoo> looks like it was in a test somewhere else in the file
waleee has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
vb has quit [Quit: Lost terminal]
vb has joined #ocaml
<d_bot> <darrenldl> @thangngoc89 re timere/timedesc's case: drup (and i) ended up switching to storing the generated sexp of the db, which is read by a code gen that generates a .ml file with the marshalled string of the db during installation of the package
<Armael> oh dear
<Armael> that's a bit convoluted but I can imagine how you got to that solution
<d_bot> <darrenldl> ah everything drup mentioned is in the issue (i was not certain if it was only brought up in convo and not documented)
<d_bot> <darrenldl> but yes, it makes the code gen a bit of a catch 22
<d_bot> <darrenldl> which ends up with having an empty database as "base case" via dune's virtual lib in code gen, which generates the full db
<d_bot> <darrenldl> (full db sexp)
gwizon has joined #ocaml
<d_bot> <thangngoc89> Oh dear.
isekaijin has joined #ocaml
<d_bot> <darrenldl> i think above is not necessary if you don't offer database de/serialisation code in your library - timedesc contains them, so we want to reuse as much of timedesc as possible
<d_bot> <darrenldl> (the virtual lib part anyway)
<d_bot> <darrenldl> as for two pass code gen - first pass of sexp code gen phase is necessary since that is really slow and depends on OS data, i run this code gen on my own computer to embed data into the git repo, second pass is only for giving a more compact representation during library use by swapping to marshalled string when library is installed
<d_bot> <darrenldl>
<d_bot> <darrenldl> one pass into marshalled might suffice for you already
<companion_cube> or canonical sexprs or whatever :p
<d_bot> <darrenldl> yep, depends on how much speed you need
<d_bot> <darrenldl> tldr: everything seems fine if you have one really long string, not so much when you have one or multiple really long expressions though
Haudegen has joined #ocaml
gwizon has quit [Ping timeout: 252 seconds]
gwizon has joined #ocaml
waleee has quit [Ping timeout: 246 seconds]
_whitelogger has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
isekaijin has quit [Quit: WeeChat 3.2]
glassofethanol has quit [Quit: leaving]
waleee has joined #ocaml
<d_bot> <thangngoc89> How can I tell `ocamlopt` to produce cmi and cmx file in another directory?
<d_bot> <thangngoc89> no matter where the current working dir is, `ocamlopt` produces the cmi and cmx in the same folder as `ml` file
<d_bot> <EduardoRFS> @thangngoc89 -o ?
bartholin has quit [Quit: Leaving]
<d_bot> <thangngoc89> @EduardoRFS it's for executable only
Anarchos has joined #ocaml
Anarchos has quit [Client Quit]
<d_bot> <EduardoRFS> @thangngoc89 nope,
Anarchos has joined #ocaml
Haudegen has joined #ocaml
adanwan_ has joined #ocaml
adanwan has quit [Ping timeout: 244 seconds]
Anarchos has quit [Ping timeout: 258 seconds]
gwizon has quit [Ping timeout: 268 seconds]
gwizon has joined #ocaml
<d_bot> <thangngoc89> @EduardoRFS oh. I have to specify `.cmx` in `-o` as well. thanks
<d_bot> <thangngoc89> Is there any `path.resolve` in OCaml that does what node does?
<d_bot> <thangngoc89> ```js
<d_bot> <thangngoc89> path.resolve("/absolute/path/", "../path2")
<d_bot> <thangngoc89> -> `/absolute/path2`
<d_bot> <thangngoc89> ```
<d_bot> <thangngoc89> I'm looking at [Fpath](https://erratique.ch/software/fpath/doc/Fpath/index.html) but I couldn't figure out how to do this
<d_bot> <Splingush> ```ocaml
<d_bot> <Splingush> (v "/absolute/path/") // (v "../path2") |> normalize;;
<d_bot> <Splingush> - : t = /absolute/path2
<d_bot> <Splingush> ```
<d_bot> <Splingush> There are some examples listed further down in the docs, those might be helpful as well.
<d_bot> <thangngoc89> @Splingush omg. thank you so much. I've trying to enter the examples in utop but couldn't find the suitable one
<d_bot> <Splingush> Glad I could help, cheers 🙂
<companion_cube> you could use luv, it probably has the same stuff node does :p
<d_bot> <antron> @thangngoc89 @companion_cube https://aantron.github.io/luv/luv/Luv/File/index.html#val-realpath and i see a typo in the docs... and i just told @thangngoc89 that i dont know of any such function 😛
<d_bot> <antron> even the docs byline needs changing i guess, it makes no sense to me now
<d_bot> <antron> from the C docs "The realpath() function shall derive, from the pathname pointed to by file_name, an absolute pathname that resolves to the same directory entry, whose resolution does not involve '.', '..', or symbolic links."
<companion_cube> very nice
<d_bot> <antron> im not sure if it behaves exactly the same as path.resolve, though
<d_bot> <thangngoc89> @companion_cube node's path.resolve is very foolproof . Trying to go as little libraries as possible and especially not C libraries
<companion_cube> if it's foolproof because of libuv it seems a bit contradictory :p
<d_bot> <thangngoc89> what are the accepted filename for ocaml source code file? [A-z0-9\_]+ ?
<d_bot> <antron> yep luv is a pretty invasive change. however it is not a C library. and it binds to the C library inside nodejs 🙂
<d_bot> <antron> (im not seriously suggesting it, i actually opened the File docs to prove that such a function is not there, but its there :P)
<d_bot> <thangngoc89> Note to self: check node's source code to see how `path.resolve` is implemented
gravicappa has joined #ocaml
<d_bot> <antron> it looks like a pure-js (non-libuv) implementation <https://github.com/nodejs/node/blob/v16.4.2/lib/path.js#L158> and <https://github.com/nodejs/node/blob/v16.4.2/lib/path.js#L66> also looks like it is pure string ops and does not resolve symlinks
<d_bot> <thangngoc89> yes. It never resolve symlink
TakinOver has quit [Quit: KVIrc 5.0.0 Aria http://www.kvirc.net/]
Stumpfenstiel has joined #ocaml
Stumpfenstiel has quit [Quit: No Ping reply in 180 seconds.]
Stumpfenstiel has joined #ocaml
gwizon has quit [Remote host closed the connection]
jinsun has quit [Read error: Connection reset by peer]
gravicappa has quit [Ping timeout: 268 seconds]
jinsun has joined #ocaml
zebrag has joined #ocaml
glassofethanol has joined #ocaml
glassofethanol has quit [Quit: leaving]
jinsun_ has joined #ocaml
jinsun has quit [Ping timeout: 265 seconds]
Stumpfenstiel has quit [Ping timeout: 252 seconds]
Haudegen has quit [Ping timeout: 240 seconds]
TakinOver has joined #ocaml
cedric has quit [Quit: Konversation terminated!]
adanwan_ has quit [Remote host closed the connection]
adanwan has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]