Stumpfenstiel has quit [Ping timeout: 268 seconds]
cedric has quit [Quit: Konversation terminated!]
favonia has quit [Ping timeout: 252 seconds]
favonia has joined #ocaml
Haudegen has quit [Ping timeout: 268 seconds]
shawnw has quit [Ping timeout: 255 seconds]
favonia has quit [Ping timeout: 252 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 255 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 252 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 255 seconds]
favonia has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
dvu has joined #ocaml
favonia has quit [Ping timeout: 252 seconds]
favonia has joined #ocaml
favonia has quit [Ping timeout: 252 seconds]
favonia has joined #ocaml
gravicappa has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
favonia has quit [Ping timeout: 255 seconds]
favonia has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
favonia has quit [Ping timeout: 255 seconds]
favonia has joined #ocaml
leah2 has quit [*.net *.split]
bacam has quit [*.net *.split]
st has quit [*.net *.split]
p4bl0 has quit [*.net *.split]
tizoc has quit [*.net *.split]
oisota has quit [*.net *.split]
sleepydog has quit [*.net *.split]
noddy has quit [*.net *.split]
micro has quit [*.net *.split]
aquijoule__ has quit [*.net *.split]
rks` has quit [*.net *.split]
greenbagels has quit [*.net *.split]
engil has quit [*.net *.split]
_tjr_ has quit [*.net *.split]
ralu has quit [*.net *.split]
Cypi has quit [*.net *.split]
energizer has quit [*.net *.split]
damien2 has quit [*.net *.split]
nfc has quit [*.net *.split]
gahr has quit [*.net *.split]
Enjolras_ has quit [*.net *.split]
Armael has quit [*.net *.split]
rwmjones|hols has quit [*.net *.split]
rak has quit [*.net *.split]
aquijoule__ has joined #ocaml
ralu has joined #ocaml
leah2 has joined #ocaml
_tjr_ has joined #ocaml
tizoc has joined #ocaml
micro has joined #ocaml
st has joined #ocaml
p4bl0 has joined #ocaml
engil has joined #ocaml
rks` has joined #ocaml
nfc has joined #ocaml
energizer has joined #ocaml
bacam has joined #ocaml
Enjolras_ has joined #ocaml
Cypi has joined #ocaml
damien2 has joined #ocaml
oisota has joined #ocaml
greenbagels has joined #ocaml
rwmjones|hols has joined #ocaml
Armael has joined #ocaml
gahr has joined #ocaml
sleepydog has joined #ocaml
rak has joined #ocaml
noddy has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
jtck_ has quit [Remote host closed the connection]
jtck has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Haudegen has joined #ocaml
bartholin has joined #ocaml
Guest8905 has quit [Remote host closed the connection]
Guest8905 has joined #ocaml
<d_bot>
<Cyclomatic Complexity> stupid q: there are extensible variants in OCaml. But is there a good way to define extensible functions on them? So that when you add a case to the variant, you can also add one match case to the function?
cedric has joined #ocaml
favonia has quit [Ping timeout: 265 seconds]
Serpent7776 has joined #ocaml
<d_bot>
<antron> do you mean having the compiler force you to add cases?
<d_bot>
<octachron> @Cyclomatic Complexity : you can have set of functions that signals which extension constructors they can handle and a handler that matches each input with the right partial function.
<d_bot>
<Cyclomatic Complexity> No, I meant, in practice, how do you extend functions
<d_bot>
<Cyclomatic Complexity> I am not sure what you havein mind, do you have an example?
<d_bot>
<octachron> There are many variants of this structure but they mostly come down to each function `extensible -> ... ` having limited responsability and delegating to someone with a better point of view the handling of unknown variants.
favonia has joined #ocaml
<d_bot>
<Alistair> Whats the performance of something like that like?
<d_bot>
<octachron> That's a linear search over all registered functions. If performance matters, you can probably organize the search to be more efficient.
<d_bot>
<Cyclomatic Complexity> Not great I expect, you have to iterate through each of the functions in the list, and I don't think there is any partial evaluation, so it can't be optimized by latter passes
<d_bot>
<octachron> Note that with extension constructor, the compiler itself has not much information. And typically even pattern matching devolves into nested equality tests.
<d_bot>
<Cyclomatic Complexity> Oh, there are no whole-program optimizations for extensible variants?
<d_bot>
<Cyclomatic Complexity> hmmm
<d_bot>
<Cyclomatic Complexity> Is it because you can add cases dynamically with FCMs?
<d_bot>
<octachron> Worse than that you can hide the identity of an extension constructor with a signature (`module M: sig type ext += B end = struct type ext += B = A end`)
foocraft has joined #ocaml
foocraft has quit [Client Quit]
bartholin has quit [Ping timeout: 272 seconds]
bartholin has joined #ocaml
zebrag has joined #ocaml
Stumpfenstiel has joined #ocaml
jtck has quit [Quit: Leaving]
jtck has joined #ocaml
jtck has quit [Remote host closed the connection]
jtck has joined #ocaml
gareppa has joined #ocaml
jtck has quit [Remote host closed the connection]
jtck has joined #ocaml
gareppa has quit [Remote host closed the connection]
mro has joined #ocaml
bartholin has quit [Read error: Connection reset by peer]
mro has quit [Ping timeout: 272 seconds]
Absalom has joined #ocaml
bartholin has joined #ocaml
favonia has quit [Ping timeout: 252 seconds]
waleee has quit [Ping timeout: 252 seconds]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
waleee has joined #ocaml
waleee has quit [Ping timeout: 252 seconds]
bartholin has quit [Ping timeout: 252 seconds]
bartholin has joined #ocaml
thelounge98 has joined #ocaml
bartholin has quit [Ping timeout: 258 seconds]
bartholin has joined #ocaml
rgrinberg has joined #ocaml
<d_bot>
<aolko> hi there, i'd like to ask some questions about using ocaml as a base for a language
<d_bot>
<aolko> apparently people claim that it'
bartholin has quit [Ping timeout: 240 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
<d_bot>
<octachron> Like always `simple` depends on your background. And as `the best language` it is hardly something that can be quantified objectively.
bartholin has joined #ocaml
<d_bot>
<aolko> i'm a procedural php guy (and somewhat functional es5 guy, normal functional not twisted ml functional)
<d_bot>
<octachron> The datapoints on hand is that `Rust` was bootstrapped from `OCaml`. `Haxe`, `Hack`, the reference `webasm` implementation are written in OCaml. And `Rescript` too (but that is a fork of OCaml).
<d_bot>
<aolko> that was also the starter point
<d_bot>
<octachron> Hm, if you are not familiar with writing a compiler, this means that you would be learning on three fronts at the same time: functional languages, proper type systems (with sums), about compilers.
<d_bot>
<aolko> well, interpreter, rather
<d_bot>
<aolko> since you don't know the **why** part just yet
<d_bot>
<octachron> Anyway, what were you questions?
<d_bot>
<aolko> right, how does one write an interpreter of a different dialect of existing language?
<d_bot>
<g_w1> fwiw, i'm writing a lang in ocaml rn
<d_bot>
<aolko> great, i count on your help 😛
rgrinberg has joined #ocaml
<d_bot>
<g_w1> write a tokenizer then parser then bytecode generator then bytecode executor
<d_bot>
<Cyclomatic Complexity> (And ligolang.org is written in OCaml)
<d_bot>
<Cyclomatic Complexity> Unrelated: is there a ppx / anything to name patterns in OCaml?
<d_bot>
<aolko> with a skip-tokenizer-entirely root, like PEG-based langs do
<d_bot>
<g_w1> yes
<d_bot>
<aolko> oh and probably i will supply my own format of grammars
<d_bot>
<aolko> so, in other words i probably need a parser generator
<d_bot>
<aolko> and so far i found Menhir
favonia has joined #ocaml
<d_bot>
<aolko> and `hack` currently uses a mix of rust and ocaml, so it's not as simple to pick it apart
<d_bot>
<octachron> `Menhir` is the go-to parser generator for OCaml.
<d_bot>
<aolko> right, so it also means that grammar has to be written from scratch 😐
<d_bot>
<colin> it probably won't be that bad since the precedence declarations required to remove conflicts will be the same and are given in the file above
<d_bot>
<colin> will be laborious and tedious
<d_bot>
<colin> but "from scratch", depends how you look at it - I'd say formed grammar productions and precedence declarations is really a mechanical translation
<d_bot>
<aolko> yeah, it'd be great if your grammar is entirely original
<d_bot>
<aolko> but if you have to closely clone another language (in this case php) that's oof
<d_bot>
<colin> the semantic actions are in PHP
<d_bot>
<colin> so long as they're not stateful in some hacky way, could probably transliterate into what menhir or ocamlyacc expects quite easily
<d_bot>
<aolko> the point is that i essentially have no prefabs for the grammar, so i have to write it myself
<d_bot>
<aolko> in peg, from scratch
<d_bot>
<aolko> for menhir
bartholin has joined #ocaml
<d_bot>
<colin> maybe I'm misunderstanding
<d_bot>
<colin> aren't you just wanting to port the above, linked, grammar to menhir?
<d_bot>
<aolko> no, i won't be doing that
<d_bot>
<aolko> i linked that as a "oh great it's an entirely different grammar i won't be porting" proof
<d_bot>
<colin> what are you wanting to parse
<d_bot>
<colin> I've read your messages several times and don't follow at all
<d_bot>
<colin> perhaps the beer is too strong
<d_bot>
<aolko> that question comes after "what are the differences from php?"
<d_bot>
<colin> are you wanting to parse PHP?
<d_bot>
<aolko> i want to interpret my dialect
<d_bot>
<colin> Zend's parser for PHP uses yacc/bison so its grammar is for an LR-based parser generator
<d_bot>
<colin> so you can modify that
<d_bot>
<colin> you'll need to transliterate it into menhir
<d_bot>
<aolko> no way i'm going into that pit of spaghetti
<d_bot>
<colin> beats doing it from scratch
<d_bot>
<colin> especially if you're familiar with yacc-based tooling already
<d_bot>
<colin> you have met the necessary suffering of the least important and least-interesting parts of language projects, parsing
<d_bot>
<aolko> with parser generators that's kinda avoidable
<d_bot>
<colin> depends on the generator
<d_bot>
<colin> if you do any substantial work with LR generators
<d_bot>
<aolko> in our case menhir
<d_bot>
<colin> yeah
<d_bot>
<colin> to resolve conflicts in these grammars
<d_bot>
<colin> you often have to appeal to the table itself
<d_bot>
<colin> (we'll dispense of the fact that menhir, by default, doesn't actually compile to an LR algorithm querying a table)
<d_bot>
<NULL> I've never had any problems when reading menhir's `--explain` output
<d_bot>
<colin> I find it too annoying
<d_bot>
<colin> I usually know the problem in my head
<d_bot>
<colin> and know how to achieve the results I want if I could simply resolve conflicts in the table directly (which I do sometimes, hardcoding table + algo)
<d_bot>
<colin> the issue is
<d_bot>
<colin> I find yacc precedence declarations to be really annoying
<d_bot>
<aolko> the other future pain i forsee is actually getting the interpreter to work with apache, but that's for another time
<d_bot>
<colin> are you just gonna route through fastcgi?
<d_bot>
<colin> that's the quick and simple way to feed into a webserver
<d_bot>
<aolko> well, there's php-fpm and mod_php
<d_bot>
<aolko> so i think there should be smth similar
<d_bot>
<colin> fastcgi
<d_bot>
<aolko> and then the extension question will arise, since i haven't yet conceived the `php.ini` alternative
<d_bot>
<colin> have you considered compiling to PHP and simply doing it as a kind of preprocessor rather than interpreter or do you have semantics that aren't amenable to that scenario
<d_bot>
<aolko> no
<d_bot>
<aolko> becauze zend f'd up real badly
<d_bot>
<colin> I just think at least then you'd get JIT
<d_bot>
<aolko> no man, it's non-salvageable
<d_bot>
<colin> what, PHP?
<d_bot>
<aolko> zend engine
<d_bot>
<colin> how brutal is your overhaul going to be
<d_bot>
<colin> might as well just create a different language 😏
<d_bot>
<aolko> well, that'll be pphp
<d_bot>
<colin> smlweb or Ur/Web coming up 😏
<d_bot>
<aolko> no, just pphp
<d_bot>
<aolko> it'll use the collection principle and no oop
<d_bot>
<colin> the fact that Googling that acronym led to a wikipedia page describing an "inherited disorder" is rather fitting
<d_bot>
<aolko> so, module is a collection of functions is a collection of variables
<d_bot>
<aolko> it can be shortened to `pp` and it's not my fault ~90% of the web runs php
<d_bot>
<colin> ah, well, good luck with your ventures in webpain
<d_bot>
<aolko> right, doesn't mean i'd be entirely on my own, would still need that grammar/interpreter help
<d_bot>
<aolko> as for right now basically defining the base php grammar
<d_bot>
<colin> luckily that exists as a yacc grammar already
<d_bot>
<aolko> not peg tho
<d_bot>
<colin> PEG is bad. Qed.
<d_bot>
<aolko> peg is friendlier
<d_bot>
<colin> sounds like a total nightmare to do that
<d_bot>
<aolko> this is like saying css is bad and XAML styling is great
<d_bot>
<colin> on one hand you have a ready-to-go-with-some-transliteration-into-idiomatic-menhir
<d_bot>
<colin> on the other, "let's do it in PEG from scratch"
<d_bot>
<aolko> iirc there's no 100% accurate translators/converters from yacc to peg
<d_bot>
<colin> believable
<d_bot>
<aolko> and since that's a thing for people like me that are not gurus in parse generators that seems to be the viable option
<d_bot>
<colin> luckily, to become a guru at parser generators you just need to read 10 pages of Aho's "Compilers: Principles, Techniques, and Tools" i.e. the dragon book
<d_bot>
<colin> the only redeeming chapters of that book 🙃
<d_bot>
<aolko> i'm all for domain-specific knowledge
<d_bot>
<aolko> i.e. the neccessary knowledge for the task/set of tasks
<d_bot>
<aolko> dragon book doesn't fit in that
<d_bot>
<colin> well, tell me when you've got your PHP-with-extensions PEG grammar ready-to-go in 2030
<d_bot>
<aolko> please don't pull one of those "hmph well tell me when you'll do your thing entirely on your own because you reject the ways i suggested"
<d_bot>
<aolko> it won't get anywhere, nor will it help to solve the problem
<d_bot>
<colin> this is an OCaml server and you've rejected the most popular generator used by OCaml projects
<d_bot>
<colin> so I can only wish you luck and good health
<d_bot>
<aolko> not really, i was going for peg one, yet you kinda stareted insisting on yacc one
<d_bot>
<colin> with good reason
<d_bot>
<colin> namely that the PHP grammar has been defined several times for yacc-based/inspired tooling
<d_bot>
<aolko> then:
<d_bot>
<aolko> a. someone who has a better understanding of both parser generators can help out by translating it
<d_bot>
<aolko> b. it will be written from scratch with no reference by poking around in the target parser generator from the start
<d_bot>
<colin> a. is straightforward as yacc is easy to learn
<d_bot>
<colin> bison, yacc, menhir, etc.
<d_bot>
<colin> all get a bad review from Reddit-compiler people
<d_bot>
<aolko> not really
<d_bot>
<colin> but that's because their idea of "too much work" is reading 5 pages of documentation to learn how to use a tool
<d_bot>
<aolko> css is easy to learn, yacc is messy to learn
<d_bot>
<colin> they'd rather yak shave a recursive descent mess
<d_bot>
<colin> have you learned yacc?
<d_bot>
<aolko> never, still a mess every time i look into any yacc grammar
<d_bot>
<colin> ah, so something that vaguely resembles BNF w/ semantic actions
favonia has quit [Ping timeout: 240 seconds]
<d_bot>
<colin> is messy
<d_bot>
<colin> I see
<d_bot>
<aolko> i like the straight top-down peg-like kind
<d_bot>
<octachron> I don't remember any active PEG generator library. I generally see people use either menhir, parser combinators, or hand-written parsers.
<d_bot>
<g_w1> is there an idomatic way to say this code is unreachable? similiar to unreachable!() in rust or `unreachable` in zig? I basically want to use it in a match case to say panic if this is reached, it should never get to here
<d_bot>
<Deadrat> failwith "unreachable" ?
<d_bot>
<Alistair> Modify the type to ensure it's not expressible?
<d_bot>
<theangryepicbanana> what else are you expecting lol
<d_bot>
<aolko> r9y
<d_bot>
<theangryepicbanana> do you really want every definition to be `var thing = function thing() {...}`
<companion_cube>
it sounds as weird as someone saying "C++98, the most readable one"
<d_bot>
<theangryepicbanana> ^
<d_bot>
<aolko> sure, function can be shortened to `fun` or `func`
<d_bot>
<theangryepicbanana> if you *really* want an ocaml-like language that looks like ancient JS, you should have a look at Haxe
<companion_cube>
:DDDD
favonia has quit [Ping timeout: 240 seconds]
<d_bot>
<theangryepicbanana> it even used switch/case for pattern matching
<d_bot>
<Alistair> Languages are often designed to solve certain problems (e.g. ML was a meta language for theorem proving), they should be used based on merits of this for specific problems
<d_bot>
<Alistair> Like sure OCamls syntax is a bit clunky, but it’s great at what it does
<d_bot>
<theangryepicbanana> and if you don't like it, there's plenty of similar languages with different syntax (reasonml, f#, scala, etc)
favonia has joined #ocaml
<d_bot>
<aolko> haxe is a weird territory for me, yes it has a butt-ton of targets, but it's oop turns me off
<d_bot>
<theangryepicbanana> fun fact: ocaml has oop too
<d_bot>
<Alistair> ^
<d_bot>
<Alistair> Objective Caml
<d_bot>
<aolko> then it's not truly functional
<d_bot>
<theangryepicbanana> who said it had to be
<d_bot>
<Alistair> If you want pure then go Haskell
<d_bot>
<NULL> So you're neither a functional nor an OOP programmer ?
<d_bot>
<theangryepicbanana> I'll actually unironically use classes in ocaml every so often
<d_bot>
<theangryepicbanana> lol
<companion_cube>
me too
<d_bot>
<aolko> i'm a procedural guy
<d_bot>
<Alistair> Use C?
<d_bot>
<theangryepicbanana> then you're better off with pascal lmao
<d_bot>
<aolko> php
<d_bot>
<theangryepicbanana> tf
<d_bot>
<aolko> as of using c, there are cavearts
<d_bot>
<theangryepicbanana> you criticize ocaml and then say php is better?
<d_bot>
<aolko> took it as "do you use c?"
<d_bot>
<theangryepicbanana> php and c are in completely different domains
<d_bot>
<aolko> nope, since zend ruins it with each major release
<d_bot>
<aolko> same with js and tc39, don't worry
<d_bot>
<theangryepicbanana> I really don't care ngl
<d_bot>
<Alistair> Make your own language and ecosystem?
<d_bot>
<theangryepicbanana> also a side note, you'll never actually escape fp and oop because they technically exist in every language in some way
<d_bot>
<aolko> so that means writing a parser generator since i have my own idea of grammars
<companion_cube>
@aolko I say that in all seriousness: if you don't like FP, OCaml is not going to be pleasant for you
<companion_cube>
look into Zig or Ada or something like that
<d_bot>
<aolko> i like fp when it only has *some* of the unnecessary jargon haskell has
<d_bot>
<aolko> mainly when it's just about functions and closures, nothing more
<d_bot>
<Alistair> types?
<companion_cube>
that's pretty watered down FP
<d_bot>
<Alistair> ^
<d_bot>
<Alistair> Basically lambda calc
<d_bot>
<aolko> dynamic, optional
<d_bot>
<theangryepicbanana> haskell isn't the primary example of FP
<companion_cube>
so, like, 2000-ish JS
<d_bot>
<aolko> it's primary example of poisonous fp jargon
<d_bot>
<theangryepicbanana> not really
<d_bot>
<aolko> ES3*
<d_bot>
<Alistair> Types is perhaps the best feature of FP
<d_bot>
<aolko> yep, pretty much like ES3
<d_bot>
<theangryepicbanana> the "jargon" you're referring to is most likely monads, which aren't really FP-specific, but something more common in "purely functional" languages
<d_bot>
<Alistair> Not really, if you accept that mathematicians got to naming useful things first and just learn stuff like monads as functional patterns (like OOP patterns) then it becomes simpler to deal with
<d_bot>
<Alistair> You don't need to take a category theory course to know how to use a monad
<companion_cube>
@aolko why don't you stick to JS
<d_bot>
<theangryepicbanana> purely functional language take up a minority of the FP paradigm, so it's wrong to thing that that make FP bad or complex or whatever
<d_bot>
<aolko> TC39 ruined it
<companion_cube>
or explore things like clojure, which are also dynamically typed
<companion_cube>
and have no |
<companion_cube>
you can still use old JS
<d_bot>
<Alistair> How about Scala?
<companion_cube>
it hasn't disappeared
<d_bot>
<theangryepicbanana> companion_cube: agreed. this isn't going anywhere
<d_bot>
<aolko> (((clojure))) more like
<d_bot>
<theangryepicbanana> oh so you're one of those people
<companion_cube>
…
<d_bot>
<aolko> scala is weighed down with JVM
<companion_cube>
wat
<d_bot>
<Alistair> V8 vs JVM lol
<d_bot>
<Alistair> Can't imagine which one wins
<companion_cube>
JVM
<companion_cube>
anyway can we just stop this now?
<d_bot>
<theangryepicbanana> companion_cube: i.e snowflakes who think that every language is imperfect (except for one really obscure one) and refuse to believe otherwise (or in other words, actually learn about they languages they complain about)
<d_bot>
<Alistair> Yeah, this is unproductive
<d_bot>
<aolko> > you can still use old JS
<d_bot>
<aolko> the ecosystem is gone
<d_bot>
<theangryepicbanana> I'm sure there's a reason for that
<d_bot>
<theangryepicbanana> can't quite put my finger on it, eh?
<d_bot>
<aolko> one big fat reason is npm
<d_bot>
<aolko> and it's hell
<d_bot>
<theangryepicbanana> wow, it's like people don't want to use ancient technology anymore
<companion_cube>
you could look into lua, it's like old JS
<d_bot>
<theangryepicbanana> even internet explorer supports ES5
<companion_cube>
(except still useful)
<d_bot>
<Alistair> Yeah Lua is good
<d_bot>
<aolko> the perception of `ancient` is all in people's heads
<d_bot>
<Alistair> And not too slow
<d_bot>
<thangngoc89> This conversation is very non-productive
<d_bot>
<aolko> lua might be good, sure, bure in some places it's rather clunky