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/
waleee has quit [Ping timeout: 272 seconds]
<discocaml> <akhilindurti> is there a cleaner way to write this unit test?
<discocaml> <akhilindurti> ```OCaml
<discocaml> <akhilindurti> try
<discocaml> <akhilindurti> let _ = typecheck_prog prog in
<discocaml> <akhilindurti> true
<discocaml> <akhilindurti> with OverlappingInstance "overlapping instance for Eq forall 'a. box 'a" ->
<discocaml> <akhilindurti> true
<discocaml> <akhilindurti> ```
<discocaml> <akhilindurti> I don't actually care about the return value of `typecheck_prog`, but just care about exceptions it raises
<discocaml> <akhilindurti> is there a cleaner way to write this unit test?
<discocaml> <akhilindurti> ```OCaml
<discocaml> <akhilindurti> try
<discocaml> <akhilindurti> let _ = typecheck_prog prog in
<discocaml> <akhilindurti> true
<discocaml> <akhilindurti> with OverlappingInstance "overlapping instance for Eq forall 'a. box 'a" ->
<discocaml> <akhilindurti> true
<discocaml> <akhilindurti> ```
<discocaml> <akhilindurti> I don't actually care about the return value of `typecheck_prog`, but just care about exceptions it raises
<discocaml> <akhilindurti> i was thinking about pulling in ounit
<discocaml> <akhilindurti> but i'm already using dune test
<discocaml> <akhilindurti> oh i just found out about `test_unit`, makes it nicer
rgrinberg has joined #ocaml
<discocaml> <Kali> ```ocaml
<discocaml> <Kali> (try ignore (typecheck_prog prog)
<discocaml> <Kali> with OverlappingInstance ... -> ()); true
<discocaml> <Kali> ```
<discocaml> <Kali> (... is not literal)
<discocaml> <akhilindurti> i realized the test had a small bug, since the exception is required to occur. the first `true` should've been a `false`
<discocaml> <Kali> oh, i see
<discocaml> <akhilindurti> i wrote a tiny helper
<discocaml> <akhilindurti> ```OCaml
<discocaml> <akhilindurti> let assert_raises f e =
<discocaml> <akhilindurti> try
<discocaml> <akhilindurti> ignore (f ());
<discocaml> <akhilindurti> false
<discocaml> <akhilindurti> with exn -> equal exn e
<discocaml> <akhilindurti>
<discocaml> <akhilindurti> assert_raises
<discocaml> <akhilindurti> (fun () -> typecheck_prog prog)
<discocaml> <akhilindurti> (OverlappingInstance "overlapping instance for Eq forall 'a. box 'a")
<discocaml> <akhilindurti> ```
<discocaml> <Kali> that should work
<discocaml> <Kali> oh, actually, put a `let _ =` before the `assert_raises (...) (...)`
<discocaml> <Kali> or some sort of let binding
<discocaml> <Kali> otherwise it will be interpreted as part of assert_raises because whitespace is ignored
<discocaml> <akhilindurti> oh don't worry, these are located in separate places
<discocaml> <akhilindurti> the `assert_raises` is defined outside the inline tests
<discocaml> <akhilindurti> it's more like
<discocaml> <akhilindurti> ```ocaml
<discocaml> <akhilindurti> let assert_raises f e =
<discocaml> <akhilindurti> ...
<discocaml> <akhilindurti>
<discocaml> <akhilindurti> let%test "1" =
<discocaml> <akhilindurti> ...
<discocaml> <akhilindurti> ```
<discocaml> <Kali> oh, good
bibi_ has quit [Ping timeout: 260 seconds]
chrisz has quit [Ping timeout: 255 seconds]
chrisz has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<discocaml> <akhilindurti> is there like a linter that will warn me when right-to-left evaluation order could affect the semantics of my program?
<discocaml> <akhilindurti> or just something conservative that prevents you from applying functions to something other than variables
<discocaml> <Kali> what do you mean by "other than variables"?
<discocaml> <akhilindurti> so you can't write code like `TyArrow (inst from) (inst dst)`, you have to write it as `let ifrom = inst from in let idst = inst dst in TyArrow ifrom idst`
<discocaml> <akhilindurti> so you can't write code like `TyArrow (inst from) (inst dst)`, you have to write it as
<discocaml> <akhilindurti> `let ifrom = inst from in let idst = inst dst in TyArrow ifrom idst`
<discocaml> <Kali> (note that editing in this channel reissues the message on the irc side)
<discocaml> <akhilindurti> oof sorry
<discocaml> <Kali> i'm not aware of any; may i ask why?
<discocaml> <akhilindurti> i've been getting hit by the eval order recently, when i have side effects involved in the evaluation of arguments when applying a function
<discocaml> <akhilindurti> like i get that the solution is to defensively `let ... in` everything
<discocaml> <akhilindurti> but it'd be nice to have a tool that catches that
<discocaml> <sim642> I don't think there is. The prototype Salto analyzer wants to maybe eventually do that? But it's quite a difficult problem without annoying false positives
azimut has quit [Ping timeout: 252 seconds]
Serpent7776 has joined #ocaml
patrick is now known as Guest4170
Guest4170 has quit [Killed (sodium.libera.chat (Nickname regained by services))]
patrick__ has joined #ocaml
mro has joined #ocaml
olle has joined #ocaml
mro has quit [Quit: Leaving]
bartholin has joined #ocaml
xd1le has joined #ocaml
ns12 has joined #ocaml
bartholin has quit [Quit: Leaving]
dnh has joined #ocaml
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
chrisz has quit [Ping timeout: 255 seconds]
chrisz has joined #ocaml
<discocaml> <ariahudson0803> I'll teach anyone interested how to trade and earn $30k in just 72hrs from the crypto market.. Drop a direct message (HOW) for more details.
bibi_ has joined #ocaml
bibi_ has quit [Ping timeout: 260 seconds]
dnh has joined #ocaml
dnh has quit [Client Quit]
bibi_ has joined #ocaml
dnh has joined #ocaml
dnh has quit [Client Quit]
rgrinberg has joined #ocaml
bibi_ has quit [Ping timeout: 240 seconds]
patrick__ is now known as patrick
myrkraverk has quit [Quit: Leaving]
bibi_ has joined #ocaml
Anarchos has joined #ocaml
<Anarchos> ow to add (c_library_flags (-lbsd)) to the "dune/otherlibs/dune/src/dune" file , only for a particular platform ?
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
<toastal> Using Format or Fmt, is there a way to configure the margin to use tabs & not spaces?
<zozozo> toastal: I think that you can set the `out_ident` function of a formatter to change the way indentation of new lines is done
<zozozo> see Format.pp_set_formatter_out_functions and the surrounding doc in the Format module
justache has quit [Ping timeout: 258 seconds]
justache has joined #ocaml
remexre has quit [Ping timeout: 245 seconds]
remexre has joined #ocaml
adrien has quit [Ping timeout: 258 seconds]
adrien has joined #ocaml
<toastal> zozozo: will look. thanks.
masterbuilder has quit [Ping timeout: 258 seconds]
masterbuilder has joined #ocaml
sand_dull has joined #ocaml
gentauro has quit [Ping timeout: 245 seconds]
gentauro has joined #ocaml
tizoc has quit [Ping timeout: 245 seconds]
tizoc has joined #ocaml
sand_dull has quit [Remote host closed the connection]
sand_dull has joined #ocaml
sand_dull has quit [Remote host closed the connection]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
bartholin has joined #ocaml
jsoo has quit [Ping timeout: 245 seconds]
jsoo has joined #ocaml
Serpent7776 has quit [Ping timeout: 255 seconds]
azimut has joined #ocaml
<olle> Hm anonymized record with `with`?
<olle> like type Thing of {id: int};; let t = Thing {id = 1} in let t2 = t with id = 2???
<olle> How to google this even :d
<olle> Can I extract the record from the tag?
<discocaml> <deepspacejohn> you can bind the record to a name with `let Thing t2 = t`
<discocaml> <deepspacejohn> `let t = Thing {id = 1} in let Thing t2 = t in Thing {t2 with id = 2}`
<olle> Hmmm
<olle> Yea that should work, thanks! :)
<olle> Feel free to answer on SO for Internet points
sand_dull has joined #ocaml
Serpent7776 has joined #ocaml
<olle> I copy-pasted your answer to SO, deepspacejohn fyi
<olle> I can remove it if you want
<discocaml> <._null._> Thank you discocaml
sand_dull has quit [Remote host closed the connection]
bibi_ has quit [Ping timeout: 240 seconds]
rgrinberg has joined #ocaml
<Anarchos> i don't see the 'unnamed' part if you do let t=… or let t2= …
gareppa has joined #ocaml
alphacentauri has quit [Quit: WeeChat 4.0.5]
alphacentauri has joined #ocaml
dnh has joined #ocaml
waleee has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
bibi_ has joined #ocaml
alphacentauri has quit [Read error: Connection reset by peer]
alphacen1 has joined #ocaml
<olle> Anarchos: Who are you asking?
<discocaml> <deepspacejohn> olle: cool that's fine.
gareppa has quit [Quit: WeeChat 3.8]
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
dnh has joined #ocaml
Serpent7776 has quit [Ping timeout: 252 seconds]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
bartholin has quit [Quit: Leaving]
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dnh has joined #ocaml
spoof has joined #ocaml
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
spoof_ has joined #ocaml
spoof has quit [Ping timeout: 248 seconds]
spoof_ has quit [Client Quit]
olle has quit [Ping timeout: 272 seconds]
Tuplanolla has joined #ocaml
rgrinberg has joined #ocaml