<discocaml>
<Kali> the issue here is that you only need one wildcard for records
<discocaml>
<Kali> since records are not positional, you just need {name; _}
<discocaml>
<Kali> you don't need a wildcard for each element
<discocaml>
<Kali> just one for all not matched on
boozec has joined #ocaml
<darchitect>
oh brilliant !
<darchitect>
it makes perfect sense
<darchitect>
is there a cleaner way to match this without needing the inner match btw ?
<discocaml>
<Kali> not really, unless you consider
<discocaml>
<Kali> | r::_ -> r.name
<discocaml>
<Kali> to be cleaner
<octachron>
You can inline the second match in the first. `PhysicalAddressBook ({name;_} :: _ ) ->`. Not sure if I would call that cleaner.
<darchitect>
yeah it's not really cleaner since I have to handle the empty list case as well
<darchitect>
but thanks anyway !
<darchitect>
thinks are starting to click
<discocaml>
<_ggole> You can nest the matches directly, like `| PhysicalAddressBook ({name; _}::_) -> name`
<discocaml>
<pigeon.v> companion_cube: you could wrap the parser inside a functor, or am I missing something?
neiluj has joined #ocaml
mro has joined #ocaml
mro has quit [Ping timeout: 260 seconds]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
szkl has quit [Quit: Connection closed for inactivity]
<discocaml>
<Ada> raphaal i would avoid using Str in general
<raphaal>
why?
<raphaal>
and what I should use instead?
mro has quit [Ping timeout: 268 seconds]
<discocaml>
<Ada> it uses global state, the performance is pretty bad and it only supports a small non standard subset of regex
<discocaml>
<Ada> i like re, does full perl style regexes , there are a few other options as well
<dinosaure>
raphaal: ocaml-re can be a solution if you want to use regex
<dinosaure>
str is not actively maintained
<discocaml>
<Ada> it’s a separate library nowadays so it’s only really kept around for compatibility
<raphaal>
thanks, I'll check it
<raphaal>
maybe stupid question, is there a doc for the Re?
<discocaml>
<._null._> ocaml.org/p/re (you can replace re with any package)
<raphaal>
thanks, not the best, but it's better than reading source or tests directly
torretto has joined #ocaml
alexherbo2 has joined #ocaml
<companion_cube>
@pigeon.v hu, not a bad idea with a generateive functor
mro has joined #ocaml
waleee has quit [Quit: updating stuff]
boozec has quit [Ping timeout: 264 seconds]
mro has quit [Ping timeout: 260 seconds]
boozec has joined #ocaml
noddy has quit [Quit: WeeChat 4.1.1]
noddy has joined #ocaml
torretto has quit [Quit: WeeChat 4.1.1]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
boozec has quit [Ping timeout: 260 seconds]
azimut has quit [Ping timeout: 255 seconds]
famubu has quit [Quit: leaving]
neiluj has quit [Remote host closed the connection]
boozec has joined #ocaml
dreadedfrog has joined #ocaml
boozec has quit [Ping timeout: 240 seconds]
dreadedfrog has quit [Remote host closed the connection]
<darchitect>
hey guys
<darchitect>
I've got 2 .ml files in lib/ using dune. I want to import a type and it's constructors from one of the files to the other so that i don't get unbound module exception. What is the best way to do this ?
<darchitect>
example -> I need to import Leaf, Node (type 'a btree) from lib/btree.ml into lib/example_functions.ml
oriba has joined #ocaml
dnh has joined #ocaml
azimut has joined #ocaml
average has joined #ocaml
bartholin has joined #ocaml
fweht has quit [Quit: Connection closed for inactivity]
boozec has joined #ocaml
darchitect has quit [Ping timeout: 268 seconds]
darchitect has joined #ocaml
azimut has quit [Remote host closed the connection]
<discocaml>
<._null._> Usually you would just `open Btree`, but you can do `type 'a btree = 'a btree = Leaf | Node of... `
<discocaml>
<._null._> Usually you would just `open Btree`, but you can do `type 'a btree = 'a Btree.btree = Leaf | Node of... `
azimut has joined #ocaml
boozec has quit [Quit: boozec]
rgrinberg has joined #ocaml
Tuplanolla has joined #ocaml
waleee has joined #ocaml
darchitect has quit [Ping timeout: 260 seconds]
darchitect has joined #ocaml
azimut has quit [Ping timeout: 255 seconds]
torretto has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
average has quit [Quit: Connection closed for inactivity]
Anarchos has joined #ocaml
<discocaml>
<Ada> how is printf able to change its arguments based on a string?
motherfsck has quit [Remote host closed the connection]
<discocaml>
<Ada> i'm building a router and this would be an interesting way to handle parameters and query strings, but all i've found so far is ppx which seems rather complex
motherfsck has joined #ocaml
<discocaml>
<octachron> Printf argument is not a string.
<discocaml>
<octachron> It is a format string which is using a bit of special compiler support to share the same syntax as string.
<discocaml>
<Ada> ahh,
<discocaml>
<Kali> is there a way to concatenate format strings?
<discocaml>
<Kali> ^^
<discocaml>
<Kali> oh, found it
<discocaml>
<octachron> "%s" is short-hand for `Format (String (No_padding, End_of_format), "%s")`
<discocaml>
<octachron> Where `String` is a GADT constructor.
<discocaml>
<Ada> if i want the string syntax and the learning experience its probably more practical than anything to build a ppx around that and let it handle the matching since it seems very robust
<discocaml>
<octachron> For an example of one variant of heterogeneous lists.
<discocaml>
<octachron> which can be used to replace `Format.fprintf ppf "%s %s n°%d" "Hello" "world" 6` with `fprintf ppf "%s %s n°%d" ["Hello"; "world"; 6 ]`.
<discocaml>
<diligentclerk> I have an insane bug I don't know how to fix so here is a weird question, kind of a hail mary. If I compile OCaml with foreign C source code is it possible that OCaml's garbage collection strategy depends on the number of like, entry points exposed in the C code's header file
<discocaml>
<diligentclerk> Because it seems like when I make unrelated changes to the C source code it triggers a segfault that I suspect is due to an accidental read after deallocation
jabuxas has quit [Ping timeout: 256 seconds]
<discocaml>
<Kali> aha
<discocaml>
<diligentclerk> and the only explanation I can come up with is that OCaml's garbage collection is behaving in a slightly different way as a function of the exposted signature of the C code
<discocaml>
<diligentclerk> even when I make changes to functions that aren't actually called in the OCaml executable
<discocaml>
<octachron> It sounds like you have a bug in your C code that is only lucky enough to trigger a segfault with the right code structure.
<discocaml>
<diligentclerk> Well, I don't mean it's a bug in the OCaml garbage collector, I mean that the OCaml wrapper code for the C code registers certain foreign objects with the garbage collector and I suspect I somehow screwed this up.
<discocaml>
<diligentclerk> In any case I don't know how to debug the C source code, it's transcompiled from another language and it's not really human readable. The \*.mli and \*.ml wrappers are also procedurally generated and I'm not thrilled about reading those in detail either.
<discocaml>
<diligentclerk> Well, I don't mean it's a bug in the OCaml garbage collector, I mean that the OCaml wrapper code for the C code registers certain foreign objects with the garbage collector and I suspect I somehow screwed this up.
<discocaml>
<diligentclerk> In any case I don't know how to debug the C source code, it's transcompiled from another language and it's not really human readable. The \*.mli and \*.ml wrappers are also procedurally generated and I'm not thrilled about reading the ml file in detail either.
<discocaml>
<octachron> You could try to run lintcstubs on the C stubs; or insert call to the major GC after each call to C functions on the OCaml side to make the failure more deterministic.
mal`` has quit [Quit: Leaving]
Serpent7776 has quit [Ping timeout: 264 seconds]
Anarchos has quit [Quit: Vision[]: i've been blurred!]