companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.2.0 released: https://ocaml.org/releases/5.2.0 | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
mange has joined #ocaml
gzar has quit [Quit: WeeChat 4.4.3]
Tuplanolla has quit [Quit: Leaving.]
chiselfuse has quit [Ping timeout: 264 seconds]
chiselfuse has joined #ocaml
hsw has joined #ocaml
Opus has quit [Quit: .-.]
Opus has joined #ocaml
pi3ce has joined #ocaml
nirvdrum4 has joined #ocaml
nirvdrum has quit [Read error: Connection reset by peer]
nirvdrum4 is now known as nirvdrum
bartholin has joined #ocaml
mange has quit [Remote host closed the connection]
bartholin has quit [Quit: Leaving]
Serpent7776 has joined #ocaml
mbuf has joined #ocaml
<discocaml> <reynir1396> I want to use the new `(project_defaults ..)` option in dune config, and this requires `(lang dune 3.17)` in the config. Now, all my older switches can't build any dune projects because of `(lang dune 3.17)`:D :D
semarie has quit [Ping timeout: 252 seconds]
semarie has joined #ocaml
alexherbo2 has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
mbuf has quit [Ping timeout: 244 seconds]
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
oriba has joined #ocaml
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
gentauro has quit [Read error: Connection reset by peer]
gentauro has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
Mister_Magister has quit [Quit: bye]
Mister_Magister has joined #ocaml
Mister_Magister has quit [Remote host closed the connection]
Mister_Magister has joined #ocaml
<discocaml> <deepspacejohn> Maybe put it in a different config file? e.g. `dune init proj --config-file=~/dune-config-with-project-defaults`. It might not be too painful since you only need it for running `dune init proj`
<discocaml> <deepspacejohn> (That is, if updating dune on the other switches isn't an option)
Mister_Magister has quit [Remote host closed the connection]
Mister_Magister has joined #ocaml
Mister_Magister has quit [Remote host closed the connection]
<discocaml> <poselsky> Hi!
<discocaml> <poselsky> I've got this project structure:
<discocaml> <poselsky> ```
<discocaml> <poselsky> | bin - main.ml
<discocaml> <poselsky> - dune
<discocaml> <poselsky> | lib | gen - gen.ml
<discocaml> <poselsky> - dune
<discocaml> <poselsky> ```
<discocaml> <poselsky>
<discocaml> <poselsky> I've got gen.ml and it generates some another ml file based on prerequisites. I wanted to copy gened file with rules - copy stanza but I get `is outside the build directory. This is not allowed.` error. Is there a way to circumvent this?
<discocaml> <contificate> what path are you using? you should use a relative path which becomes relative within the build folder
<discocaml> <contificate> then these `action`s that generate other ml files are ephemeral, only within the `_build` folder
Mister_Magister has joined #ocaml
<discocaml> <poselsky> I'm using outside of the build dir because I want to use the gened file as a lib. Is it available by default without including it in the source tree?
<discocaml> <poselsky> If so I guess I can just remove the copy thing all together.
<discocaml> <contificate> you can still use the gen'd file as a library, the first thing dune does is copy source to build folder
<discocaml> <contificate> then all actions execute relative to the build folder copy
<discocaml> <contificate> if you want to generate ml files that you _commit_ there is an actual dune promotion workflow that can do this
<discocaml> <poselsky> I will ask about that perhaps later when I need this :Hmm:
<discocaml> <poselsky>
<discocaml> <poselsky> Thanks! :peepoHappy:
<discocaml> <contificate> my favourite dune feature is dynamic_include, so you should check that out also
<discocaml> <contificate> very useful for generating libraries whose modules are dynamically determined
alexherbo2 has joined #ocaml
pi3ce has quit [Read error: Connection reset by peer]
pi3ce has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
Anarchos has joined #ocaml
<discocaml> <rezwanarefin01> How to install system dependencies automatically without prompt? `opam install -y --depext-only .` doesn't seem to pass on the `-y` to the system package manager!
<discocaml> <rezwanarefin01> How to install system dependencies automatically without prompt? `opam install -y --depext-only .` doesn't seem to pass on the `-y` to the system package manager (pacman)!
patrick_ is now known as patrick
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Anarchos has joined #ocaml
bartholin has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Anarchos has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
patrick has quit [Changing host]
patrick_ has joined #ocaml
Anarchos has joined #ocaml
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
<discocaml> <aricursion> I want to write a relatively short ocaml file which depends on `yojson`
<discocaml> <aricursion> is there a better way to do this than to have a whole `dune` environment?
<discocaml> <aricursion> Ideally, I would just have one file which I could compile and call it a day
<discocaml> <contificate> you can pass the library to `ocamlopt` directly
<discocaml> <contificate> maybe a bit annoying if you use a preprocessor relying on ppx, perhaps
<discocaml> <aricursion> hm
<discocaml> <aricursion> at that point I would just use dune ig
<discocaml> <aricursion> oh well
<discocaml> <contificate> can do it in commands if you want
<discocaml> <contificate> but also might as well just write a single dune file
<discocaml> <aricursion> wdym
<discocaml> <aricursion> I though I would have to do `dune project init` and all that
<discocaml> <contificate> no
<discocaml> <contificate> in a folder, `dune` and `main.ml`, have `dune` contain `(executable (name main))`
<discocaml> <contificate> dune exec ./main.exe
<discocaml> <contificate> done
<discocaml> <contificate> dune project init is for structuring projects where you have like a `lib` full of libraries and a `bin` containing an executable project
<discocaml> <aricursion> oh
<discocaml> <aricursion> does this work if I want multiple executables with the same dependencies?
<discocaml> <contificate> yes
<discocaml> <contificate> best to be in their own respective subfolder with their own dune file
<discocaml> <contificate> otherwise you have explicit module (exclusion) lists
<discocaml> <aricursion> i see
<discocaml> <contificate> it's simplest if a single dune file in a folder defines a single target (library or executable)
<discocaml> <contificate> but libraries permit of a modules stanza that lets you list and exclude certain files
<discocaml> <aricursion> gotcha
<discocaml> <contificate> dune is designed to be composable in this way
<discocaml> <aricursion> this is great!
<discocaml> <contificate> so you can just have a mega folder full of subdirs for libraries and executables and whatever, data_only_dirs, blah blah
<discocaml> <aricursion> so then the last question I have is I can create an opam switch at the top folder
<discocaml> <aricursion> and then i install my dependencies there?
<discocaml> <deepspacejohn> Dune's home page has an example of an extremely minimal project setup (just `dune-project` `dune` and `hello_world.ml` files) https://dune.build/
<discocaml> <contificate> there is a way to do some kind of folder hook thing I'm sure in your shell to switch to a specific switch when inside a specific folder
<discocaml> <contificate> but I forget the details
<discocaml> <contificate> or if there's a better way
<discocaml> <deepspacejohn> you can install a local opam switch in the folder. if you're using opam's built in shell hooks then it will take care of it for you.
<discocaml> <aricursion> wow
<discocaml> <aricursion> this is so easy
<discocaml> <aricursion> tysm
<discocaml> <aricursion> out of curiosity, why is opam slow?
<discocaml> <aricursion> it seems to be slower than similar things like Rust's Cargo
<discocaml> <aricursion> or even Pip for that matter
<discocaml> <deepspacejohn> do you mean slow at updating? IIRC it downloads the metadata for all of the packages in the repository and runs a solver on them every time, which is slower than a package manager than just downloads individual packages.
<discocaml> <aricursion> interesting
<discocaml> <aricursion> I guess I do research in automated reasoning, I shouldnt be complaining if the solvers are slow lol
Anarchos has quit [Quit: Vision[]: i've been blurred!]
<discocaml> <deepspacejohn> opam is also somewhat unusual among package managers in that it's manually curated (which doesn't make it slow directly but has implications for the design decisions)
<discocaml> <aricursion> i see
<discocaml> <aricursion> this doesnt seem to be working
<discocaml> <aricursion> ```
<discocaml> <aricursion> Error: I cannot find the root of the current workspace/project.
<discocaml> <aricursion> If you would like to create a new dune project, you can type:
<discocaml> <aricursion>
<discocaml> <aricursion> dune init project NAME
<discocaml> <aricursion>
<discocaml> <aricursion> Otherwise, please make sure to run dune inside an existing project or
<discocaml> <aricursion> workspace. For more information about how dune identifies the root of the
<discocaml> <aricursion> current workspace/project, please refer to
<discocaml> <aricursion> ```
<discocaml> <deepspacejohn> do you have a `dune-project` file?
<discocaml> <aricursion> i was just about to ask if i needed that
<discocaml> <aricursion> no
<discocaml> <deepspacejohn> dune at minimum needs a `dune` and a `dune-project` file (See the example on the dune home page)
<discocaml> <aricursion> gotcha
<discocaml> <aricursion> and i need one in every directory?
<discocaml> <deepspacejohn> you only need one `dune-project` at the root of your project. you would normally have a `dune` file in each directory that has something you need dune to compile.
<discocaml> <aricursion> gotcha
euphores has quit [Read error: Connection reset by peer]
euphores has joined #ocaml
<discocaml> <functionalprogramming> u gotta make a dune blogpost
<discocaml> <contificate> I lost the source for my blog
<discocaml> <functionalprogramming> are u kidding me
<discocaml> <contificate> nah I wiped desktop on a whim then remembered
<discocaml> <functionalprogramming> is it not on github broooo
<discocaml> <functionalprogramming> actually this is an opportunity
<discocaml> <functionalprogramming> remake ur website but in ocaml this time
<discocaml> <aricursion> this is a silly question
<discocaml> <aricursion> `Yojson`s type `t` is given as
<discocaml> <aricursion> ```
<discocaml> <aricursion> type t = [
<discocaml> <aricursion>
<discocaml> <aricursion> | `Null
<discocaml> <aricursion> | `Bool of bool
<discocaml> <aricursion> | `Int of int
<discocaml> <aricursion> | `Float of float
<discocaml> <aricursion> | `String of string
<discocaml> <aricursion> | `Assoc of (string * t) list
<discocaml> <aricursion> | `List of t list
<discocaml> <aricursion>
<discocaml> <aricursion> ]
<discocaml> <aricursion> ```
<discocaml> <aricursion> but if I do ``String "hello"` this does not inject into a `t` properly
<discocaml> <aricursion> I dont think it does, anyway
<discocaml> <aricursion> how can I construct a `t`?
<discocaml> <functionalprogramming> search up polymorphic variants in ocaml
<discocaml> <functionalprogramming> wdym by inject
<discocaml> <functionalprogramming> where a `Yojson.Safe.t` is expected, you should be able to pass ``String "hello"`
<discocaml> <aricursion> I am?
<discocaml> <aricursion> hm
<discocaml> <deepspacejohn> are you getting an error message?
<discocaml> <contificate> it would've been fine if github just supported Hugo, but alas
<discocaml> <yawaramin> you don't need to, just use the given tags and it will just work
<discocaml> <aricursion> oh im just dumb
<discocaml> <aricursion> sorry
<discocaml> <aricursion> the error is not where I thought it was
<discocaml> <aricursion> what is the point of the polymorphic variants over regular inductive constructors?
<discocaml> <yawaramin> any library can use them to construct valid JSON AST without having to depend on the Yojson package
<discocaml> <aricursion> oh?
zenmov has quit [Ping timeout: 252 seconds]
<discocaml> <aricursion> wait so ``String` is not a part of the `Yojson` module?
<discocaml> <octachron> Polymorphic variants are structural types: they are defined by their shape without having to define them in advance.
<discocaml> <octachron> They can be useful for library interoperability or when you have many variants in a same "type family"
<discocaml> <aricursion> woah
<discocaml> <aricursion> interestign
<discocaml> <yawaramin> yeah so `` `String "foo"`` is a valid JSON AST that will be accepted by Yojson even if the producing library has no idea that Yojson exists
<discocaml> <aricursion> interesting
<discocaml> <octachron> The disadvantage is that they can be too flexible: it can be too easy to misspell an `` `Assoc `` as `` `Asso `` (and they don't support non-regular polymorphic recursion)
<discocaml> <yawaramin> but on the bright side, you get a big type error
<discocaml> <deepspacejohn> also, on the downside, you can get a BIG type error.
<discocaml> <deepspacejohn> (versus a concise and clear error)
rgrinberg has joined #ocaml
pi3ce has quit [Read error: Connection reset by peer]
pi3ce has joined #ocaml
<discocaml> <deepspacejohn> FWIW, I think Real World OCaml's "when to use polymorphic variants" is good advice https://dev.realworldocaml.org/variants.html#when-to-use-polymorphic-variants
rgrinberg has quit [Quit: My Unrecognized Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
bartholin has quit [Quit: Leaving]
Tuplanolla has joined #ocaml
f[x] has joined #ocaml
alexherbo2 has joined #ocaml
Serpent7776 has quit [Ping timeout: 264 seconds]
rgrinberg has quit [Quit: My Unrecognized Mac has gone to sleep. ZZZzzz…]
f[x] has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
remexre has quit [Remote host closed the connection]
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]