rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shawnw has quit [Ping timeout: 264 seconds]
gravicappa has joined #ocaml
mro has joined #ocaml
Exagone313 has joined #ocaml
jonasbits_ has joined #ocaml
ski_ has joined #ocaml
dinosaure1 has joined #ocaml
daimrod2 has joined #ocaml
tizoc` has joined #ocaml
Franciman has quit [Ping timeout: 260 seconds]
Exa has quit [Ping timeout: 260 seconds]
smondet[m] has quit [Ping timeout: 260 seconds]
mewfree[m] has quit [Ping timeout: 260 seconds]
Exagone313 is now known as Exa
tizoc has quit [Ping timeout: 260 seconds]
ski has quit [Ping timeout: 260 seconds]
dinosaure has quit [Ping timeout: 260 seconds]
daimrod1 has quit [Ping timeout: 260 seconds]
jonasbits has quit [Ping timeout: 260 seconds]
Franciman has joined #ocaml
mewfree[m] has joined #ocaml
smondet[m] has joined #ocaml
Haudegen has joined #ocaml
vicfred has quit [Quit: Leaving]
hendursa1 has joined #ocaml
hendursaga has quit [Ping timeout: 276 seconds]
<d_bot>
<octachron> @Et7f3 : failed test: the test was run, behaved as expected and reported a "failed" result. unexpected error: there was an error when trying to run the test and no reporting was ever done.
bobo has joined #ocaml
spip has quit [Ping timeout: 265 seconds]
<d_bot>
<joris> Hi, a week ago i created a new local switch with opam. At this time, i had LDFLAGS set on my local shell. Since then, opam keeps trying to reuse this LDFLAGS value in all build, even though it is not in env anymore 🤯
<d_bot>
<joris> any idea where this state is stored ?
mro has quit [Remote host closed the connection]
mro has joined #ocaml
olle has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
bartholin has joined #ocaml
<d_bot>
<joris> whatever i'm recreating the switch
cedric has joined #ocaml
tizoc` is now known as tizoc
rond_ has joined #ocaml
kakadu has joined #ocaml
<sim642>
Switched a dune-project from 2.3 to 2.8 and now the binaries it produces have no write permissions any more. Why is that? I have some scripts which copy those out for usage, so it screws with that overwriting.
<d_bot>
<Emile Trotignon> reason is just another syntax for ocaml. You can mix them with no particular configuration in a given project. Just name the reason files .re and the ocaml files .ml, and everything will work fine
mro has quit [Remote host closed the connection]
<d_bot>
<Emile Trotignon> However its true that revery is easier to use with reason syntax, but its not a requirement at all.
glassofethanol has joined #ocaml
gravicappa has quit [Ping timeout: 258 seconds]
glassofethanol has quit [Client Quit]
glassofethanol has joined #ocaml
mro has joined #ocaml
mro has quit [Ping timeout: 258 seconds]
Haudegen has quit [Quit: Bin weg.]
bobo has quit [Ping timeout: 260 seconds]
hackinghorn has quit [Quit: Leaving]
gareppa has joined #ocaml
<vsiles>
sim642: strange, I'm getting a .exe with the executable rights with 2.9
gareppa has quit [Remote host closed the connection]
<vsiles>
what file system are you building on ?
bobo has joined #ocaml
spip has joined #ocaml
bobo has quit [Ping timeout: 252 seconds]
<leah2>
i'm trying to build coq 8.14 with dune, but it fails linking the toplevels... it passes /usr/lib/ocaml/zarith/zarith.cma directly as an argument, but then can't find dllzarith.so (same dir), how can i make it use a -I /usr/lib/ocaml/zarith line?
<Franciman>
hi leah2 :P
<leah2>
;)
mbuf has quit [Quit: Leaving]
Haudegen has joined #ocaml
mro has joined #ocaml
mro has quit [Ping timeout: 260 seconds]
nfc_ has quit [Ping timeout: 260 seconds]
glassofethanol has quit [Quit: leaving]
<saltrocklamp[m]>
in `try do_stuff with BadThing -> ...`, how do i get access the exception itself? e.g. to use `Printexc.to_string` on it.
<octachron>
the exception itself is `BadThing`?
<octachron>
in other words, `BadThing` is a standard extension constructor of the type `exn`
<smondet[m]>
to give it a name you can use `as`
<saltrocklamp[m]>
yes, e.g. `Stream.Failure`
<smondet[m]>
`with Bad_thing as this_exn -> OPrintexc.to_string this_exn`
<saltrocklamp[m]>
and thanks smondet , that looks like it worked
gopiandcode has quit [Ping timeout: 258 seconds]
nfc_ has joined #ocaml
tomku has quit [Quit: Lost terminal]
mro has joined #ocaml
gopiandcode has joined #ocaml
<d_bot>
<NULL> What octachron was implying is that for an exception without arguments, you don't need to name it to reuse it, `Printexc.to_string Bad_thing` will be the same as `Printexc.to_string this_exn` (and when there are arguments, you could repass them). Naming is easier in this case
<d_bot>
<NULL> in this last* case
mro has quit [Ping timeout: 258 seconds]
<saltrocklamp[m]>
oh, i see
bobo has joined #ocaml
<saltrocklamp[m]>
i am now looking into ocamldoc syntax, and it looks like record member comments come after the record, on the same line. is it also possible to put the comment before the record? i have a somewhat detailed doc comment and it looks very ugly to have it dangling off the right side
<companion_cube>
it doesn't have to be on the same line
<companion_cube>
but you can't have an empty line between the record and comment.
<saltrocklamp[m]>
ok, so the comment can be on the line right below it? as opposed to above, like in most other cases
spip has quit [Ping timeout: 260 seconds]
Manis has joined #ocaml
<companion_cube>
it can be above too
<companion_cube>
I personally like it below, but you know, choices
<companion_cube>
it'll tell you if some doc comments are dangling
<Manis>
Hi. I'm trying to parse a file in OCaml that contains different IDs of the form [a-z]{3}[0-9]{6}. To make it easier to apply pattern matching I thought that it would make sense to convert the string into a structure of some form. It would be nice if e.g. abc000001-style IDs could be stored in some AbcID while def123456 IDs would be a DefID (for a given set of 3-letter prefixes). Being able to convert from/to strings would be a plus. Could some
<Manis>
point me to an OCaml structure that would be appropriate for such a problem?
<saltrocklamp[m]>
"warning 50" sounds like something out of a dystopian novel, like "catch 22" :P
<d_bot>
<darrenldl> Manis: just use two maps/trees?
tomku has joined #ocaml
<saltrocklamp[m]>
my naive translation of my newbie-level understanding of haskell would be: `type thing_id = | AbcId of string | DefId of string` and a function `parse_id : string -> thing_id`
<saltrocklamp[m]>
or `parse_id : string -> thing_id option`
<Manis>
saltrocklamp: That could work… I guess I was thinking way too far
<Manis>
Basically all I want to do it attach a label to the value so that I can pattern match it.
<Manis>
Another problem where I have probably been thinking way too far. I'm reading in multiple files via a parsing function that returns an assoc list. It there an "easy" way to merge all those association lists into a hashtbl using a custom merging function for key collisions?
<companion_cube>
I'd suggest using `Map` instead of lists
<Manis>
My current approach is List.assoc -> Seq -> Map -> Map.union -> Seq -> Hashtbl.
<companion_cube>
you could have `Map` and only `Map` :)
<Manis>
Isn't a Map slower for lookups?
<companion_cube>
it's faster than assoc lists anyway
<d_bot>
<Et7f3> Thanks so I should focus more un unexpected failure.
<Manis>
Certainly, I'm just using the assoc list to fill the hash table once. After being filled at start up it is static and only lookups will occur on it, that's why I'm asking.
<companion_cube>
oh ok.
Boarders has quit [Ping timeout: 264 seconds]
Boarders has joined #ocaml
<d_bot>
<darrenldl> the number of possible 3 letter prefixes is fixed?
<sim642>
vsiles, executable yes, but not writable. The permissions are r-xr-xr--
mro has joined #ocaml
mro has quit [Remote host closed the connection]
<Manis>
darrenldl: Yes, there's only three valid 3 letter prefixes.
<companion_cube>
NSA, FBI, CIA?
<Manis>
damn, they figured it out!
* Manis
has left the chat
<d_bot>
<darrenldl> hm...i don't know if i'd go with record type instead tbh
spip has joined #ocaml
bobo has quit [Read error: Connection reset by peer]
<Manis>
I wanted to go with records initially. Maybe, instead of trying to have different types I could just pattern match on the record fields instead.
mro has joined #ocaml
<Manis>
And put the prefix in one field and the number in the other.
<d_bot>
<darrenldl> ye, just have one field be of variant type
<d_bot>
<darrenldl> my gut feeling is you'd end up having to write accessors if you go against the record type route
<d_bot>
<darrenldl> at which point, eh
<Manis>
of variant type?
<d_bot>
<darrenldl> yep
pmetzger has joined #ocaml
<d_bot>
<darrenldl> from my experience, type t = ABC of string | DEF of string is less convenient than type prefix = ABC | DEF type t = { prefix: prefix; id : string }
mro has quit [Remote host closed the connection]
<d_bot>
<darrenldl> (when you want to ensure the string is of uniform structure)
<Manis>
My OCaml lingo is not that great. Do you mean: type prefix = CIA | FBI | Nsa ;; type ident = { prefix: prefix, id: int } ?
<d_bot>
<darrenldl> correct
<Manis>
Looks reasonable. I'll go with that. Thanks a lot for helping me out of my confusion!
hendursa1 has quit [Quit: hendursa1]
pmetzger has quit [Client Quit]
<d_bot>
<darrenldl> the only exception i'd make is if the distinction is very significant, say when dealing with cryptographic keys or what have you
<saltrocklamp[m]>
interesting, that "discriminator" design i think is considered an antipattern in other languages
hendursaga has joined #ocaml
<d_bot>
<darrenldl> incidentally i have no clue what's the idiomatic way : D
<saltrocklamp[m]>
also, it's not as easy to pattern match on individual record fields on those other languages
<Manis>
saltrocklamp: What languages are you talking of?
rgrinberg has joined #ocaml
gravicappa has joined #ocaml
<d_bot>
<RegularSpatula> Do the different ID types get different “treatments” or whatever, or do you just need to make sure they start with the correct 3 letter code and then “remember” it?
<d_bot>
<RegularSpatula> But not really treat them any differently
bartholin has quit [Quit: Leaving]
<Manis>
RegularSpatula: They are not treated differently. There will be an API in front of it and I just need to make sure that the "NSA"-API only accepts NSA IDs and then look up the values for that NSA ID in the hashtbl and return it.
<d_bot>
<RegularSpatula> Ahh i see , that makes sense
<d_bot>
<darrenldl> so an array/triple of hashtable is all you need really for look up
<Manis>
I just need to figure out how to get the data in the hashtbl now.
<Manis>
Is it possible to match variants in a record field without using a guard?
<saltrocklamp[m]>
Manis: java and python, for example
<d_bot>
<darrenldl> i thought match x.field with | ... is pretty simple already
<Manis>
saltrocklamp[m]: Ah, yes, that's probably what confused me because I feel more comfortable in those languages :-)
<Manis>
m( sometimes I really wonder what I'm doing here…
<d_bot>
<darrenldl> saltrocklamp: those languages dont have pattern matching to begin with, let alone record field
<Manis>
I was trying `match rec with | { NSA; id } -> ...`
<Manis>
Python 3.10 has now added pattern matching btw.
<octachron>
using a guard is an anti-pattern for matching the content of a field: `{ field = X; _ }` works and is more efficient
<Manis>
octachron: YES! Thanks, that's what I was looking for.
<Manis>
One more question to record field matches: What is the order of fields in a match? The definition order?
<d_bot>
<darrenldl> i dont know about pattern matching in languages with no good enum
<d_bot>
<darrenldl> you can pick any order
<d_bot>
<darrenldl> but _ must be at the end
<Manis>
as long as the "variables"(?) have the same name as the field?
<octachron>
(and `_` is optional and is only here to tell the compiler that you are aware that there are other fields)
<Manis>
I see.
<d_bot>
<darrenldl> { field; _ } pattern matches the field and binds it to name "field"
<d_bot>
<darrenldl>
<d_bot>
<darrenldl> { field = x; _ } binds it to name x
<Manis>
That's confusing. comparison is = and assignment, too?
Tuplanolla has joined #ocaml
<companion_cube>
there is no real assignment
<companion_cube>
there's `let x = y in …`
<Manis>
That depends on your definition of assignment, doesn't it?
<Manis>
You assign the value of said field to a new name.
<Manis>
I still call them variables, although they are static.
<companion_cube>
it's a binding, but yeah
<Manis>
or constant, rather.
<Corbin>
It's a binding, for sure.
<companion_cube>
you can do `let (x,y) = … ` too
<companion_cube>
so it's more of a irrefutable pattern matching
<Manis>
companion_cube: Is there a semantic difference between binding and assigning?
<companion_cube>
idk, assigning for me is more like `:=`
<companion_cube>
put a value in a mutable box :p
<Corbin>
An assignment to a name occurs after the name is created. A binding creates the name and attaches its value in one single motion.
<Manis>
^ this sounds legit.
<Manis>
I just never thought about it.
<Corbin>
There's an underlying assumption that we are usually making: Assignable names are a specific sort of created object.
<Corbin>
Whereas a binding is just a feature of the syntax, subject to at least a gentle form of referential transparency. `let` is a great example of this; `let x = y in z` is just like `(fun x -> z)(y)`, with the same sort of binding. (Modulo companion_cube's point about irrefutable patterns!)
<Manis>
That's a very good explanation for why let ... and ... cannot reference each other.
<Manis>
So it's very unlike Haskell's let which (AFAIK) creates an alias for some "code".
<companion_cube>
haskell's let is recursive by default, and is in a lazy language, so yeah :D
<Corbin>
Haskell's let is a "letrec" -- what companion_cube said.
<companion_cube>
in OCaml, `let x = y in z` means y is a value already
<companion_cube>
in haskell, y woudl be a thunk
<Manis>
Can't a function inside a submodule call another function from that submodule?
<Manis>
Or rather, can a function in a submodule reference the submodule it's in?
<companion_cube>
no
<octachron>
A function can always call any other functions which is in the scope.
<octachron>
But you cannot sneak in recursion in a function through a submodule
<Manis>
How would calling another function defined in the same submodule make some other function recursive?
<companion_cube>
module M = struct let f x = M.f x end
<companion_cube>
no? :p
rond_ has quit [Quit: Client closed]
<Manis>
I was thinking of `module M = struct let f x = M.g x let g x = 42 end`.
<d_bot>
<somebody> re: assignment vs rebinding, imo it's more obvious when you think about reassignment vs rebinding (since, well, that's where the differences lie). so reassignment (basically) updates a previous reference, rebinding always creates a new one
<d_bot>
<darrenldl> Manis: there is also the gotcha of assignment when the name is visible across multiple smaller scopes
<d_bot>
<somebody> aka shadowing
<d_bot>
<somebody> i mean... assignment in general comes with a lot of gotchas imo
<Manis>
rebinding shadows the old binding but reassigning doesn't.
<d_bot>
<somebody> e.g. assigning to the same variable in an async loop is a relatively common source of trouble in some languages
<d_bot>
<darrenldl> reassigning also means you need to restore state more often than you might want
Haudegen has quit [Quit: Bin weg.]
hendursaga has quit [Ping timeout: 276 seconds]
hendursaga has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
zebrag has joined #ocaml
Haudegen has joined #ocaml
wonko has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
kakadu has quit [Quit: Konversation terminated!]
kurfen has joined #ocaml
Skyfire has quit [Quit: WeeChat 3.3]
chrisz has quit [Quit: leaving]
olle has quit [Ping timeout: 260 seconds]
bobo has joined #ocaml
spip has quit [Ping timeout: 260 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
Manis has quit [Quit: Manis]
gravicappa has quit [Ping timeout: 260 seconds]
cedric has quit [Quit: Konversation terminated!]
gravicappa has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
herrschreinerei has joined #ocaml
<herrschreinerei>
hello guys. I stumbled upon the >|= operator and I really don't know how to look it up, I guess it's in Batteries but I really have no clue. Do you have any pointer?
<companion_cube>
it's in the stdlib too
<companion_cube>
look for it in the Stdlib module
<herrschreinerei>
ow
<herrschreinerei>
ok
<companion_cube>
it's called the pipe operator
<herrschreinerei>
thx
<herrschreinerei>
rly
<herrschreinerei>
it's not |>?
<companion_cube>
oh fuck, I misread
<companion_cube>
ok, >|= is not standard
<companion_cube>
it's an infix "map" operator by convention
<companion_cube>
for many different things (option, list, monads…)
<herrschreinerei>
oooh that make sense in the context
<herrschreinerei>
ok thx
<companion_cube>
>>= is bind, >|= is map
<companion_cube>
generally
kurfen has quit [Quit: WeeChat 2.3]
<herrschreinerei>
yeah that's what I missed
<herrschreinerei>
let (>|=) = Lwt.(>|=)
<herrschreinerei>
all right sorry for the noise, simple stuff :D
gravicappa has quit [Ping timeout: 260 seconds]
ski_ is now known as ski
wonko has quit [Ping timeout: 252 seconds]
<saltrocklamp[m]>
what's the "right way" to create a switch that just follows the latest stable release, for general-purpose system-wide use? i did `opam switch create ocaml-base-compiler`, is that okay? i noticed there's also an `ocaml` package, so i'm wondering if i could have done `opam switch create ocaml` instead. also, if i do `opam switch create ocaml-system` and then activate it and run `opam install`, do the installed packages get saved to
<saltrocklamp[m]>
`~/.opam` or do they go to some system-wide location?
<companion_cube>
they still go in ~/.opam iirc
<companion_cube>
you can use a fixed version of OCaml in a switch, and then upgrade it later with --unlock-base
<saltrocklamp[m]>
ah, looks like it's `--update-invariant`, which i remember someone had told me to use once
zebrag has quit [Quit: Konversation terminated!]
* ski
. o O ( `module rec' )
rgrinberg has joined #ocaml
shawnw has joined #ocaml
zebrag has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]