Leonidas changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.1.1 released: https://ocaml.org/releases/5.1.1 | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
Tuplanolla has quit [Quit: Leaving.]
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
xd1le has quit [Remote host closed the connection]
xd1le has joined #ocaml
jabuxas has joined #ocaml
jabuxas has quit [Ping timeout: 256 seconds]
xd1le has quit [Quit: xd1le]
waleee has quit [Ping timeout: 255 seconds]
motherfsck has quit [Ping timeout: 255 seconds]
motherfsck has joined #ocaml
Square2 has joined #ocaml
Serpent7776 has joined #ocaml
bartholin has joined #ocaml
bibi_ has quit [Quit: Konversation terminated!]
torretto has quit [Ping timeout: 260 seconds]
torretto has joined #ocaml
olle has joined #ocaml
bartholin has quit [Quit: Leaving]
steenuil has quit [Remote host closed the connection]
steenuil has joined #ocaml
dnh has joined #ocaml
dnh has quit [Ping timeout: 255 seconds]
infinity0 has joined #ocaml
dnh has joined #ocaml
jabuxas has joined #ocaml
a51 has joined #ocaml
<reynir> There is no way to say "this module has this signature except member foo is actually called bar", right?
<reynir> For example, given a functor `module F(T : sig val foo : unit -> int end) = struct let foooo () = T.foo () + T.foo () end` and a module `module M = struct bar () = 42 end` you can't write `module M' = F(M with val foo = bar)` or so?
<discocaml> <dinosaure> you can do `F(struct include M let foo = bar end)`
<discocaml> <dinosaure> so it's not an exclusion but you add what is required for `F`
<discocaml> <_ggole> Yeah, some variant of `include` trick seems necessary
omegatron has joined #ocaml
<reynir> yes so basically you have to define a new module
a51 has quit [Quit: WeeChat 4.2.1]
a51 has joined #ocaml
justache is now known as fotastache
jabuxas has quit [Ping timeout: 272 seconds]
Square2 has quit [Ping timeout: 255 seconds]
olle has quit [Ping timeout: 255 seconds]
Serpent7776 has quit [Ping timeout: 255 seconds]
<discocaml> <cavemon.dev> what does `!` mean in `type !'a t`?
<discocaml> <smondet> It's an injectivity annotation
<discocaml> <cavemon.dev> how about `.` ? not seeing it on that page
<discocaml> <cavemon.dev>
<discocaml> <cavemon.dev> ```ocaml
<discocaml> <cavemon.dev> let null_ty : 'a. 'a t -> 'a option t =
<discocaml> <cavemon.dev> ```
fotastache has quit [Quit: ZNC 1.8.2 - https://znc.in]
<discocaml> <cavemon.dev> is it this? https://v2.ocaml.org/manual/types.html#typexpr
<discocaml> <cavemon.dev>
<discocaml> <cavemon.dev> ```
<discocaml> <cavemon.dev> poly-typexpr ::= typexpr
<discocaml> <cavemon.dev> ∣  { ' ident }+ . typexpr
<discocaml> <cavemon.dev> ```
<discocaml> <Kali> `typevar.` indicates an explicit universal quantification on that type variable
<discocaml> <Kali> (or type variables, you can have multiple: `'a 'b.`)
<discocaml> <Kali> this is usually hidden in type signatures since it's just implied, but sometimes you need to explicitly write it to make sure you get the right type, like when putting a polymorphic function in a record
<discocaml> <Kali> ```ocaml
<discocaml> <Kali> type example = {
<discocaml> <Kali> f : 'a -> 'a (* wrong: 'a is unqualified *)
<discocaml> <Kali> }
<discocaml> <Kali>
<discocaml> <Kali> type example = {
<discocaml> <Kali> f : 'a. 'a -> 'a (* correct *)
<discocaml> <Kali> }
<discocaml> <Kali> ```
<discocaml> <cavemon.dev> here's the source for context https://github.com/tjdevries/octane.ml/blob/master/lib/type.ml
<discocaml> <cavemon.dev>
<discocaml> <cavemon.dev> ```ocaml
<discocaml> <cavemon.dev> let null_ty : 'a. 'a t -> 'a option t =
<discocaml> <cavemon.dev> fun (type a) (ty : a t) : a option t ->
<discocaml> <cavemon.dev> match ty with
<discocaml> <cavemon.dev> | INTEGER -> NULLABLE INTEGER
<discocaml> <cavemon.dev> | REAL -> NULLABLE REAL
<discocaml> <cavemon.dev> | TEXT -> NULLABLE TEXT
<discocaml> <cavemon.dev> | BOOLEAN -> NULLABLE BOOLEAN
<discocaml> <cavemon.dev> | NULLABLE _ -> invalid_arg "already a nullable type"
<discocaml> <cavemon.dev> ;;
<discocaml> <cavemon.dev> ```
<discocaml> <cavemon.dev> does qualified here mean something like "the return type here is the same as arg type"?
<discocaml> <Kali> unqualified is sort of like, this type variable is unbound, it just appeared out of nowhere
<discocaml> <Kali> you can't introduce a type variable without it first being bound
<discocaml> <Kali> like in 'a option, it's bound here:
<discocaml> <Kali> ```ocaml
<discocaml> <Kali> (* bound here *)
<discocaml> <Kali> type 'a option =
<discocaml> <Kali> | Some of 'a
<discocaml> <Kali> | None
<discocaml> <Kali> ```
<discocaml> <Kali> you can't do ```ocaml
<discocaml> <Kali> type option =
<discocaml> <Kali> | Some of 'a
<discocaml> <Kali> | None
<discocaml> <Kali> ```
<discocaml> <Kali> because 'a must be introduced before it is used
<discocaml> <Kali> in a normal type signature, these bindings are hidden to reduce noise
<discocaml> <Kali> for example `(fun x->x) : 'a -> 'a` is really `... : 'a. 'a -> 'a`
<discocaml> <cavemon.dev> are these two equivalent?
<discocaml> <cavemon.dev>
<discocaml> <cavemon.dev> ```ocaml
<discocaml> <cavemon.dev> type example = { f: 'a. 'a -> 'a }
<discocaml> <cavemon.dev>
<discocaml> <cavemon.dev> type 'a example = { f: 'a -> 'a }
<discocaml> <cavemon.dev> ```
<discocaml> <Kali> no
<dh`> no
<dh`> the first gives you a type "example" with a field f that is a function that takes any type and returns the same type
<discocaml> <._null._> Beware of large-ish code blocks, mind the bridge with IRC
<discocaml> <Kali> the first example is a record containing a function from any type to any type
<dh`> the second gives you a type "'t example" with a field f that takes a 't and returns a 't
<dh`> that is, the first takes any type (but that isn't very useful) and the second makes the type into a parameter of the example type
<discocaml> <Kali> the second example is a type parameterized by a type, that produces a record type containing a function from that type to that type
<discocaml> <Kali> for example `int example` is the type `{ f : int -> int }`
<discocaml> <cavemon.dev> i see what you mean
<discocaml> <Kali> but the first `example` function has to be applicable to all types
<discocaml> <Kali> `{ f = fun x -> x }` is ok, but `{ f = fun x -> x + 1 }` is not
<discocaml> <cavemon.dev> because + is int
<discocaml> <Kali> because it has type `int -> int`, which is less general than `'a -> 'a`
<discocaml> <cavemon.dev> makes sense
<discocaml> <cavemon.dev> finally what is `type a` in `fun ...`
<discocaml> <cavemon.dev> `fun (type a) (ty : a t) : a option t ->`
<discocaml> <._null._> A locally abstract type, so one which doesn't get unified with any other (except when GADTs are involved)
<discocaml> <leviroth> I disagree. For example the compiler is perfectly happy to let you write `((fun x -> x + 1) : 'a -> 'a)` even though it will not let you add a universal quantifier to the type.
<discocaml> <cavemon.dev> locally abstract meaning opaque? or can be any type like int
<discocaml> <._null._> It's locally abstract, just like regular arguments are locally abstract: you don't know what they are inside the value, you have to deal with all possibilities
<discocaml> <._null._> It's locally abstract, just like regular arguments are locally abstract: you don't know what they are inside the function, you have to deal with all possibilities
<discocaml> <cavemon.dev> so these are not the same correct?
<discocaml> <cavemon.dev> ```ocaml
<discocaml> <cavemon.dev> let filter = fun (type a) (data: a list) -> data
<discocaml> <cavemon.dev> let filter: 'a. 'a -> 'a = fun data -> data
<discocaml> <cavemon.dev> ```
<discocaml> <._null._> No, the first one is `let filter : 'a. 'a list -> 'a list = fun data -> data`
<discocaml> <cavemon.dev> so these are not the same correct?
<discocaml> <cavemon.dev> ```ocaml
<discocaml> <cavemon.dev> let filter = fun (type a) (data: a list) -> data
<discocaml> <cavemon.dev> let filter: 'a. 'a list -> 'a list = fun data -> data
<discocaml> <cavemon.dev> ```
<discocaml> <cavemon.dev> sorry i forgot to put `list` on second example
<discocaml> <._null._> Then yes, they will be the same
<discocaml> <cavemon.dev> are they only same because its an identity function?
<discocaml> <._null._> Locally abstract types are useful because they won't try to unify with any other type, and they're sometimes required (GADTs, FCMs) but apart from that they don't extend expressivity
<discocaml> <._null._> "they won't try" : when you have type errors they will be more readable
jabuxas has joined #ocaml
gentauro has quit [Read error: Connection reset by peer]
gentauro has joined #ocaml
<discocaml> <rongcuid> I'm trying to compile a fairly dated project (`cil-template`) which uses cmake, and I am getting errors about `UsdOCaml.cmake` cannot find a source file, likely because it's not searching for the ocaml file extension. Does anyone have an idea about how to deal with this?
<dh`> burn down the cmake
<dh`> (if you are building this because you're taking it up, burn down the cmake right away, you'll thank yourself later. if you're just trying to compile it, that's a harder question)
<discocaml> <rongcuid> Well, it's a tutorial repository...
jabuxas has quit [Read error: Connection reset by peer]
<discocaml> <rongcuid> Last time I touched ocaml dune wasn't a thing yet. I'm not sure how hard it will be to convert
jabuxas has joined #ocaml
<discocaml> <cavemon.dev> is there a contrived example to illustrate locally abstract vs. polymorphic? trying to wrap my head around it
<dh`> doesn't have to be dune, virtually anything is preferable to cmake, especially for ocaml where there's no standard support for it
<discocaml> <rongcuid> I need to understand how the project compiles first
<dh`> anyway if you can't burn it out next best guess is to search for a newer version of the ocaml-in-cmake infrastructure they're using
<dh`> since cmake is a fairly moving target
<discocaml> <rongcuid> It has this 1260 line cmake module
<dh`> I recommend against trying to understand cmake unless you have a lot of sanity points to spare
<dh`> especially that kind of cmake
<discocaml> <rongcuid> I'm trying to understand what this does `OCAMLOPTS -pp "camlp4o pa_macro.cmo ${PPARGS}"`
<dh`> it runs the camlp4 preprocessor (which is old and dead)
<dh`> or arranges to run it or something, depending on exactly what it is and what's around it
<discocaml> <rongcuid> This is basically the thing:
<discocaml> <rongcuid> ```cmake
<discocaml> <rongcuid> add_ocaml_executable(ciltutcc.exe
<discocaml> <rongcuid> OCAMLOPTS -pp "camlp5o pa_macro.cmo ${PPARGS}"
<discocaml> <rongcuid> OCAMLCOPTS -pp "camlp5o pa_macro.cmo ${PPARGS}"
<discocaml> <rongcuid> SOURCES ${CILTUT_SRC}
<discocaml> <rongcuid> PACKAGES ${CILTUT_PACKS})
<discocaml> <rongcuid> ```
<discocaml> <rongcuid> camlp5o is what I tried modifying to
jabuxas has quit [Ping timeout: 255 seconds]
<discocaml> <rongcuid> Ok, I hacked cmake to at least configure\
<discocaml> <rongcuid> Ok, I hacked cmake to at least configure
omegatron has quit [Quit: Power is a curious thing. It can be contained, hidden, locked away, and yet it always breaks free.]
<discocaml> <rongcuid> Was `Pervasive` the `Stdlib` now?
mccd has joined #ocaml
<companion_cube> yes
<dh`> ah
<dh`> in cmake-world those are named arguments to "add_ocaml_executable"
<dh`> so it's presumably adding that to two slightly different sets of compiler options
<dh`> which those are and when they're used is anyone's guess, you'll have to check the cmake for add_ocaml_executable
bartholin has joined #ocaml
<discocaml> <rongcuid> I think I have a good idea what the cmake build does. I'll take a quick look at dune and see how to rewrite it
<dh`> if you're lucky it's just ocamlopt <flags> foo.mli and ocamlopt <flags> foo.ml for all the sources
<dh`> then a final ocamlopt run with the results to link a program
<dh`> but it sounds like you'll need to find or build camlp4
<dh`> (camlp5 from what I understand is not very compatible)
<discocaml> <rongcuid> I have no idea what this command is supposed to do. I think it sets some compiler flags if I enable some option in cmake
<discocaml> <rongcuid> `camlp5o` seems to be backwards compatible with 4
<discocaml> <rongcuid> In this case, at least
<discocaml> <rongcuid> Are there any good quick tutorials on ocaml, especially for new features introduced in 5?
drakonis has quit [Quit: WeeChat 4.1.1]
Serpent7776 has joined #ocaml
drakonis has joined #ocaml
mccd has quit [Ping timeout: 272 seconds]
Anarchos has joined #ocaml
mccd has joined #ocaml
szkl has quit [Quit: Connection closed for inactivity]
Serpent7776 has quit [Ping timeout: 260 seconds]
<dh`> rongcuid: apparently not
<dh`> (I don't know of any but I'm not the right person to ask)
<Anarchos> how is the token COMMENT used in the ocaml parser ?
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
dnh has joined #ocaml
zanetti has quit [Quit: zanetti]
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<mccd> Man caqti without rapper is just so confusing
<mccd> I just want to run a query without any parameters
<mccd> but it says Caqti_request.exec is deprecated in favor of infix operators that are incomprehensible
mccd has quit [Ping timeout: 264 seconds]
Fardale has quit [Quit: WeeChat 3.0]
Fardale has joined #ocaml
Tuplanolla has joined #ocaml
dnh has joined #ocaml
<discocaml> <limp.biskit> the infix operators are quite good
germ has quit [Ping timeout: 255 seconds]
bartholin has quit [Quit: Leaving]
bibi_ has joined #ocaml