Leonidas changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.1.1 released: https://ocaml.org/releases/5.1.1 | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Tuplanolla has quit [Quit: Leaving.]
<discocaml_> <struktured> Re-asking the following question as I'm still quite curious about it. Has anyone seen a signature emiitted with two definitions of the same value in the signature, with the 2nd one being bound as `_`? Eg...
<discocaml_> <struktured>
<discocaml_> <struktured> ```OCaml
<discocaml_> <struktured> module type S = sig
<discocaml_> <struktured> val f : int -> bool
<discocaml_> <struktured> val _ : int -> bool
<discocaml_> <struktured> end
<discocaml_> <struktured> ```
<discocaml_> <struktured>
<discocaml_> <struktured> I can't reproduce it anymore unfortunately as I worked around it but I believe it was a sexp converter function definition in this case.
cr1901_ has joined #ocaml
cr1901 has quit [Ping timeout: 268 seconds]
neiluj has joined #ocaml
neiluj has quit [Ping timeout: 246 seconds]
neiluj has joined #ocaml
neiluj has quit [Ping timeout: 256 seconds]
nkatte has quit [Changing host]
nkatte has joined #ocaml
hsw has joined #ocaml
neiluj has joined #ocaml
neiluj has quit [Ping timeout: 260 seconds]
jabuxas has joined #ocaml
neiluj has joined #ocaml
neiluj has quit [Ping timeout: 256 seconds]
jabuxas has quit [Ping timeout: 255 seconds]
neiluj has joined #ocaml
hsw_ has joined #ocaml
hsw has quit [Ping timeout: 256 seconds]
neiluj has quit [Ping timeout: 255 seconds]
neiluj has joined #ocaml
neiluj has quit [Ping timeout: 255 seconds]
<discocaml_> <sim642> I think ppxlib derivers cause this
neiluj has joined #ocaml
neiluj has quit [Ping timeout: 256 seconds]
pi3ce has joined #ocaml
pi3ce has quit [Client Quit]
pi3ce has joined #ocaml
neiluj has joined #ocaml
neiluj has quit [Ping timeout: 268 seconds]
neiluj has joined #ocaml
neiluj has quit [Ping timeout: 246 seconds]
neiluj has joined #ocaml
olle has joined #ocaml
neiluj has quit [Ping timeout: 268 seconds]
pi3ce has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
pi3ce has joined #ocaml
Serpent7776 has joined #ocaml
sroso has joined #ocaml
neiluj has joined #ocaml
bartholin has joined #ocaml
neiluj has quit [Ping timeout: 260 seconds]
bartholin has quit [Ping timeout: 240 seconds]
<reynir> that got me thinking of this PR that I see now got merged: https://github.com/ocaml/ocaml/pull/12323
<reynir> as I understand it you can then write »val \#_ : int -> bool« then
dnh has joined #ocaml
<discocaml_> <darrenldl> only just now realised `@.` with a formatter made from stderr doesn't actually print newline to stderr, but just to stdout
<discocaml_> <darrenldl> 🤦‍♂️
neiluj has joined #ocaml
waleee has quit [Ping timeout: 246 seconds]
oriba has joined #ocaml
<oriba> when using Printexc.register_printer I can create nice messages
<oriba> but there always is printed Fatal error
<oriba> is there a way to have a more smooth exit?
<oriba> when using try/with I could print a message and then exit
<oriba> is this also possible with Printexc module?
<oriba> ah, Printexc.to_string also uses the printer-output... so I can wrap inside try/with and then do exit 1 there...
sroso has quit [Quit: Leaving :)]
discocaml_ has quit [Remote host closed the connection]
discocaml has joined #ocaml
<oriba> looks like register_printer does not more than to regsister a printer ;-)
<discocaml> <lyhokia> Hello, anyone knows how to prevent reduce reduce error in an expression language where arbitrary newline token may be inserted?
<discocaml> <lyhokia> Like this:
<discocaml> <lyhokia> ```
<discocaml> <lyhokia> exp:
<discocaml> <lyhokia> | l=literal { ... }
<discocaml> <lyhokia> | e1=exp NL* op=bin_op NL* e2=exp { ... }
<discocaml> <lyhokia> ```
<discocaml> <._null._> Don't post long code, the bridge to IRC doesn't handle them well
<discocaml> <lyhokia> Okay, let me find a ubuntu pastebin
<discocaml> <._null._> I think it's easier to deal with newlines in the lexer directly
<discocaml> <lyhokia> Well in some case you have to deal with them in parser
<discocaml> <._null._> To only make it a token when it is significant
<discocaml> <lyhokia> My langauge is newline significant
<discocaml> <._null._> When are they significant ?
<discocaml> <lyhokia> Because I am writing a shell
<discocaml> <lyhokia> A mixed language of shell and python, if you well.
<discocaml> <lyhokia> And I think when they are significant doesn't matter here because I would need to write a lot to explain it. And it is not related to the issue here.
<discocaml> <lyhokia> The issue here is pretty simple, get this work:
<discocaml> <lyhokia> ```
<discocaml> <lyhokia> exp:
<discocaml> <lyhokia> | l=literal { ... }
<discocaml> <lyhokia> | e1=exp NL* op=bin_op NL* e2=exp { ... }
<discocaml> <lyhokia> ```
<discocaml> <._null._> If you can decide at lexing time whether newlines are significant, you completely bypass this issue. I have no other solution (even though they might exist)
<discocaml> <lyhokia> Well the very reason I wouldn't throw away newlines is that I can't decide when are they significant.
<discocaml> <lyhokia> So I don't think that will work.
<discocaml> <lyhokia> Thank you, though.
pi3ce has quit [Quit: No Ping reply in 180 seconds.]
pi3ce has joined #ocaml
<dh`> lyhokia: I can explain how to do this
<dh`> but the problem with exp ::= literal | exp op exp isn't the newline
<dh`> (a) first make your grammar work without newlines
<dh`> (b) then make the grammar work with all newlines optional (to do this, put NL* _after each terminal_; that guarantees there's only one NL* possible in any given state
<dh`> (c) then change NL* to NL+ where you want to require them
<dh`> if that won't work because you are also trying to use NL as end-of-statement or similar, make a different token TEMP and use that as the end marker until you've sorted out ignoring the newlines elsewhere
<dh`> then you'll have a couple places in your grammar with TEMP NL*, and if you just remove TEMP it'll be ambiguous
<dh`> to fix that you need to make all the tokens that can appear before TEMP _not_ be allowed to end in newline
<dh`> (and if there are other uses of them that should still allow newlines, change _those_ uses to t NL*)
<dh`> basically the way to think about it is in terms of which nonterminals can end in optional newlines
<dh`> but still, first make the grammar work without newlines. debug one thing at a time
<discocaml> <lyhokia> Let me take a look
<discocaml> <lyhokia> Thank you
<discocaml> <lyhokia> The grammar works without newlines.
<discocaml> <lyhokia> I doublt (b) though.
<dh`> then it can't have exp ::= literal | exp op exp in it, that's itself ambiguous
<discocaml> <lyhokia> I have precedence set for op
<discocaml> <lyhokia> I'm kinda confused as to why it's itself ambiguous
<discocaml> <lyhokia> Oh oh this is a left-recursion
<discocaml> <lyhokia> my bad
<dh`> also, don't use precedence rules, write out the expression grammar
<discocaml> <lyhokia> Why?
<dh`> what the precedence rules actually do is highly technical and unless you're really on top of the innards of this stuff it's hard to be sure that what they're doing is actually what you want
<discocaml> <lyhokia> okay, let me take a try
<dh`> plus while (or maybe because) expression grammars are highly stylized it's not difficult to either write or read
<dh`> unless you want to have let expressions with different precedence on the RHS, that's a pain in the arse
<dh`> (but it's also a case where it's _really_ hard to reason about the precedence declarations)
<dh`> anyway, exp ::= literal NL* | exp op NL* literal NL* will work (assuming op and literal are terminals and/or they can't already end in newlines)
<dh`> another reason to write out the operator precedence is that for something like a shell newlines are effectively another operator
<dh`> or at least, the end-of-statement newlines are
olle has quit [Ping timeout: 240 seconds]
<dh`> the sh grammar goes something like stmts ::= stmt | stmts NL stmt | stmts SEMIC stmt
<discocaml> <lyhokia> That's an interesting view
<discocaml> <lyhokia> So sh is actually expression based?
<dh`> (it's more complicated than that, sh being weird in its own assorted ways, but that's a starting point)
<dh`> sh is just weird, look at Michael Greenberg's treatment of it if you're curious
<discocaml> <lyhokia> Yeah, the weirdness of sh is exactly why I want to write a better alternative lol.
<discocaml> <lyhokia> Thanks for the info!
<dh`> yw
<dh`> unfortunately you'll find that people expect sh-style quoting and variable expansion in shells
<dh`> but yeah, newline is a separator, and all or nearly all newlines can be interchanged with ;
<dh`> the other thing you need to do in your grammar is make sure the parser never tries to look ahead past a newline, or interactive mode won't work right
<dh`> unfortunately, there's no easy way to crosscheck that
<discocaml> <lyhokia> What's the argument with this
<discocaml> <lyhokia> that interactive mode won't work?
<dh`> when you get a line from the terminal and send it through the parser, you want it to execute and not demand more input to look ahead at before it parses that line
<dh`> you can work around this by restarting for every line and feeding it an EOF at the end of each line, but that's annoying and may cause you other internal problems
jabuxas has joined #ocaml
<discocaml> <lyhokia> Oh yeah that make sense.
<dh`> you ought to be able to declare in the grammar "you may not look ahead past here" so it'll fail to build if you accidentally write it so it needs to
<dh`> but no parser generator I've ever heard of supports that
<discocaml> <lyhokia> I may run into this and get back to you later. Thank you.
<dh`> sure
waleee has joined #ocaml
waleee has quit [Quit: WeeChat 4.1.2]
mro has joined #ocaml
neiluj has quit [Ping timeout: 252 seconds]
dylanj_ is now known as dylanj
<discocaml> <limp.biskit> non-sh shells are cool. can't think of another one off the top of my head except fish
<companion_cube> nushell, elvish
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
<discocaml> <limp.biskit> nushell looks cool
<discocaml> <limp.biskit> reminds me of the nice parts of powershell
mro has quit [Quit: Leaving]
<discocaml> <lyhokia> nushell feels fragile as it's another layer atop of the environment.
<discocaml> <lyhokia> evlish looks fine but I want more extensible shell
<discocaml> <lyhokia> there was a fairly unpopular shell but it's very extensible, but I don't like it's syntax.
<discocaml> <lyhokia> Has anyone run into getting a reduce/reduce error when compiling menhir, but when you look at the error message dumped by menhir there's only shift-reduce conflicts?
<discocaml> <lyhokia> I'm running `menhir --explain --inspection --dump --table ./menhir_parser.mly`
<discocaml> <lyhokia> NVM figured what is it out.
<discocaml> <lyhokia> Bascially the err message get opressed by other err messages
jabuxas has quit [Ping timeout: 240 seconds]
nasmevka has joined #ocaml
nasmevka has quit [Remote host closed the connection]
neiluj has joined #ocaml
neiluj has quit [Ping timeout: 255 seconds]
cr1901_ is now known as cr1901
pi3ce has quit [Ping timeout: 264 seconds]
pi3ce has joined #ocaml
jabuxas has joined #ocaml
Tuplanolla has joined #ocaml
jabuxas has quit [Ping timeout: 255 seconds]
waleee has joined #ocaml
neiluj has joined #ocaml
myrkraverk_ has quit [Read error: Connection reset by peer]
neiluj has quit [Ping timeout: 255 seconds]
myrkraverk has joined #ocaml
myrkraverk_ has joined #ocaml
myrkraverk has quit [Read error: Connection reset by peer]
jabuxas has joined #ocaml
neiluj has joined #ocaml
ania123 has joined #ocaml
neiluj has quit [Ping timeout: 268 seconds]
neiluj has joined #ocaml
ania123 has quit [Quit: Client closed]
pi3ce has quit [Ping timeout: 256 seconds]
<discocaml> <barconstruction> I'm trying to learn some F# and I keep getting caught on very surprising things.
<discocaml> <barconstruction> This seems like such a big difference, it's surprising that they diverge so much from OCaml in the simple concept of an abstract data type.
Serpent7776 has quit [Ping timeout: 255 seconds]
pi3ce has joined #ocaml
berberman has quit [Quit: ZNC 1.8.2 - https://znc.in]
berberman has joined #ocaml
waleee has quit [Quit: WeeChat 4.1.2]
n8n has quit [Quit: WeeChat 4.2.2]
n8n has joined #ocaml
neiluj has quit [Quit: WeeChat 4.2.1]
pi3ce has quit [Quit: No Ping reply in 180 seconds.]
pi3ce has joined #ocaml
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]