companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.0 released(!!1!): https://ocaml.org/releases/5.0.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
oriba has quit [Ping timeout: 240 seconds]
azimut has joined #ocaml
elred has quit [Quit: leaving]
xd1le has joined #ocaml
chrisz has quit [Ping timeout: 245 seconds]
chrisz has joined #ocaml
<companion_cube> I wish we could have some sort of unitialized arrays…
<companion_cube> once more
spip has quit [Quit: Konversation terminated!]
<greenbagels> companion_cube: for speed or?
<greenbagels> also, https://ocaml.org/docs/metaprogramming and https://github.com/ocaml-ppx/ppx_deriving mention how to combine derivers
<greenbagels> like [@@deriving show,eq]
<greenbagels> but with say ppx_deriving_yojson, how would i combine something like @default and @key?
<greenbagels> oh i guess [@default X] [@key Y]
waleee has quit [Ping timeout: 245 seconds]
waleee has joined #ocaml
azimut_ has joined #ocaml
azimut has quit [Ping timeout: 240 seconds]
<greenbagels> if you have a data type that could have a "null" value but also just be plain ol' optional (i.e. not labeled "Required" in a JSON Schema), what would be the more common solution? To make a trinary variant type (like Missing, Null, or Some 'a) or to compose the `option` type with a variant type? (like Missing, or `a option)
<greenbagels> honestly json is such a pain...
<discocaml> <geoff> `option option`?
<greenbagels> i dont know why i thought that wouldn't work...
<greenbagels> now im imagining some cursed ocaml codebase out there that has Some Some Some Some Some None...
bartholin has joined #ocaml
waleee has quit [Ping timeout: 240 seconds]
azimut_ has quit [Ping timeout: 240 seconds]
azimut has joined #ocaml
neuroevolutus has joined #ocaml
neuroevolutus has quit [Quit: Client closed]
bartholin has quit [Quit: Leaving]
waleee has joined #ocaml
dhil has joined #ocaml
waleee has quit [Ping timeout: 240 seconds]
neuroevolutus has joined #ocaml
neuroevolutus has quit [Client Quit]
Serpent7776 has joined #ocaml
olle has joined #ocaml
luke20 has joined #ocaml
Tuplanolla has joined #ocaml
luke20 has quit [Ping timeout: 246 seconds]
luke23 has joined #ocaml
wingsorc has quit [Ping timeout: 240 seconds]
luke23 has quit [Ping timeout: 246 seconds]
spip has joined #ocaml
luke35 has joined #ocaml
mechap has joined #ocaml
m5zs7k has quit [Ping timeout: 245 seconds]
m5zs7k has joined #ocaml
<discocaml> <smondet> (Coq extracted to OCaml without optimizations looks like that actually': `(S (S (S (S Z)))` 🙂 )
gareppa has joined #ocaml
luke35 has quit [Ping timeout: 246 seconds]
<discocaml> <deepspacejohn> I guess it also depends on if Null or Missing have a different meaning. If they don't, then I'd just keep it simply by always including the fields and setting them to `null`. If you're decoding JSON to OCaml, then you can just decode both missing or null fields as `None`.
<discocaml> <deepspacejohn> if you do need to preserve the distinction between null and missing, then I'd do a trinary type or a type like `type 'a optional = Missing | Set of 'a` because seeing `Some None` makes me unhappy.
mechap has quit [Quit: WeeChat 4.0.1]
dhil has quit [Ping timeout: 264 seconds]
Everything has quit [Ping timeout: 258 seconds]
<dh`> there's nothing wrong with Some None if it's clear what it's supposed to mean
<dh`> e.g. lookup in a foo option Map.t
azimut has quit [Ping timeout: 240 seconds]
Everything has joined #ocaml
<discocaml> <xavierm02_> Is there some way of having `dune test` check that something does not typecheck (or more precisely that `let f (x : t1) : t2 = x` does not typecheck, i.e. that two types `t1` and `t2` are not convertible)?
<discocaml> <xavierm02_> some *simple* way
<discocaml> <deepspacejohn> So you want a test that tries to compile that code, and the test passes if the compiler finds a type error? (I'm not sure how you'd do that, but I'm just making sure I'm understanding the problem.)
<discocaml> <xavierm02_> @deepspacejohn Yes. I want to have an explicit check that a type is abstract-enough
<discocaml> <xavierm02_> And I can't just try getting a weird error with `Obj.magic` and catching it because the two types will be equal, but that equality should be hidden
<discocaml> <deepspacejohn> Types are usually either just abstract or they aren't, so that seems like an odd thing to test. But if you're using `Obj.magic`, then you're breaking the type system anyway. Either way, I don't have a good solution. Hopefully someone else can help.
<dh`> a test framework that has no way to express tests that are expected to fail seems fundamentally flawed to me
<discocaml> <deepspacejohn> Dune runs tests after compiling the code. So if your code doesn’t compile, then it can’t run the tests. Maybe you could call the compiler from a cram test, or something like that though.
<discocaml> <xavierm02_> I'm not using `Obj.magic`. I was just saying that "have different representations" might be expressible using `Obj`, but that even if it were, this would not be relevant to my use case
dhil has joined #ocaml
deadmarshal_ has quit [Remote host closed the connection]
<discocaml> <functionalprogramming> why would you need to explicitly write a test for this
<discocaml> <xavierm02_> Hm. I can see this working with cram tests, e.g. writing the tests in comments and uncommenting them in seperate files, but that's too much work for the little gain for now ^.^
<discocaml> <octachron> You could check the output of a REPL session.
<discocaml> <xavierm02_> @micah : For the same reason as other trivial tests : if the invariant I have in mind when writing the code is eventually broken, I want the compiler to warn whoever broke it that I did not expect this
<discocaml> <octachron> (both the compiler and the reference manual use more specialized tools but you would need to vendor them)
<discocaml> <xavierm02_> @micah : For the same reason as other trivial tests : if the invariant I have in mind when writing the code is eventually broken, I want the build system to warn whoever broke it that I did not expect this
<discocaml> <xavierm02_> @octachron What would be the advantage of using a REPL instead of trying to compile the file?
<discocaml> <octachron> You can have more than one error in the test by using `ocaml <test.ml`
<discocaml> <octachron> (and mix the test with non-typechecking tests)
<discocaml> <xavierm02_> Ah right
deadmarshal_ has joined #ocaml
bartholin has joined #ocaml
John_Ivan has quit [Quit: Disrupting the dragon's slumber one time too often shall eventually bestow upon all an empirical and indiscriminate conflagration that will last for all goddamn eternity.]
John_Ivan has joined #ocaml
olle has quit [Ping timeout: 252 seconds]
motherfsck has joined #ocaml
waleee has joined #ocaml
olle has joined #ocaml
olle has quit [Ping timeout: 245 seconds]
szkl has joined #ocaml
gareppa has quit [Quit: WeeChat 3.8]
neuroevolutus has joined #ocaml
olle has joined #ocaml
Serpent7776 has quit [Ping timeout: 252 seconds]
azimut has joined #ocaml
dhil has quit [Ping timeout: 246 seconds]
wingsorc has joined #ocaml
bartholin has quit [Quit: Leaving]
azimut has quit [Remote host closed the connection]
azimut_ has joined #ocaml
luke76 has joined #ocaml
szkl has quit [Quit: Connection closed for inactivity]
olle has quit [Ping timeout: 250 seconds]
neuroevolutus has quit [Quit: Client closed]
luke76 has quit [Ping timeout: 246 seconds]
liminal has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]