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/
humasect has joined #ocaml
humasect has quit [Client Quit]
myrkraverk has joined #ocaml
myrkraverk_ has quit [Ping timeout: 244 seconds]
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 252 seconds]
nirvdrum741 has quit [Quit: The Lounge - https://thelounge.chat]
myrkraverk has joined #ocaml
myrkraverk_ has quit [Ping timeout: 252 seconds]
myrkraverk_ has joined #ocaml
inline has quit [Quit: Leaving]
wbooze has joined #ocaml
myrkraverk has quit [Ping timeout: 276 seconds]
<discocaml> <ape_logic> is there a way to use either of the ppx json derivers to support objects that can contain a few variations of structure ?
<discocaml> <ape_logic> for example ,
<discocaml> <ape_logic> `"foo": { "type": "baz", "baz": "bar" }` or `"foo": { "type": "feh", "ding": "dong" }`
<discocaml> <ape_logic> the actual data is a nested structure that contains named k/v which can each be of a few types, depending on one of its sub keys
<discocaml> <ape_logic> (so "foo" is the name of the entry, and the entries are part of a top level object)
<discocaml> <ape_logic> it seems like they'll only really work for static structures, and while my natural inclination is to represent these in ocaml with variants, the derivers have funny ideas about how those are represented, and even moreso around what an assoc list looks like in json ..
<discocaml> <ape_logic> (it's a nix flake lockfile, so like [this](https://github.com/nix-community/patsh/blob/main/flake.lock) , except there are node types other than "github" possible too :) )
<discocaml> <ape_logic> (it's a nix flake lockfile, so like [this](<https://github.com/nix-community/patsh/blob/main/flake.lock>) , except there are node types other than "github" possible too :) )
<discocaml> <yawaramin> would probably need a few manual transformations to set it up the way you want it
<discocaml> <yawaramin> eg using `ppx_deriving_yojson`: ```ocaml
<discocaml> <yawaramin> type foo = Baz of { baz : string } | Feh of { ding : string }
<discocaml> <yawaramin>
<discocaml> <yawaramin> type foo' = { typ : string [@key "type"]; baz : (string [@default ""]); ding : (string [@default ""]) } [@@deriving to_yojson]
<discocaml> <yawaramin>
<discocaml> <yawaramin> let foo_to_yojson = function
<discocaml> <yawaramin> | Baz { baz } -> foo'_to_yojson { typ = "baz"; baz; ding = "" }
<discocaml> <yawaramin> | Feh { ding } -> foo'_to_yojson { typ = "feh"; baz = ""; ding }
<discocaml> <yawaramin> ```
<discocaml> <yawaramin> trying it: ```
<discocaml> <yawaramin> # Yojson.Safe.to_string (foo_to_yojson (Baz {baz = "bar"}));;
<discocaml> <yawaramin> - : string = "{\"type\":\"baz\",\"baz\":\"bar\"}"
<discocaml> <yawaramin> # Yojson.Safe.to_string (foo_to_yojson (Feh {ding = "dong"}));;
<discocaml> <yawaramin> - : string = "{\"type\":\"feh\",\"ding\":\"dong\"}"
<discocaml> <yawaramin> ```
<discocaml> <ape_logic> that's kind of similar to where I was at, but what about making yojson understand the object containing them? ie.
<discocaml> <ape_logic> ```json
<discocaml> <ape_logic> {
<discocaml> <ape_logic> "things": {
<discocaml> <ape_logic> "this": { "type": "baz", "baz": "bar" },
<discocaml> <ape_logic> "that": { "type": "feh", "ding": "dong"}
<discocaml> <ape_logic> }
<discocaml> <ape_logic> }
<discocaml> <ape_logic> ```
<discocaml> <ape_logic> I try to tell it this is a `(string * foo) list` but it wants one of those to look something like `things: [ { ..some.object.data.. }, ]`
<discocaml> <ape_logic> that's kind of similar to where I was at, but what about making yojson understand the object containing them? ie.
<discocaml> <ape_logic> ```json
<discocaml> <ape_logic> {
<discocaml> <ape_logic> "things": {
<discocaml> <ape_logic> "this": { "type": "baz", "baz": "bar" },
<discocaml> <ape_logic> "that": { "type": "feh", "ding": "dong"}
<discocaml> <ape_logic> }
<discocaml> <ape_logic> }
<discocaml> <ape_logic> ```
<discocaml> <ape_logic> I try to tell it `things` is a `(string * foo) list` but it wants one of those to look something like `things: [ { ..some.object.data.. }, ]`
<discocaml> <ape_logic> that's kind of similar to where I was at, but what about making yojson understand the object containing them? ie.
<discocaml> <ape_logic> ```json
<discocaml> <ape_logic> {
<discocaml> <ape_logic> "things": {
<discocaml> <ape_logic> "this": { "type": "baz", "baz": "bar" },
<discocaml> <ape_logic> "that": { "type": "feh", "ding": "dong"}
<discocaml> <ape_logic> }
<discocaml> <ape_logic> }
<discocaml> <ape_logic> ```
<discocaml> <ape_logic> I try to tell it `things` is a `(string * foo) list` but it wants one of those to look something like `"things": [ { ..object data.. } ]`
<discocaml> <ape_logic> (judging by how it outputs a dummy object of it)
<discocaml> <yawaramin> once you've defined the `foo_to_yojson` (eg) nested converter, Yojson will automatically use that (because of its name) in the top-level converter
<discocaml> <yawaramin> to convert a nested `foo` object
hsw has quit [Remote host closed the connection]
hsw has joined #ocaml
troydm has joined #ocaml
hsw has quit [Remote host closed the connection]
nirvdrum741 has joined #ocaml
hsw has joined #ocaml
deavmi has quit [Quit: Livin' in Afrika]
deavmi has joined #ocaml
m5zs7k_ has joined #ocaml
m5zs7k has quit [Read error: Connection reset by peer]
za3k has quit [Remote host closed the connection]
za3k has joined #ocaml
grobe0ba has quit [Ping timeout: 248 seconds]
tomku has quit [Ping timeout: 268 seconds]
germ has quit [Ping timeout: 276 seconds]
tomku has joined #ocaml
germ has joined #ocaml
m5zs7k_ is now known as m5zs7k
wbooze_ has joined #ocaml
nirvdrum741 has quit [Read error: Connection reset by peer]
wbooze has quit [Ping timeout: 252 seconds]
nirvdrum741 has joined #ocaml
nirvdrum7414 has joined #ocaml
nirvdrum741 has quit [Ping timeout: 252 seconds]
nirvdrum7414 is now known as nirvdrum741
nirvdrum7416 has joined #ocaml
nirvdrum741 has quit [Read error: Connection reset by peer]
nirvdrum7416 is now known as nirvdrum741
<discocaml> <ape_logic> it seems no matter what I do, I get this:
<discocaml> <ape_logic> ```
<discocaml> <ape_logic> {
<discocaml> <ape_logic> "nodes": [
<discocaml> <ape_logic> [
<discocaml> <ape_logic> "test",
<discocaml> <ape_logic> {
<discocaml> <ape_logic> "inputs": [],
<discocaml> <ape_logic> "locked": {
<discocaml> <ape_logic> "lastModified": 0,
<discocaml> <ape_logic> "narHash": "",
<discocaml> <ape_logic> "path": "",
<discocaml> <ape_logic> "type": ""
<discocaml> <ape_logic> },
<discocaml> <ape_logic> "original": { "path": "", "type": "" }
<discocaml> <ape_logic> }
<discocaml> <ape_logic> ]
<discocaml> <ape_logic> ],
<discocaml> <ape_logic> "root": "root",
<discocaml> <ape_logic> "version": 7
<discocaml> <ape_logic> }
<discocaml> <ape_logic> ```
<discocaml> <ape_logic> where `nodes` array should obviously be an assoc.. all the documentation I can find suggests this should be outputting (and imbibing) an object here
<discocaml> <ape_logic> ah, ppx_yojson_conv only supports custom routines under the default names / doesn't allow per field [@to_yojson]
sailorTheCat has quit [Quit: ZNC 1.8.2 - https://znc.in]
sailorTheCat has joined #ocaml
hsw has quit [Remote host closed the connection]
hsw has joined #ocaml
grobe0ba has joined #ocaml
Serpent7776 has joined #ocaml
bartholin has joined #ocaml
za3k has quit [Quit: ZNC 1.8.2+deb3.1 - https://znc.in]
za3k has joined #ocaml
Haudegen has joined #ocaml
myrkraverk has joined #ocaml
Everything has joined #ocaml
myrkraverk_ has quit [Ping timeout: 252 seconds]
bartholin has quit [Quit: Leaving]
keyboard has quit [Remote host closed the connection]
hsw has quit [Remote host closed the connection]
hsw has joined #ocaml
zor has joined #ocaml
chiselfuse has quit [*.net *.split]
toastal has left #ocaml [#ocaml]
funkatronixxx has joined #ocaml
funkatronixxx has quit [Remote host closed the connection]
humasect has joined #ocaml
itszor has joined #ocaml
zor has quit [Ping timeout: 272 seconds]
humasect has quit [Remote host closed the connection]
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 252 seconds]
myrkraverk_ has quit [Read error: Connection reset by peer]
myrkraverk_ has joined #ocaml
toastal has joined #ocaml
myrkraverk__ has joined #ocaml
myrkraverk_ has quit [Ping timeout: 276 seconds]
Haudegen has quit [Quit: Bin weg.]
chiselfuse has joined #ocaml
humasect has joined #ocaml
toastal has left #ocaml [#ocaml]
polykernel has quit [Ping timeout: 265 seconds]
polykernel has joined #ocaml
Serpent7776 has quit [Ping timeout: 248 seconds]
myrkraverk has joined #ocaml
Serpent7776 has joined #ocaml
myrkraverk__ has quit [Ping timeout: 276 seconds]
Haudegen has joined #ocaml
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 252 seconds]
humasect has quit [Remote host closed the connection]
myrkraverk has joined #ocaml
myrkraverk_ has quit [Ping timeout: 276 seconds]
Tuplanolla has joined #ocaml
humasect has joined #ocaml
<discocaml> <yawaramin> yeah i used ppx_deriving_yojson
trillion_exabyte has quit [Ping timeout: 248 seconds]
myrkraverk_ has joined #ocaml
trillion_exabyte has joined #ocaml
myrkraverk has quit [Ping timeout: 248 seconds]
wbooze_ is now known as wbooze
myrkraverk has joined #ocaml
myrkraverk_ has quit [Ping timeout: 248 seconds]
toastal has joined #ocaml
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 248 seconds]
toastal has left #ocaml [#ocaml]
myrkraverk has joined #ocaml
toastal has joined #ocaml
myrkraverk_ has quit [Ping timeout: 252 seconds]
Haudegen has quit [Quit: Bin weg.]
myrkraverk_ has joined #ocaml
humasect has quit [Remote host closed the connection]
myrkraverk has quit [Ping timeout: 252 seconds]
myrkraverk has joined #ocaml
humasect has joined #ocaml
myrkraverk_ has quit [Ping timeout: 248 seconds]
Haudegen has joined #ocaml
humasect has quit [Remote host closed the connection]
Serpent7776 has quit [Ping timeout: 252 seconds]
bartholin has joined #ocaml
euphores has quit [Quit: Leaving.]
humasect has joined #ocaml
euphores has joined #ocaml
toastal has left #ocaml [#ocaml]
Serpent7776 has joined #ocaml
humasect has quit [Remote host closed the connection]
<discocaml> <leostera> we have supervisors in riot!
<discocaml> <shalokshalom> nice!
<discocaml> <shalokshalom> are there any plans to implement fault tolerance, and how far do you think you can go with the scheduling?
Everything has quit [Quit: leaving]
<discocaml> <yawaramin> doesn't fault tolerance basically boil down to having supervisors in an actor system?
Serpent7776 has quit [Ping timeout: 265 seconds]
Frostillicus has quit [Ping timeout: 276 seconds]
bartholin has quit [Quit: Leaving]
Mister_Magister_ has joined #ocaml
Mister_Magister has quit [Ping timeout: 276 seconds]
Mister_Magister_ is now known as Mister_Magister
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 252 seconds]
Frostillicus has joined #ocaml
Frostillicus has quit [Ping timeout: 252 seconds]
Mister_Magister_ has joined #ocaml
Mister_Magister has quit [Ping timeout: 248 seconds]
Mister_Magister_ is now known as Mister_Magister
humasect has joined #ocaml
humasect has quit [Remote host closed the connection]
Mister_Magister_ has joined #ocaml
Mister_Magister has quit [Ping timeout: 276 seconds]
humasect has joined #ocaml
Mister_Magister_ is now known as Mister_Magister
humasect has quit [Remote host closed the connection]
Mister_Magister_ has joined #ocaml
Mister_Magister has quit [Ping timeout: 248 seconds]
humasect has joined #ocaml
Mister_Magister_ is now known as Mister_Magister
humasect has quit [Remote host closed the connection]
humasect has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
Tuplanolla has quit [Ping timeout: 272 seconds]
humasect has quit [Read error: Connection reset by peer]
humasect has joined #ocaml
Frostillicus has joined #ocaml
humasect has quit [Remote host closed the connection]
Frostillicus has quit [Ping timeout: 252 seconds]