azimut_ has quit [Remote host closed the connection]
azimut has joined #ocaml
John_Ivan has quit [Ping timeout: 268 seconds]
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
nvaxplus has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
<nvaxplus>
anyone here have any experience with generating modules with ppxlib? I simply cannot get mine to work. When I load it up in utop I get tab completion for the generated name but there's nothing in the module itself
zebrag has quit [Quit: Konversation terminated!]
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
williewillus has quit [Quit: Leaving]
mbuf has joined #ocaml
azimut_ has joined #ocaml
azimut has quit [Remote host closed the connection]
random-jellyfish has joined #ocaml
genpaku has quit [Remote host closed the connection]
genpaku has joined #ocaml
hrberg has joined #ocaml
hrberg has quit [Client Quit]
hrberg has joined #ocaml
<sim642>
Generating modules from what? A deriver?
<nvaxplus>
sim642: yeah exactly
<sim642>
Have you looked at the generated code? Not just tried to check whether it works via tab completion
<sim642>
There shouldn't be anything special about generating modules though
<nvaxplus>
it's a very simple module, I just collect the name of all the constructors and put that string in a module
<nvaxplus>
but that output doesn't work. I can't access foo_test.a
<sim642>
The module name needs to be capitalized
<nvaxplus>
oh man
<nvaxplus>
*wow*
<sim642>
I guess the parsetree won't complain
<sim642>
And the compiler doesn't sanity check that either?
<nvaxplus>
yep! that fixed it
<nvaxplus>
sorry, I'm used to SML, only recently switched over to ocaml so I have to remind myself of these rules a lot
<nvaxplus>
thank you so much, been banging my head against the wall for forever on this dumb thing! :)
<octachron>
No identifiers are not checked after parsing, partially on purpose: an alternative syntax might decide to have different convention for identifiers.
<octachron>
And since this does not affect typechecking, there is no reason to forbid such non-standard identifiers after parsing.
random-jellyfish has quit [Quit: Client closed]
nvaxplus has quit [Quit: Leaving]
<sim642>
Makes sense
szkl has quit [Quit: Connection closed for inactivity]
jlrnick has joined #ocaml
azimut_ has quit [Ping timeout: 268 seconds]
jlrnick has quit [Ping timeout: 256 seconds]
bartholin has joined #ocaml
Serpent7776 has joined #ocaml
sm2n has quit [Ping timeout: 244 seconds]
sm2n has joined #ocaml
spip has joined #ocaml
bobo_ has quit [Ping timeout: 256 seconds]
oriba has joined #ocaml
oriba has quit [Client Quit]
omegatron has joined #ocaml
random-jellyfish has joined #ocaml
random-jellyfish has quit [Client Quit]
AndroUser2 has joined #ocaml
<AndroUser2>
Simple question, but what is the name of 'a type in ocaml?
<AndroUser2>
"generic"?
<AndroUser2>
"whatever"?
<AndroUser2>
test
AndroUser2 is now known as olle
<olle>
test
random-jellyfish has joined #ocaml
<olle>
Pah, maybe just "any" is good enough, as in typescript
oriba has joined #ocaml
oriba has quit [Client Quit]
oriba has joined #ocaml
random-jellyfish has quit [Client Quit]
oriba has quit [Client Quit]
chrisz has quit [Ping timeout: 248 seconds]
<Armael>
olle: a type variable
faultline has joined #ocaml
chrisz has joined #ocaml
<olle>
Armael Hmmm
<olle>
Right, it's not decided until its use
Haudegen has joined #ocaml
<Armael>
yeah
<olle>
Armael Doesn't that require that the language carries type information during runtime?
olle has quit [Ping timeout: 252 seconds]
olle has joined #ocaml
<Armael>
no, types are erased after typechecking at compile time in ocaml
<olle>
k
<olle>
Armael Buuut does it require boxed values?
<Armael>
with the compilation scheme that ocaml uses, yes: it relies on the fact that values have a uniform representation at runtime (a value is an integer or a pointer to a block, with one bit to distinguish between the two)
<Armael>
so a polymorphic function can just take "a value" at runtime and handle it opaquely
<olle>
I guess a more simple way to do it without boxed values, could be to carry type information, return "any" and then require a type refinement using an instanceof operator in an if-statement.
<Armael>
your any is going to be boxed as well
<Armael>
or rather, a box around your value
<Armael>
so you wouldnt gain anything
<olle>
Armael I'm compiling to C
<Armael>
what is the source language?
<olle>
Armael Ehm, a subset of php, haha
<Armael>
what I said applies to ML and ML typing
<olle>
It's mostly about the silly "array" type in php, which needs to be inferred
<olle>
Like Hashtable<string, 'a> -> 'a
<Armael>
if your source language is PHP then you may in fact need runtime thpe informqtion
<Armael>
idk
<olle>
Ye, we'll see.
<Armael>
but does php even have static types?
<olle>
Armael More and more
<olle>
Or no
<olle>
It does not
<olle>
But it has type hinting
<olle>
Limited type hinting
<Armael>
idk what that is
<olle>
function foo(int $i) { ... }
<olle>
Runtime error if $i is not an int
<Armael>
ah well ok, that's more like dynamic types still
<olle>
Sure
<Armael>
so no static typechecking
<olle>
No
<Armael>
so you do need type info at runtime then
<Armael>
and everything is going to be boxed
<olle>
But int $i can be assumed to be an int :)
<olle>
No boxes so far
<olle>
But I won't add a GC anyway
<Armael>
well how do you know the type of a value then
<olle>
Armaeln By having type hints mandatory
<olle>
Except "array", that needs to be inferred further, as noted
<olle>
Armael I'm transpiling php to c, so, in a way, sure
<olle>
And i'm not using internal php value representation, like the so called zval type
<olle>
It's just a toy project :)
<Armael>
I'm just saying there are several ways you could go abt it
<olle>
I'm letting myself get away with a lot
<Armael>
depending on what your source subset is
<olle>
Armael Yeah. The use-cases decides the needed subset, I guess...
<olle>
It's common to add extra type info in comments, too, like /** @var array<int, string> */
<olle>
So maybe I'll abuse that, when needed, so people can optimize could a bit more
<olle>
E.g. differ between int and float
<olle>
General programming question:What's the different use-case between dynamic vector (array) and linked list?
<Armael>
another way of handling polymorphism, instead of a uniform representation, is to generate several specialized copies of the polymorphic code, one for each concrete instance of the polymorphic type variables
<olle>
True
<Armael>
like what rust does
<olle>
Oh ok, didn't know that
<olle>
But yeah, I guess they don't box anything :) Unless when explicit about it
<Armael>
indeed
<olle>
glib has some form of manual ref count
<olle>
But no memory pools :(
<olle>
Maybe I could do that as a compiler wtich, "--enable-ref-count", haha
<olle>
switch*
<olle>
Maybe void* would be enough in some cases, like function comb($a, $b) { return [$a, $b]; }