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
<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>
<._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
<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> 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.