companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.14.0 released: https://ocaml.org/releases/4.14.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
Haudegen has quit [Ping timeout: 260 seconds]
wingsorc has quit [Remote host closed the connection]
wingsorc has joined #ocaml
wingsorc has quit [Remote host closed the connection]
wingsorc has joined #ocaml
<d_bot> <Pluton> What does it mean when we have a function with an in. Like
<d_bot> <Pluton> ```
<d_bot> <Pluton> let f x =
<d_bot> <Pluton> let g y = y + 5
<d_bot> <Pluton> in g x
<d_bot> <Pluton> ```
<d_bot> <Pluton> I mean ik f x is basically g y here but what is that equal to
yilin has joined #ocaml
<d_bot> <geoff> Reading this may be helpful to you https://dev.realworldocaml.org/variables-and-functions.html
<d_bot> <Pluton> Well i did just rn
<d_bot> <Pluton> And it didnt have what i asked
<d_bot> <Pluton> Ik
<d_bot> <Pluton> ```
<d_bot> <Pluton> let x = e in p
<d_bot> <Pluton> ```
<d_bot> <Pluton> is same as
<d_bot> <Pluton> ```
<d_bot> <Pluton> (fun x -> p) e
<d_bot> <Pluton> ``
<d_bot> <Pluton> But how would it work with functions
<d_bot> <Pluton> I mean logically it should be
<d_bot> <Pluton> ```
<d_bot> <Pluton> (fun x -> g x) (let g y = y + 5)
<d_bot> <Pluton> ```
<d_bot> <Pluton> Right?
<d_bot> <Pluton> But that makes no sense
<d_bot> <leviroth> no, it would be `(fun x -> (fun g y -> y + 5) x)`
<d_bot> <Pluton> ```
<d_bot> <Pluton> let f = (fun x -> (fun g y -> y + 5) x)
<d_bot> <Pluton> ```
<d_bot> <Pluton> This?
<d_bot> <leviroth> right
<d_bot> <Pluton> So when you use in with variables and functions its a different thing?
<d_bot> <Pluton> Or is there any connection with these 2
<d_bot> <leviroth> If you look closely, your original definition of `f` does not have the form `let f x = e in p`
<d_bot> <leviroth> It just has the form `let f x = e`
<d_bot> <leviroth> The keyword `in` appears in the body, but that's because the body itself has the form `let g y = e in p`
<d_bot> <leviroth> So `f` is defined via `let` but not via `let ... in`, so the transformation that you described is not correct.
gwizon has joined #ocaml
<d_bot> <Pluton> Oooh
<d_bot> <Pluton> so `let g y = y +5 in g x`
<d_bot> <Pluton> That would equal to
<d_bot> <Pluton> ```
<d_bot> <Pluton> (f y -> y + 5) x
<d_bot> <Pluton> ```
rgrinberg has joined #ocaml
<d_bot> <Pluton> Imma go experiment with this rq
<d_bot> <Pluton> so ig it would define the func then plug it in g
<d_bot> <Pluton> So basically in 2 lines
<d_bot> <Pluton> ```
<d_bot> <Pluton> let g y = y + 5
<d_bot> <Pluton> g x
<d_bot> <Pluton> ```
<d_bot> <Pluton> And then remove g from the memory ig
<d_bot> <jumpnbrownweasel> what other languages are you familiar with? it might be easier to answer by drawing a parallel
<d_bot> <jumpnbrownweasel> yes, the scope of g is limited to its enclosing definition f
<d_bot> <Pluton> Im most familiar with python
<d_bot> <jumpnbrownweasel> so `let` is like `def`, and each time you use `let` you create another nested `def` (roughly, I'm sure the analogy is not perfect)
yilin has quit [Quit: WeeChat 3.5]
<d_bot> <Pluton> I mean yea i think i get it
<d_bot> <Pluton> Thanks everyone
bastienleonard has quit [Ping timeout: 244 seconds]
waleee has quit [Ping timeout: 276 seconds]
raskol has joined #ocaml
raskol has quit [Ping timeout: 260 seconds]
gwizon has quit [Quit: leaving]
raskol has joined #ocaml
Sankalp has quit [Ping timeout: 240 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
Sankalp has joined #ocaml
raskol has quit [Ping timeout: 272 seconds]
gopiandcode has quit [Quit: WeeChat 3.0]
jpds1 has quit [Remote host closed the connection]
jpds1 has joined #ocaml
motherfsck has quit [Ping timeout: 260 seconds]
raskol has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
ansiwen has quit [Quit: ZNC 1.7.1 - https://znc.in]
ansiwen has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
azimut has quit [Ping timeout: 268 seconds]
raskol has quit [Ping timeout: 272 seconds]
mbuf has joined #ocaml
<d_bot> <Bluddy> Yeah I have [@@deriving sexp] on a large amount of state in the form of records so I can save and load. Ideally I want to keep it as detail-free as possible so I can swap out sexp for some binary format later on.
kurfen_ has quit [Ping timeout: 276 seconds]
kurfen has joined #ocaml
<d_bot> <Bluddy> I followed your guys' advice and extended the `Set` functor, but it's not ideal. I wish there was a better way.
quernd9 has joined #ocaml
amk_ has joined #ocaml
kakadu has joined #ocaml
emp has quit [Quit: ZNC 1.8.2 - https://znc.in]
CalimeroTeknik has quit [Quit: バイバイ]
quernd has quit [Quit: Ping timeout (120 seconds)]
dwt_ has quit [Quit: ZNC 1.8.2 - https://znc.in]
amk has quit [Read error: Connection reset by peer]
emp_ has joined #ocaml
brettgilio has quit [Quit: Ping timeout (120 seconds)]
kakadu_ has quit [Remote host closed the connection]
wagle has quit [Remote host closed the connection]
quernd9 is now known as quernd
brettgilio5 has joined #ocaml
chrisz has quit [Ping timeout: 240 seconds]
wagle has joined #ocaml
cross has quit [Ping timeout: 268 seconds]
mjacob has quit [Ping timeout: 264 seconds]
fds has quit [Remote host closed the connection]
chrisz has joined #ocaml
cross has joined #ocaml
fds has joined #ocaml
mjacob has joined #ocaml
dwt_ has joined #ocaml
ctk has joined #ocaml
Serpent7776 has quit [Quit: leaving]
bartholin has joined #ocaml
nerdypepper is now known as aksnay
aksnay is now known as akshay
Sankalp has quit [Ping timeout: 244 seconds]
bcw has joined #ocaml
bartholin has quit [Ping timeout: 272 seconds]
amk_ has quit [Remote host closed the connection]
amk has joined #ocaml
bartholin has joined #ocaml
Sankalp has joined #ocaml
jpds1 has quit [Remote host closed the connection]
jpds1 has joined #ocaml
ctk has quit [Changing host]
ctk has joined #ocaml
Haudegen has joined #ocaml
olle has joined #ocaml
Tuplanolla has joined #ocaml
ctk is now known as CalimeroTeknik
salkin has joined #ocaml
wingsorc has quit [Quit: Leaving]
JSharp has quit []
bartholin has quit [Ping timeout: 240 seconds]
JSharp has joined #ocaml
salkin has quit [Quit: salkin]
bartholin has joined #ocaml
salkin has joined #ocaml
<d_bot> <wyn> hey, re https://ocaml.org/p/json-data-encoding/0.11 I was wondering if there was a way to auto-generate encoding functions from the Json_schema types - I can see that it's possible to go the other way ie Json_encoding.schema function
<d_bot> <wyn> basically I have a large json schema file and was about to start writing all the encodings by hand but thought I'd check first.
<d_bot> <wyn>
<d_bot> <wyn> Also, not sure if this question is better in the tezos discord...
<sim642> I don't think there is, I wondered the same and implemented a subset of the conversion for a project of mine
<sim642> Although I just needed it to validate the schema, not use the actual encoding
<sim642> So it erases all the actual values
<d_bot> <wyn> thanks i'll take a look, yep, ive looked around and can see that there are other tools out there that promise to do conversions and autogenerating of functions targetting various languages (e.g. apache thrift) but was wondering about a tidier ocaml only approach
<sim642> But if you need the actual values in the encoding, I don't think you can get away automatically because the encoding carries the types
<sim642> But json-data-encoding parses the schema only at runtime
<sim642> I think atd is quite ocaml-related, but I've never used it myself
<sim642> Although I think it requires a custom format, not a json schema for the generation
<d_bot> <wyn> so just to be clear of what that snippet does,
<d_bot> <wyn>
<d_bot> <wyn> given a schema and an encoding (that is supposed to implement the schema)
<d_bot> <wyn> it basically 'typechecks' that the given encoding will work by
<d_bot> <wyn> converting to an encoding that makes a unit for everything (ignoring the actual value)?
<sim642> Yeah, I just needed it to validate a json object against a schema
<d_bot> <wyn> yep, I did look at atdgen but you do seem to need an atd file
salkin has quit [Quit: salkin]
salkin has joined #ocaml
omegatron has joined #ocaml
bcw has quit [Ping timeout: 268 seconds]
waleee has joined #ocaml
dnh has joined #ocaml
bartholin has quit [Ping timeout: 260 seconds]
bcw has joined #ocaml
bartholin has joined #ocaml
bobo_ has joined #ocaml
spip has quit [Ping timeout: 240 seconds]
waleee has quit [Ping timeout: 255 seconds]
Haudegen has quit [Quit: Bin weg.]
yilin has joined #ocaml
<d_bot> <denis631> Hi everybody,
<d_bot> <denis631> I am working on a project where I generate LLVM code for the specific task definied at runtime in OCaml (using LLVM bindings).
<d_bot> <denis631> Currently I generate only little piece of LLVM code that I run with LLVM JIT (I assume in the same program space) and the other logic still runs in OCaml.
<d_bot> <denis631>
<d_bot> <denis631> I am curious if I would be able to generated LLVM code for the whole program that is able to call some OCaml code (as I do not want to translate all code into LLVM)
<d_bot> <denis631> I guess in order to do it I would need to get the address of the OCaml functions that I would want to call and define them as a global in LLVM code. And then call them from the generated LLVM code that I execute through LLVM JIT.
<d_bot> <denis631> How could I get the address of the OCaml functions. Is it this approach a valid one?
<d_bot> <denis631>
<d_bot> <denis631> An example would be:
<d_bot> <denis631> ```llvm
<d_bot> <denis631> ; ModuleID = 'test'
<d_bot> <denis631> declare void @function_from_OCaml() ; Should I assign the function address here?
<d_bot> <denis631>
<d_bot> <denis631> define i1 @main(i8* %0) {
<d_bot> <denis631> entry:
<d_bot> <denis631> ; Do some work
<d_bot> <denis631> call void @function_from_OCaml()
<d_bot> <denis631> ; Do some other work
<d_bot> <denis631> ret i1 0
<d_bot> <denis631> }
<d_bot> <denis631> ```
<d_bot> <octachron> Getting an address of an OCaml function is probably not sufficient since OCaml does not follow LLVM calling convention.
<d_bot> <Dano> As I understand it, OCaml has object-oriented features. How much does the language (standard libraries, etc.) rely on OO?
<d_bot> <NULL> A tiny fraction
<d_bot> <Dano> I'm a Java and C++ developer and I would like to learn a heavily functional style, so I suppose this a goodlanguage to learn to think functionally?
<d_bot> <NULL> Definitely
<d_bot> <Dano> Sounds good, I will try to learn it
<d_bot> <denis631> Any ideas of how to make it possible?
Haudegen has joined #ocaml
<d_bot> <Pluton> Is let () = _ in _ the only way to call a function and return something in a function
<d_bot> <NULL> (Wrap in \` to disable Markdown)
<d_bot> <NULL> `let () = e1 in e2` is equivalent to `e1; e2`
<d_bot> <Pluton> Ye i forgot the code blocks
<d_bot> <Pluton> Thanks
<d_bot> <NULL> (with the small caveat that the first one will raise an error if e1 doesn't have type unit while the second one will only throw a warning)
<d_bot> <NULL> (and the parsing priority is different)
<d_bot> <Pluton> Interesting
<d_bot> <Pluton> I tried using begin and end but it doesnt seem to work in situation where i have like
<d_bot> <Pluton> ```
<d_bot> <Pluton> let rec f x = begin g x ; f t; end
<d_bot> <Pluton> ```
<d_bot> <NULL> ; is a separator, not a finisher
jpds1 is now known as jpds
bartholin has quit [Ping timeout: 240 seconds]
gwizon has joined #ocaml
<d_bot> <Pluton> O yeah
<d_bot> <Pluton> Well i didn do it like that when i did it
<d_bot> <octachron> @denis631 You could patch LLVM to support OCaml calling convention, or maybe try to call OCaml function using the C-FFI API
bartholin has joined #ocaml
brettgilio5 is now known as brettgilio
<d_bot> <Nehemiah> Hello
motherfsck has joined #ocaml
motherfsck has quit [Ping timeout: 260 seconds]
troydm has quit [Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset]
motherfsck has joined #ocaml
xgqt has quit [Read error: Connection reset by peer]
xgqt has joined #ocaml
gwizon has quit [Quit: Lost terminal]
dextaa has quit [Read error: Connection reset by peer]
salkin has quit [Remote host closed the connection]
dextaa has joined #ocaml
dextaa has quit [Read error: Connection reset by peer]
yilin has quit [Ping timeout: 260 seconds]
dextaa has joined #ocaml
dextaa has quit [Read error: Connection reset by peer]
Sankalp has quit [Ping timeout: 268 seconds]
rgrinberg has joined #ocaml
dextaa has joined #ocaml
dextaa has quit [Read error: Connection reset by peer]
Sankalp has joined #ocaml
dextaa has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zebrag has joined #ocaml
<d_bot> <denis631> I don’t think patching LLVM would be an option.
<d_bot> <denis631> But I could imagine generating LLVM code that allows calling OCaml functions.
<d_bot> <denis631>
<d_bot> <denis631> I will have a further look on C-FFI API.
<d_bot> <denis631> Do you have any references for me? @octachron
Sankalp has quit [Ping timeout: 264 seconds]
Sankalp has joined #ocaml
rgrinberg has joined #ocaml
<companion_cube> anyone knows how finalizers and domains will work?
<companion_cube> I wonder if there could be a property that a finalizer created in domain A, is called in domain A
<companion_cube> (finalizers and threads play quite badly)
bartholin has quit [Ping timeout: 272 seconds]
troydm has joined #ocaml
bcw has quit [Read error: Connection reset by peer]
Haudegen has quit [Quit: Bin weg.]
bartholin has joined #ocaml
azimut has joined #ocaml
noonien64 has joined #ocaml
noonien6 has quit [Ping timeout: 244 seconds]
mro has joined #ocaml
mbuf has quit [Quit: Leaving]
salkin 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
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Read error: Connection reset by peer]
Haudegen has joined #ocaml
waleee has joined #ocaml
raskol has joined #ocaml
yilin has joined #ocaml
emp has joined #ocaml
emp_ has quit [Ping timeout: 260 seconds]
raskol has quit [Ping timeout: 272 seconds]
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
bartholin has quit [Ping timeout: 260 seconds]
bartholin has joined #ocaml
Serpent7776 has joined #ocaml
<d_bot> <mbacarella> anyone recall a project that wraps git command-line tool calls? (ocaml-git is interesting but not mature enough IMO)
bastienleonard has joined #ocaml
yilin has quit [Ping timeout: 272 seconds]
<jpds> Who would be the best person to talk about enabling IPv6 on https://opam.ocaml.org/ ?
yilin has joined #ocaml
salkin has quit [Quit: salkin]
yilin has quit [Ping timeout: 240 seconds]
Everything has joined #ocaml
bartholin has quit [Ping timeout: 244 seconds]
deadmarshal has quit [Ping timeout: 260 seconds]
yilin has joined #ocaml
yilin has quit [Ping timeout: 240 seconds]
deadmarshal has joined #ocaml
Everything has quit [Quit: leaving]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
raskol has joined #ocaml
dextaa8 has joined #ocaml
troydm has quit [*.net *.split]
dextaa has quit [*.net *.split]
bobo_ has quit [*.net *.split]
Tuplanolla has quit [*.net *.split]
wagle has quit [*.net *.split]
brettgilio has quit [*.net *.split]
kakadu has quit [*.net *.split]
ansiwen has quit [*.net *.split]
sagax has quit [*.net *.split]
bacam has quit [*.net *.split]
wagle has joined #ocaml
ansiwen has joined #ocaml
bobo_ has joined #ocaml
troydm has joined #ocaml
brettgilio has joined #ocaml
kakadu has joined #ocaml
bacam has joined #ocaml
Tuplanolla has joined #ocaml
sagax has joined #ocaml
qwr has quit [Ping timeout: 268 seconds]
wingsorc has joined #ocaml
olle has quit [Ping timeout: 272 seconds]
Serpent7776 has quit [Quit: leaving]
rgrinberg has joined #ocaml
yilin has joined #ocaml
sagax has quit [Read error: Connection reset by peer]
jpds1 has joined #ocaml
jpds has quit [Ping timeout: 268 seconds]
raskol has quit [Ping timeout: 276 seconds]
yilin has quit [Ping timeout: 240 seconds]
Haudegen has quit [Ping timeout: 240 seconds]
wingsorc has quit [Quit: Leaving]
waleee has quit [Ping timeout: 272 seconds]
wingsorc has joined #ocaml
wingsorc has quit [Quit: Leaving]
wingsorc has joined #ocaml
qwr has joined #ocaml
jpds1 has quit [Read error: Connection reset by peer]
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
jpds1 has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
spip has joined #ocaml
bobo_ has quit [Ping timeout: 260 seconds]
dnh has quit [Quit: Textual IRC Client: www.textualapp.com]