wingsorc__ has quit [Remote host closed the connection]
wingsorc__ has joined #ocaml
MarvelousWololo has quit [Quit: MarvelousWololo]
mima has quit [Ping timeout: 246 seconds]
<discocaml>
<masterbuilder> why does it seem like all the set functions accept arguments in the reverse order from what you would expect?
<discocaml>
<masterbuilder> well, not all, but for example the order of the set itself and the element for functions that take those two arguments, and fold especially seems a bit unnatural to me
chrisz has quit [Ping timeout: 246 seconds]
<companion_cube>
Yeah it's annoying
<companion_cube>
Fold for set and map is a pain
chrisz has joined #ocaml
szkl has quit [Quit: Connection closed for inactivity]
haesbaert has quit [Remote host closed the connection]
bartholin has quit [Ping timeout: 246 seconds]
Anarchos has joined #ocaml
haesbaert has joined #ocaml
mclovin has joined #ocaml
bartholin has joined #ocaml
lobo[m] has joined #ocaml
reynir[m] has joined #ocaml
mima has joined #ocaml
gareppa has joined #ocaml
bartholin has quit [Ping timeout: 260 seconds]
bartholin has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
spip has joined #ocaml
Serpent7776 has joined #ocaml
serpent has joined #ocaml
<discocaml>
<chrisarmstrong> sorry if this seems like a silly question, but I was looking at `piaf` and noticed it's still awaiting a release for ocaml >=5.0 support. Will it be released on opam soon?
<discocaml>
<chrisarmstrong>
<discocaml>
<chrisarmstrong> I considered checking out the source code but its opam file contains pinned versions of a number of other repositories, which made me think not.
gareppa has quit [Quit: WeeChat 3.8]
gareppa has joined #ocaml
gareppa has quit [Client Quit]
gareppa has joined #ocaml
tom1212 has joined #ocaml
<tom1212>
hello! got a bunch of modules that rely on the assumption that their type t is the same while abstract, and do Obj.magic to get the underlying type and do stuff with it
<tom1212>
it's unorthodox, but is it really frown upon?
<discocaml>
<xavierm02_> I'd say it's better to avoid using Obj.magic where possible. In your case, you could a priori avoid using it by defining the common type somewhere, and then having all the modules provide functions from and to that type, which would replace your uses of Obj.magic
<discocaml>
<xavierm02_> And private types may be useful, depending on what you want exactly
<octachron>
tom1212, Obj.magic is not part of the langage. Any code relying on it is not valid OCaml.
<tom1212>
:)
<tom1212>
thanks! will investigate the use of private types
<octachron>
The intended use case for Obj.magic is more for higher-level language with more powerful type system using OCaml as a compilation target (aka Coq)
<tom1212>
basically I'm writing a wrapper over a C library that uses a single type to represent all objects
<discocaml>
<xavierm02_> Oh
<tom1212>
what I'm doing is a bunch of modules that wrap the object
<tom1212>
the problem is that anyone can write a module that satisfies the module type but still it will break some functors that rely on the assumption that the modules wrap a C object
<octachron>
It is not clear to me why you are using `Obj.magic`.
<tom1212>
to go from functor argument type coeff to C type gen
<tom1212>
coeff being an abstract type
<octachron>
`let one = Obj.magic R.one` is one of the worse possible pattern when using `Obj.magic`, you should really restrict the type as soon as possible.
<octachron>
Why lie to the type system if `coeff=gen`?
<tom1212>
what do you mean by "restrict the type as soon as possible."?
<tom1212>
because I don't want the API to expose the internal type gen
<tom1212>
but it might be a bad idea after all
<octachron>
You are already exposing the internal type. You are just also introducing potential segfaults along the way.
<octachron>
`let x: typ = Obj.magic ...`
<tom1212>
right...
<octachron>
One option is to expose that you have a familly of types.
<tom1212>
what would you suggest? make the types non abstract and remove as much Obj.magics?
<octachron>
by using a type `type 'a t` as an abstract type with a phantom parameter.
<octachron>
Then you have your own magic function: `'a t -> 'b t` which will only work on the type family inherited from C (if needed).
<tom1212>
interesting! can you show a little example please? it's hard for me to see how it would work
<discocaml>
<xavierm02_> I don't understand what the library is doing. YYou build polynomials on arbitrary rings, but the type that represents these polynomials is always the same?
<tom1212>
yeah that's a particularity of the C library that uses the same type for all objects
<discocaml>
<xavierm02_> Why do rings of polynomials interface with the C library, but not other rings?
<tom1212>
for now I've just tried polynomials, other rings are next
<discocaml>
<xavierm02_> In other words, why is it `module Polynomial (R : Ring) : Polynomial_sig with type coeff := R.t and type R.t := R.t` and not `module Polynomial (R : Ring with type t = gen) : Polynomial_sig with type coeff := R.t and type R.t := R.t`?
<tom1212>
xavierm02_: good catch! yes that would solve the issue!
<tom1212>
thanks :)
<octachron>
Basically, you are exposing the fact that the underlying library is dynamically typed, while still having the possibility of using the phantom parameter to try to add some static typing on the OCaml side.
<tom1212>
many thanks octachron! studying your example
<octachron>
And if you are not planning to add a layer of static typing, the simple option is to use the `gen` type directly.
<tom1212>
ok!
daimrod1 has quit [Server closed connection]
daimrod1 has joined #ocaml
jsoo has quit [Server closed connection]
jsoo has joined #ocaml
dinosaure has quit [Server closed connection]
dinosaure has joined #ocaml
serpent has quit [Quit: leaving]
azimut has joined #ocaml
tom1212 has quit [Remote host closed the connection]
tom1212 has joined #ocaml
<discocaml>
<xavierm02_> When working on two dune projects A and B, with B depending on A, how does one tell dune to use the local version of A when working on B?
<discocaml>
<anmonteiro> it's a bit hard to release it since it depends on a few forks. last time I vendored a bunch of libraries but it's still a bit of a bad experience
<discocaml>
<xavierm02_> But I'd prefer being able to use the current version of A from B even if it hasn't been committed / pushed
<discocaml>
<xavierm02_> Maybe I should just keep things in different packages of the same dune project for now
<discocaml>
<regularspatula> You can have multiple packages in a single dune project and develop them in tandem
<discocaml>
<regularspatula> Ah as you said
sbdln has joined #ocaml
<sbdln>
hello, I was trying to make a function to remove duplicates from an 'a list using filter but it doesn't seem to work, it keeps returning the original list given
<sbdln>
okay I just used "String.equal x h != true" and it works, thanx
<companion_cube>
`not (String.equal x h)`
<sbdln>
okay that's clean tanx
sbdln has quit [Quit: leaving]
tom1212 has quit [Remote host closed the connection]
gareppa has quit [Quit: WeeChat 3.8]
<discocaml>
<froyo> sbdln: never use == and !=, it's best you pretend they don't even exist
<discocaml>
<froyo> they have their niche uses which you'll find them when you need them
gareppa has joined #ocaml
gareppa has quit [Client Quit]
gareppa has joined #ocaml
<qwr>
sbdln: == and != test whether its same instance (except for bool and int, that don't have identity), = and <> are the general value equality that's usually wanted
<discocaml>
<hockletock> char also
szkl has quit [Quit: Connection closed for inactivity]
tom1212 has joined #ocaml
tom1212 has quit [Ping timeout: 246 seconds]
<discocaml>
<vphantom> Yes I wish the documentation buried `==` and `!=` much deeper. I needed my cheat sheet to remember to use `=` and `<>` for months… Still do in an occasional oops moment (typical of multi-lingual development.)
<discocaml>
<jumpnbrownweasel> using Containers (or i guess Base/Core) is nice for that, since they hide == and !=
<discocaml>
<bluddy5> It's a massive gotcha for programmers who use multiple languages regularly
<discocaml>
<bluddy5> or even just one language other than ocaml
mbuf has quit [Quit: Leaving]
<discocaml>
<geoff> Reading the manual or introductory book would clear it up in the pretty early operators section though
<discocaml>
<bluddy5> That's not really helpful. I deal with python and c++ regularly. When I come back to ocaml, I can't help it if I my brain accidentally uses the more universal symbols for comparison. Bugs can easily come about this way.
<discocaml>
<bluddy5> This is true, and is perhaps a bit of a saving grace. Since equality operators have issues regardless, I avoid them at all times. This helps avoid == and != as well.
<discocaml>
<deepspacejohn> it doesn't help that OCaml's general feeling of "if it compiles, it works" lures you into a false sense of security.
<discocaml>
<geoff> that's more a problem with how people (incorrectly) think about static typing though
<discocaml>
<bluddy5> Basically always use Containers or Base. These footguns are then disabled.
<discocaml>
<deepspacejohn> I also just avoid equality infix operators in general. IMO there's rarely a benefit to saving a few characters by `a = b` vs `String.equal a b`
<discocaml>
<regularspatula> I like `String.(a = b)`. At least base and containers have it
<discocaml>
<regularspatula> Actually not sure if containers puts it in infix module or not. But base has it in string
<discocaml>
<jumpnbrownweasel> it does. but i hadn't realized the benefit until you mentioned it!
<discocaml>
<jumpnbrownweasel> containers does. but i hadn't realized the benefit until you mentioned it!
<discocaml>
<jumpnbrownweasel> oops, meant to reply to @regularspatula
Anarchos has joined #ocaml
<discocaml>
<regularspatula> Pretty sure Ch 2 of the manual has a bit about local opens (if you haven’t seen it the syntax before)
Tuplanolla has joined #ocaml
tom1212 has joined #ocaml
tom1212 has quit [Remote host closed the connection]
tom1212 has joined #ocaml
ursa-major has joined #ocaml
waleee has joined #ocaml
<Anarchos>
opam is so long to install only one package ...
<Anarchos>
what a pain
<discocaml>
<lecondorduplateau> yah
tom1212 has quit [Remote host closed the connection]
tom1212 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
<discocaml>
<arbipher> I tried compiling a dune project on the recently updated macOS (`Apple clang version 14.0.3 (clang-1403.0.22.14.1)`) and found this error message:
<discocaml>
<arbipher>
<discocaml>
<arbipher> ```console
<discocaml>
<arbipher> /var/folders/s1/4f0tf3s97cn_dkx2ckzl69wc0000gn/T/build_190fb4_dune/camlobj3f0b50.c:14634:14: warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
<discocaml>
<arbipher> extern value caml_get_public_method();
<discocaml>
<arbipher> ^
<discocaml>
<arbipher> /var/folders/s1/4f0tf3s97cn_dkx2ckzl69wc0000gn/T/build_190fb4_dune/camlobj3f0b50.c:14836:14: warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
<discocaml>
<arbipher> extern value caml_set_oo_id();
<discocaml>
<arbipher> ```
<discocaml>
<arbipher>
<discocaml>
<arbipher> (Before I minimize the example demo,) I would like to ask if you have encounter similar problems and what could cause this.
<discocaml>
<anmonteiro> and would have to be changed in OCaml proper
<Anarchos>
interesting : i git clone mirage-crypto, made some modifications in it and run «opam install . --inplace-build». Bam, i get : « remove ocaml-variants 4.14.2+trunk* [conflicts with ocaml, eio]»
<Anarchos>
and it ends with : «66 to install | 102 to recompile | 2 to upgrade | 4 to remove»
<Anarchos>
just because i add a raw_getrandom stub for my OS . Something is flawed in my opam flow i guess
amk has quit [Ping timeout: 264 seconds]
tom1212 has left #ocaml [#ocaml]
bartholin has quit [Quit: Leaving]
Serpent7776 has quit [Ping timeout: 250 seconds]
ursa-major has quit [Quit: WeeChat 4.0.2]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
John_Ivan has joined #ocaml
amk has joined #ocaml
amk has quit [Remote host closed the connection]
amk has joined #ocaml
Anarchos has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]