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: 252 seconds]
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
waleee has quit [Ping timeout: 256 seconds]
waleee has joined #ocaml
jpds has quit [Ping timeout: 268 seconds]
jpds has joined #ocaml
grobe0ba_ has joined #ocaml
grobe0ba has quit [Ping timeout: 244 seconds]
grobe0ba_ has quit [Ping timeout: 248 seconds]
grobe0ba has joined #ocaml
grobe0ba has quit [Ping timeout: 256 seconds]
grobe0ba has joined #ocaml
raskol has joined #ocaml
grobe0ba has quit [Ping timeout: 256 seconds]
grobe0ba has joined #ocaml
chrisz has quit [Ping timeout: 268 seconds]
chrisz has joined #ocaml
waleee has quit [Ping timeout: 252 seconds]
raskol has quit [Ping timeout: 252 seconds]
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
<sim642> (ppx_deriving_yojson isn't technically fully ppxlib, but that doesn't matter)
<nvaxplus> sim642: yeah I used the ocamlc method and it looked totally normal :(
<nvaxplus> hold on, let me pastebin my generated code. One sec
<nvaxplus> sim642: https://pastebin.com/Hzm8WLuD here's the pertinent part out of the output
<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
<Armael> ah then, you're adding static typechecking?
<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]; }
<olle> Have to think about it
faultline has quit [Ping timeout: 256 seconds]
olle has quit [Ping timeout: 252 seconds]
waleee has joined #ocaml
olle has joined #ocaml
adanwan_ has joined #ocaml
adanwan has quit [Quit: _]
jlrnick has joined #ocaml
olle_ has joined #ocaml
olle has quit [Quit: AndroIRC - Android IRC Client ( http://www.androirc.com )]
sonologico has joined #ocaml
waleee has quit [Ping timeout: 256 seconds]
John_Ivan has joined #ocaml
rgrinberg has joined #ocaml
orbifx has joined #ocaml
adanwan_ has quit [Remote host closed the connection]
adanwan has joined #ocaml
sonologico has quit [Ping timeout: 256 seconds]
mbuf has quit [Ping timeout: 256 seconds]
mbuf has joined #ocaml
jlrnick has quit [Ping timeout: 248 seconds]
Serpent7776 has quit [Ping timeout: 252 seconds]
xgqt has quit [Ping timeout: 248 seconds]
xgqt has joined #ocaml
sonologico has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sonologico has quit [Ping timeout: 268 seconds]
sonologico has joined #ocaml
sonologico has quit [Client Quit]
rgrinberg has joined #ocaml
mbuf has quit [Remote host closed the connection]
mbuf has joined #ocaml
zebrag has joined #ocaml
mbuf has quit [Quit: Leaving]
raskol has joined #ocaml
hannes has quit [Ping timeout: 268 seconds]
raskol has quit [Ping timeout: 248 seconds]
jpds has quit [Remote host closed the connection]
jpds has joined #ocaml
raskol has joined #ocaml
raskol has quit [Ping timeout: 256 seconds]
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
azimut has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
waleee has joined #ocaml
williewillus has joined #ocaml
williewillus has quit [Changing host]
williewillus has joined #ocaml
williewillus has quit [Client Quit]
Serpent7776 has joined #ocaml
<olle_> raise (Parser_error (sprintf "tok = %s, Could not parse '%s': error at %c" tok source (String.get source (Lexing.lexeme_start linebuf))))
<olle_> Can you see the error? There's an index out of bounds here somewhere :(
<olle_> Fatal error: exception Invalid_argument("index out of bounds")
<companion_cube> must be the String.get
<olle_> Yeah
<companion_cube> maybe line numbers are 1-indexed?
<olle_> Instead of start at 0? Can try
<olle_> Well, adding -1 "fixes" it
<olle_> Weird, tok (token) is empty string
<olle_> Oh
<olle_> Right, the string I'm parsing does contain a space char
<olle_> Hm
<olle_> Fatal error: exception Dune__exe__Debug.Parser_error("tok = , Could not parse '<?php // @pholyglot\n function main(): int {\n $str = \"Hello \" . \" world\" . \"!\";\n return 0;\n ': error at ")
<olle_> Meh
<companion_cube> maybe just use pp_loc?
<olle_> companion_cube: link?
<olle_> Hm
<olle_> Lemme check some old projects of mine first, I had string parsing working there
<olle_> But good link, I was about to ask about better error messages like that :)
perrierjouet is now known as GerardMamenti
<olle_> Oh god
<olle_> There's a syntax error in the source ><
<olle_> Missing end }
<darchitect> how are you guys ?
<darchitect> I'm drunk, but I love OCaml :)
<olle_> Heh
<darchitect> no drinking allowed in the chat ? :(
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
GerardMamenti has quit [Quit: WeeChat 3.6]
perrierjouet has joined #ocaml
<olle_> Nope
perrierjouet has quit [Client Quit]
perrierjouet has joined #ocaml
Tuplanolla has joined #ocaml
jlrnick has joined #ocaml
ardon has left #ocaml [ERC 5.4 (IRC client for GNU Emacs 28.1)]
Techcable has quit [Remote host closed the connection]
Techcable has joined #ocaml
adanwan_ has joined #ocaml
adanwan has quit [Ping timeout: 268 seconds]
williewillus has joined #ocaml
jlrnick has quit [Ping timeout: 256 seconds]
williewillus has quit [Quit: Leaving]
<olle_> I can't compare variants in if-cond?
<olle_> if Blue <> Green then Moo
<olle_> Expected int :(
williewillus has joined #ocaml
<olle_> OK, match it is
williewillus has quit [Quit: leaving]
williewillus has joined #ocaml
<olle_> Error: Uninterpreted extension 'expect_test'.
<olle_> Meh
<olle_> Tips?
<olle_> Missing ppx_?
<olle_> Probably that one :)
<olle_> Oh, that's rich... You can't test for exceptions wtth inline tests?
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
waleee has quit [Ping timeout: 248 seconds]
waleee has joined #ocaml
olle_ has quit [Ping timeout: 252 seconds]
wonko has joined #ocaml
raskol has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
bobo_ has joined #ocaml
spip has quit [Ping timeout: 252 seconds]
raskol has quit [Ping timeout: 252 seconds]
bartholin has quit [Quit: Leaving]
Serpent7776 has quit [Ping timeout: 255 seconds]
oriba has joined #ocaml
orbifx has quit [Ping timeout: 248 seconds]
wonko has quit [Ping timeout: 256 seconds]