companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.12 released: https://ocaml.org/releases/4.12.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: 240 seconds]
Haudegen has quit [Ping timeout: 258 seconds]
wilfred has quit [Quit: Connection closed for inactivity]
jtck has joined #ocaml
mbuf has joined #ocaml
wingsorc has joined #ocaml
jtck has quit [Remote host closed the connection]
wingsorc has quit [Quit: Leaving]
gravicappa has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
berberman_ has quit [Ping timeout: 240 seconds]
berberman has joined #ocaml
favonia has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
gravicappa has quit [Ping timeout: 265 seconds]
mbuf has quit [Ping timeout: 265 seconds]
mbuf has joined #ocaml
mbuf has quit [Ping timeout: 265 seconds]
mbuf has joined #ocaml
olle has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
Tuplanolla has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
Serpent7776 has joined #ocaml
favonia has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
unyu has quit [Quit: WeeChat 3.2]
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
Anarchos has joined #ocaml
olle has quit [Ping timeout: 268 seconds]
unyu has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
Haudegen has joined #ocaml
favonia has quit [Ping timeout: 240 seconds]
bartholin has joined #ocaml
favonia has joined #ocaml
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
gravicappa has joined #ocaml
vizard has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
Anarchos has joined #ocaml
gravicappa has quit [Ping timeout: 252 seconds]
gravicappa has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
<d_bot> <MemeMachine420> Hi All, how do I check whether I have a certain module installed?
<d_bot> <MemeMachine420> I'm trying to build a module but I get an unbound module `Core_kernel.std`
<d_bot> <MemeMachine420> `[NOTE] Package core_kernel is already installed (current version is v0.14.1).`
<d_bot> <MemeMachine420> `ocamlfind ocamlopt -o haha -linkpkg -package core_kernel sources.ml`
<d_bot> <MemeMachine420> ```
<d_bot> <MemeMachine420> File "sources.ml", line 1, characters 5-20:
<d_bot> <MemeMachine420> 1 | open Core_kernel.Std
<d_bot> <MemeMachine420> ^^^^^^^^^^^^^^^
<d_bot> <MemeMachine420> Error: Unbound module Core_kernel.Std
<d_bot> <MemeMachine420> ```
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
<d_bot> <ggole> `ocamlfind query package` will print the path to a package if it is installed and whinge if it is not, but note that packages are not the same as modules
<d_bot> <octachron> Module are packed within packages. They are essentially never installed directly.
<d_bot> <octachron> In this case, the `Core_kernel` module simply doesn't contain a `Std` submodule: https://ocaml.janestreet.com/ocaml-core/latest/doc/core_kernel/Core_kernel/index.html
<d_bot> <MemeMachine420> :SnowmanDecompiler:
<d_bot> <MemeMachine420> @octachron thank you I suspected this
<d_bot> <ggole> You can sort of tell because it says `Core_kernel.Std`; if `Core_kernel` were unbound it wouldn't mention the inner module
<d_bot> <MemeMachine420> I'm new to OCaml
<d_bot> <ggole> Bit of a subtlety there
<d_bot> <MemeMachine420> I could compile somethign with Core_kernel
<d_bot> <MemeMachine420> it was just an old tutorial I guess
<d_bot> <ggole> If you have it running in the toplevel you can `#show Core_kernel` to see what is in that module
<d_bot> <MemeMachine420> hmm I see thanks šŸ‘
<d_bot> <MemeMachine420> I'll just open an issue
favonia has quit [Ping timeout: 240 seconds]
mosterdt_ is now known as mosterdt
favonia has joined #ocaml
bartholin has quit [Ping timeout: 272 seconds]
bartholin has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
olle has joined #ocaml
favonia has quit [Ping timeout: 240 seconds]
vizard has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
vizard has joined #ocaml
mbuf has quit [Quit: Leaving]
vizard has quit [Ping timeout: 258 seconds]
vizard has joined #ocaml
waleee has joined #ocaml
waleee has quit [Client Quit]
vizard has quit [Ping timeout: 252 seconds]
waleee has joined #ocaml
vizard has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
<d_bot> <roddy> @MemeMachine420 I think you are looking at an old resource, Core/Core_kernel hasn't had a Std submodule for a while. If you're reading Real World OCaml, make sure it's the 2nd edition (URL starts with dev)
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
bartholin has quit [Ping timeout: 265 seconds]
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
bartholin has joined #ocaml
zebrag has joined #ocaml
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
wraithgourd has joined #ocaml
bartholin has quit [Quit: Leaving]
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
eight has quit [Ping timeout: 272 seconds]
eight has joined #ocaml
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 240 seconds]
<d_bot> <MemeMachine420> @roddy yep mb
favonia has joined #ocaml
<d_bot> <MemeMachine420> I'm looking at some code and I'm not too sure why I'm erring
<d_bot> <MemeMachine420> ```ocaml
<d_bot> <MemeMachine420> let find_sub prog name =
<d_bot> <MemeMachine420> Term.enum sub_t prog |>
<d_bot> <MemeMachine420> Seq.find_map ~f:(fun s ->
<d_bot> <MemeMachine420> Option.some_if (Sub.name s = name) (Term.tid s))
<d_bot> <MemeMachine420> ```
<d_bot> <MemeMachine420> ```
<d_bot> <MemeMachine420> but I'm not sure why I get this error
<d_bot> <MemeMachine420> File "path_check.ml", line 17, characters 22-32:
<d_bot> <MemeMachine420> 17 | Option.some_if (Sub.name s = name) (Term.tid s))
<d_bot> <MemeMachine420> ^^^^^^^^^^
<d_bot> <MemeMachine420> Error: This expression has type string but an expression was expected of type
<d_bot> <MemeMachine420> Core_kernel.Int.t = int
<d_bot> <MemeMachine420> ```
<d_bot> <MemeMachine420> tid is unique
<d_bot> <MemeMachine420> and it can be a string
<d_bot> <MemeMachine420> and name definitely returns a string
<d_bot> <Splingush> Core has comparison-operators for each type. It does not use the polymorphic one like in the Stdlib.
<d_bot> <Splingush> You can open the module locally, or prefix the expression so it uses the `=`-operator from that module:
<d_bot> <Splingush> ```ocaml
<d_bot> <Splingush> String.(Sub.name s = name)
<d_bot> <Splingush> ```
<d_bot> <MemeMachine420> ah I see
<d_bot> <MemeMachine420> but aren't they the same type already?
<d_bot> <Splingush> The `=` operator is not. That seems to be the one for comparing integers by default.
<d_bot> <MemeMachine420> yah I mean the 2 arguments, they're not the same types?
<d_bot> <MemeMachine420> oh hmm lemme check
<d_bot> <Splingush> I don't follow, sorry.
<d_bot> <Splingush> Your `Sub.name s` is a (supposedly) a string, your `name` is a string, but the `=`-operator is taking two ints. So that doesn't match.
<d_bot> <MemeMachine420> ```
<d_bot> <MemeMachine420> let main src dst proj =
<d_bot> <MemeMachine420> let prog = Project.program proj in
<d_bot> <MemeMachine420> match Option.both (find_sub prog src) (find_sub prog dst) with
<d_bot> <MemeMachine420> | None -> printf "satisfied (trivially)@\n"
<d_bot> <MemeMachine420> | Some (src,dst) -> match verify src dst prog with
<d_bot> <MemeMachine420> | None -> printf "satisfied (no counter-example was found)\n"
<d_bot> <MemeMachine420> | Some p ->
<d_bot> <MemeMachine420> printf "unsatisfied by ";
<d_bot> <MemeMachine420> match p with
<d_bot> <MemeMachine420> | Calls p -> printf "calls via %a@\n" pp_calls p
<d_bot> <MemeMachine420> | Sites p -> printf "callsites via %a@\n" pp_sites p
<d_bot> <MemeMachine420>
<d_bot> <MemeMachine420> module Cmdline = struct
<d_bot> <MemeMachine420> open Config
<d_bot> <MemeMachine420> let src = param string "src" ~doc:"Name of the source function"
<d_bot> <MemeMachine420> let dst = param string "dst" ~doc:"Name of the sink function"
<d_bot> <MemeMachine420>
<d_bot> <MemeMachine420> let () = when_ready (fun {get=(!!)} ->
<d_bot> <MemeMachine420> Project.register_pass' (main !!src !!dst))
<d_bot> <MemeMachine420> ```
<d_bot> <MemeMachine420> so it takes a cmdline which returns a string
<d_bot> <MemeMachine420> passes it to main
<d_bot> <MemeMachine420> which calls find_sub
<d_bot> <MemeMachine420> so name is for sure a string
<d_bot> <MemeMachine420> and according to the docs sub.name is a string too
<d_bot> <Splingush> (Sidenote: this channel is bridged to IRC, and large codeblocks are hard to read there. If you have more code, please put it into a bin.)
<d_bot> <MemeMachine420> ah I see
<d_bot> <MemeMachine420> mb
<d_bot> <MemeMachine420> so they're both strings according to the doc but it's actually an int
<d_bot> <Splingush> Yeah, that seems fine. It just uses the wrong `=`-operator. There are multiple of those, for each type, that only take values of that type.
<d_bot> <MemeMachine420> oh lol so it's expecitng 2 ints
<d_bot> <MemeMachine420> but it gets 2 strings?
<d_bot> <Splingush> So you use the `=`-operator that's for ints, but you want the one for Strings, which is in the `String`-module.
<d_bot> <MemeMachine420> aaaaa I see
<d_bot> <MemeMachine420> like it doesn't polymorphically auto choose
<d_bot> <MemeMachine420> yeah ok
<d_bot> <Splingush> ye!
<Absalom> Hi, when using toplevel, I manage to #load "unix.cma" and then #load "threads.cma" (no issue for both commands, I am aware threads being itsel in a dedicated directory), but when I try to use Thread module, I get an "Unbound module Thread" error.
<d_bot> <MemeMachine420> I guess `Core_kernel.Std` had that previously
<d_bot> <MemeMachine420> is there any way I could include the polymorphic operator from Core_kernel again?
<d_bot> <Splingush> I do not know that, sorry. Maybe someone else here does. Cheerio!
<d_bot> <MemeMachine420> ok thanks :aputhumb:
<d_bot> <NULL> `let (=) = Stdlib.(=)` should work, Stdlib shouldn't be shadowed by Base
<d_bot> <MemeMachine420> beautiful that worked
<d_bot> <thangngoc89> Oh since we are on this topic, Iā€™m surprised why containers shadow (==) as well
<d_bot> <MemeMachine420> so uhh is there a way to know who is shadowing my operators?
<d_bot> <thangngoc89> And deprecated it in the process
<d_bot> <NULL> I don't know the reasons either, but `(==)` is the cause of much confusion for beginners
<d_bot> <MemeMachine420> I've just read OCaml in 1 hour
<d_bot> <MemeMachine420> but from rooost and some other functional programming languages
<d_bot> <MemeMachine420> cuz rust basically stole match/let from OCaml :lmao3d:
<d_bot> <NULL> @Absalom quick experimentation on my Linux machine showed that `#require "threads.posix;;" works
<Absalom> Indeed, thanks
favonia has quit [Ping timeout: 256 seconds]
<d_bot> <Anurag> If you have an `open Core` or an `open Base` the polymorphic comparison operators will be shadowed.
favonia has joined #ocaml
<d_bot> <Anurag> If you want to bring back polymorphic comparison operators into the global scope for some reason you can open the `Poly` module from `base/core_kernel/core`. I'd recommend using the comparison operators for your specific datastructures/types in most cases.
<d_bot> <Anurag> @thangngoc89 readme for containers library has an explanation for why it shadows polymorphic comparison operators <https://github.com/c-cube/ocaml-containers#why-shadow-polymorphic-operators-by-default>
<companion_cube> (which was done after Base/Core did it)
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
bartholin has joined #ocaml
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
wraithgourd has quit [Remote host closed the connection]
<d_bot> <Cyclomatic Complexity> I might just be too tired on a saturday evening, but I don't get the following error: https://pastebin.com/951qmcdX
<companion_cube> this is not valid syntax
<companion_cube> oh wow, my bad (!!!!!)
<companion_cube> but you can't generalise this way
<companion_cube> what you can do is the equivalent of `(type a. ā€¦) ref`
<companion_cube> by using `type foo = { call: a. a plugin -> a Variable.t }`
<companion_cube> the quantification must be bounded inside a record
Stumpfenstiel has joined #ocaml
<d_bot> <Cyclomatic Complexity> I am not sure I understand why
<companion_cube> well OCaml types cannot contain quantifiers
favonia has quit [Ping timeout: 256 seconds]
<companion_cube> type _definitions_ are schemes, with universal variables (forall, etc.) but a type expression is quantifier-free
<companion_cube> `(type a. a foo -> a bar) ref` is a type expression that would contain an explicit quantification
<d_bot> <Cyclomatic Complexity> but why can't i lift the `type a .` outside the ref?
<d_bot> <Cyclomatic Complexity> which is what i've written
<companion_cube> that's not the same type
<companion_cube> (type a. a foo -> a bar) ref
<d_bot> <Cyclomatic Complexity> i want `type a . (a foo -> a bar) ref`
<companion_cube> ah but that's not possible because `ref` is mutable
<octachron> This type is not possible because mutable variable can never contain polymorphic values.
<companion_cube> you could have it with list instead of ref, for example
<companion_cube> imagine for `type a. a option ref`
<companion_cube> `let r: ā€¦ = ref None in r := Some 1; r := Some "foo"`
<companion_cube> pretty weird no?
favonia has joined #ocaml
<octachron> In other words, you would allow different readers/writers to have drastically opinion on the type of the contents of the mutable variable.
<companion_cube> ^
<d_bot> <Cyclomatic Complexity> i see
<d_bot> <Cyclomatic Complexity> thanks
<d_bot> <Cyclomatic Complexity> yeah, so the type that i wanted was indeed `(type a. a foo -> a bar) ref`
favonia has quit [Ping timeout: 240 seconds]
<companion_cube> give a try to the record type above
<companion_cube> it's relatively classic when doing CPS
<dmbaturin> companion_cube: I've just realized that TOML is not context free at all. [[false]] can be either a header of an array of tables named "false" or a (bool list list) array, you can't tell without knowing if you are in the value context or top level statement context.
favonia has joined #ocaml
<dmbaturin> As much as I wanted to avoid lexer hacks, I guess I can't. ;)
<companion_cube> but there's just 2 different productions then?
<companion_cube> oh.
<companion_cube> yeah you probably need to parse `false` as a string.
<dmbaturin> Also, `false = false`. That's valid TOML.
<dmbaturin> That's why you should never let people who didn't pass a formal language 101 class design a format.
<d_bot> <Cyclomatic Complexity> companion_cube: yeah, that's what I did, it works fine. just wondering why it can't be put in an expression directly
<companion_cube> because with a record you need `myrecord.call` which is a point where the typechecker knows to instantiate a type scheme
<companion_cube> which it does not in regular function instantiations
<companion_cube> I don't know the deep reason behind that. I think it helps (a lot) keeping type inference decidable.
<companion_cube> (or close to decidable(
<companion_cube> )
<d_bot> <octachron> Inference for higher-rank polymorphic functions is undecidable. Putting the inner polymorphic function in a box and unboxing explicitly avoids the issue without requiring type annotations on every function using the type.
<d_bot> <Cyclomatic Complexity> I see, like a type hint for internal foralls
lobo has quit [Quit: WeeChat 2.3]
lobo has joined #ocaml
bartholin has quit [Ping timeout: 256 seconds]
gravicappa has quit [Ping timeout: 272 seconds]
bartholin has joined #ocaml
<d_bot> <MemeMachine420> ```ocaml
<d_bot> <MemeMachine420> let verify src dst prog : proof option =
<d_bot> <MemeMachine420> let cg = Program.to_graph prog in
<d_bot> <MemeMachine420> match Graphlib.shortest_path (module CG) cg src dst with
<d_bot> <MemeMachine420> | Some path -> Some (Calls path)
<d_bot> <MemeMachine420> | None ->
<d_bot> <MemeMachine420> Term.enum sub_t pro
<d_bot> <MemeMachine420> ```
<d_bot> <MemeMachine420> trying to figure out in graphlib where this function calls comes from
olle has left #ocaml [#ocaml]
vb has quit [Ping timeout: 265 seconds]
favonia has quit [Ping timeout: 256 seconds]
vb has joined #ocaml
favonia has joined #ocaml
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
cedric has joined #ocaml
motherfsck has joined #ocaml
bartholin has quit [Ping timeout: 252 seconds]
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
bartholin has joined #ocaml
vizard has quit [Ping timeout: 265 seconds]
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 240 seconds]
favonia has joined #ocaml
bartholin has quit [Quit: Leaving]
Serpent7776 has quit [Quit: leaving]
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
cedric has quit [Quit: Konversation terminated!]
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml
waleee has quit [Ping timeout: 256 seconds]
favonia has quit [Ping timeout: 256 seconds]
favonia has joined #ocaml