companion_cube changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.11 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.11/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
vicfred has quit [Ping timeout: 260 seconds]
dh` has quit [Remote host closed the connection]
zebrag has quit [Quit: Konversation terminated!]
dh` has joined #ocaml
Shreya has joined #ocaml
Shreya has quit [Client Quit]
mfp has quit [Ping timeout: 248 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
mxns has quit [Ping timeout: 240 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 258 seconds]
mxns has joined #ocaml
snowpanda has joined #ocaml
snowpanda has quit [Client Quit]
narimiran has joined #ocaml
shawnw has quit [Ping timeout: 240 seconds]
olle has joined #ocaml
shawnw has joined #ocaml
l1x has joined #ocaml
hackinghorn has joined #ocaml
<hackinghorn> hi
<hackinghorn> how do I write a function that can be run in the same file and somewhere else
<hackinghorn> if I write let f x y = ... in .. , I can use it in the same file, but I cant use in another file
<vsiles> just write let f x y = x + y (or optionally let f x y = x + y;;)
<vsiles> without the `in` keyword
<hackinghorn> ah thankss
<hackinghorn> what does ;; mean?
<hackinghorn> I saw some codes and functions without ;; work :/
<d_bot> <bnguyenvanyen> ;; is mostly for the toplevel, it tells it to evaluate the input. You don't need it otherwise.
<d_bot> <bnguyenvanyen> The previous link will show you that to call the function from another file, you will need to put its module name in front. If it's in a.ml, it will be A.f.
<d_bot> <bnguyenvanyen> But then you need to look at how to compile all this correctly (you can use dune), etc etc, so the other informations on the page will be useful.
<vsiles> what he said :) thanks !
Haudegen has joined #ocaml
<hackinghorn> ah thanks
olle_ has joined #ocaml
<olle_> How do I know if my abstract syntax-tree sucks?
<olle_> Or non-sucks
tane_ has joined #ocaml
smerdyakov has left #ocaml ["Leaving"]
<vsiles> it sucks by default, doesn'i ?
<vsiles> what do you mean by suck ?
<olle_> vsiles: dunno. not sure which quality attributes are relevant. :d
Abhir-24 has joined #ocaml
bartholin has joined #ocaml
Abhir-24 has quit [Quit: Connection closed]
zebrag has joined #ocaml
<hackinghorn> hi, so if I want to use a function in the same file it is written, I either have to use let sum x y = x + y in ... or let sum x y = x+ y;; ?
|jbrown| has quit [Ping timeout: 246 seconds]
<hackinghorn> I saw something like, let sum x y = f x x y let ... = ..., there is no separators between 2 lets, does it always work?
<vsiles> yes separators are only necessary from the interactive toplevel
<vsiles> if you compile your file, you don't need them at all
|jbrown| has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
mfp has joined #ocaml
hackinghorn has quit [Ping timeout: 248 seconds]
kakadu has joined #ocaml
bronsen has quit [Quit: WeeChat 2.9]
bronsen has joined #ocaml
<qwr> there is one exception - if you want top-level expression, then it needs ;; between it and preceding let (let something ... ;; expression - but you can alternatively use let () = expression for that purpose)
murgy has joined #ocaml
Haudegen has joined #ocaml
radiopotin[m] has joined #ocaml
curtosis has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
murgy has quit [Quit: Connection closed]
curtosis is now known as curtosis[away]
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
waleee-cl has joined #ocaml
shawnw has quit [Ping timeout: 246 seconds]
kakadu has quit [Ping timeout: 240 seconds]
murgy has joined #ocaml
curtosis has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
neiluj has joined #ocaml
neiluj has quit [Changing host]
neiluj has joined #ocaml
curtosis has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
kakadu has joined #ocaml
<d_bot> <undu> I'm trying to test a module with alcotest, but the main type is a phantom type. (`type 'a t`, which is made concrete with `type 'a t = string`). I can't really create an `Alcotest.testable` out of it because the type checker complains about the type not being generalizable. Are there any strategies to resolve this short of removing the phantom type? I'd like to test the current code before removing the phantom type, which is not bei
<d_bot> <Firgeis> You could add some pretty printing to the module and test that?
<d_bot> <octachron> You could fix the polymorphic type variables and restrict the tests to `rigid t` rather than `'a t`
<d_bot> <undu> defining the type `rigid` and using it for the testable module worked wonders, thanks!
<d_bot> <undu> `let testable : (module Alcotest.TESTABLE with type t = rigid Module.t) = Alcotest.testable ...`
murgy has quit [Quit: Connection closed]
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
narimiran has quit [Ping timeout: 260 seconds]
kakadu has quit [Read error: Connection reset by peer]
kakadu has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
kakadu has quit [Read error: Connection reset by peer]
Tuplanolla has joined #ocaml
kakadu has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
zebrag has quit [Read error: Connection reset by peer]
zebrag has joined #ocaml
bartholin has quit [Quit: Leaving]
mbuf has joined #ocaml
kakadu has quit [Read error: Connection reset by peer]
bjorkintosh has quit [Ping timeout: 250 seconds]
Haudegen has joined #ocaml
neiluj has quit [Quit: leaving]
<olle_> "non-escaping variables" gives nothing on google. there's no such thing?
<olle_> statically enforced no-escaping from scope
<olle_> or statically enforced locality
mbuf has quit [Quit: Leaving]
<olle_> is there a word?
narimiran has joined #ocaml
<steenuil> sounds like you want linear types?
<companion_cube> olle_: good luck with closures :p
<olle_> steenuil: or maybe some kind of affinity...?
<steenuil> possibly
<olle_> linearity is too restrictive often
<olle_> companion_cube: no closures, no closures
<olle_> and no concurrency
<olle_> I know my boundaries xD
<olle_> well
<olle_> you can just copy stuff forever, like in <lang that shouldn't be named>
<companion_cube> no closures? sadface
<olle_> :)
<olle_> actually, when compiling to C, you can do anonymous functions easily if they do NOT capture scope
<olle_> just render the (x) => x * 2 function somwehere, ___tmp___x123
<olle_> with a cryptic name
<steenuil> or you could have a language where you explicitly capture variables, I think there's a syntax for that in C++
<companion_cube> yikes again
<olle_> steenuil: php does this, which might be GOOD because there's no block scope!
<olle_> long discussion about that on their internals
<olle_> steenuil: yes, explicit capture would be to just add another argument to the generated function. pretty easy. surprisingly easy.
<olle_> an automatic extra argument
<steenuil> yeah that's the idea
<steenuil> you can also implement proper closures like that in C, it's just a bit more work
<olle_> yeah? didn't think that far
<olle_> I'm more interested in the memory model. If a dev knows the scope/lifetime of a variable at time of writing, he/she should be able to use that fact as an optimization.
<olle_> I'm thinking non-escaping regions, too. But that's MLKit etc etc
<olle_> Learned about three languages I didn't know about before last days. Odin, Cone, and Verona: https://github.com/microsoft/verona
<olle_> Language inflation?
alexey has joined #ocaml
White_Flame has quit [Ping timeout: 246 seconds]
<companion_cube> you're still describing rust-but-worse :p
vicfred has joined #ocaml
<olle_> haha
<olle_> companion_cube: really trying to hit the 80/20 mark
<olle_> 20% of your program MUST be fast, but not more
<olle_> but yeah, experimental. we'll see.
vicfred_ has joined #ocaml
kakadu has joined #ocaml
kakadu has quit [Remote host closed the connection]
White_Flame has joined #ocaml
vicfred has quit [Ping timeout: 240 seconds]
<olle_> Question is how slow that other 80% can be to still be a vaiable alternative.
<olle_> 80% - really slow ref counting; 20% really fast stack alloc and regions?
<olle_> which domain would that be, even?
<olle_> web?
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
<companion_cube> I think web is an example where you could actually have one arena per query
<companion_cube> and it'd be super fast
<olle_> companion_cube: you mean per request? found a blog post with this use-case.
<olle_> and, iirc, apache is implemented with pools
<companion_cube> sure, sure
<companion_cube> per request
<olle_> biggest mistake they made, it said. dunno why?
<olle_> wait, searching
<companion_cube> no, they used _process_ pools
<companion_cube> totally different stuff
<olle_> oh
<olle_> anyway, yes. but every algorithm which returns can have a region. A*, for example.
<olle_> as long as you control escaping.
vicfred_ has quit [Quit: Leaving]
<olle_> (Also why I"m so bitter with <that language>, since earlier versions did have a better 80/20 adaption, IMO)
<companion_cube> what, rust? :p
<companion_cube> it was just a different language is all
olle_ has quit [Ping timeout: 265 seconds]
zebrag has quit [Read error: Connection reset by peer]
zebrag has joined #ocaml
<d_bot> <colin> to clarify, you mean an extra argument for the environment, right?
desumn has joined #ocaml
vicfred has joined #ocaml
desumn has quit [Quit: Leaving]
<osa1> does OCaml have something like type-level "fix" for constructing recursive polymorphic variants, or tuples etc.?
<osa1> I guess recursive tuples don't make sense, but for polymorphic variants it would be useful
mxns has quit [Ping timeout: 258 seconds]
<d_bot> <Drup> You can use `as` for this: ``[> `Foo of 'a ] as 'a``
mxns has joined #ocaml
chripell_ has joined #ocaml
chripell has quit [Ping timeout: 246 seconds]
narimiran has quit [Ping timeout: 268 seconds]
neiluj has joined #ocaml
neiluj has quit [Changing host]
neiluj has joined #ocaml
Amaan has quit [Ping timeout: 240 seconds]
Amaan has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
Serpent7776 has quit [Quit: leaving]
tane_ has quit [Quit: Leaving]
olle_ has joined #ocaml
olle__ has joined #ocaml
<olle__> test
<olle_> h
<olle_> m
<olle_> weird
olle__ has left #ocaml [#ocaml]
curtosis has joined #ocaml
neiluj has quit [Ping timeout: 260 seconds]
<companion_cube> olle_: well, it explains why rust got rid of them
<dieggsy> Is this dune file 'wrong' ? https://paste.dieggsy.com/2021-04-08T18:04:41
<dieggsy> i'm looking to have separate executables
<dieggsy> but i'm wondering if specifying 'modules' like that is telling it that every executable depends on every other file as a module
<dieggsy> as opposed to a one to one correspondance
<companion_cube> it's not a one to one correspondance
<dieggsy> companion_cube: shoot. is there a way to define a library and multiple executables like this without having to repeat (executable ..) for every executable
<companion_cube> I'm not sure, tbh
<companion_cube> probably not in the same directory, but don't take my word for it
curtosis has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
<dieggsy> meh, then i'll deal with the minor annoyance of it thinking it has to compile with all these modules
<dieggsy> it results in the same binary anyway something something dead code elimination
<dieggsy> ...i think anyway
<dieggsy> maybe i'll split it later on
<olle_> companion_cube: It mentions GC runtime, but I would have to read more for the details. Pretty complex.
<olle_> Like the interaction between the different features.
<dieggsy> ah, i can put the library in a subdirectory. neat
cantstanya has quit [Remote host closed the connection]
cantstanya has joined #ocaml
landonf has quit [Excess Flood]
landonf has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
<companion_cube> olle_: they removed the GC because Arc<> goes a long way
<companion_cube> and no runtime
<olle_> hm
<olle_> ah ok, so it's only the cycles that are missing from Arc, then?
<olle_> hm hm hm
<companion_cube> yes, mostly (and even then you can use weak refs)
<companion_cube> cycles wouldn't be handled well by the borrow checker anyway
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
<olle_> yeah
curtosis has joined #ocaml
<olle_> Question: Affine types would make it possible to create memory safe tight memory control, right? Use Obj.magic but wrap it in a module.
Haudegen has quit [Ping timeout: 248 seconds]
* olle_ zzz
curtosis has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
olle_ has quit [Ping timeout: 260 seconds]
dckc has quit [Ping timeout: 268 seconds]