Newest at the top
| 2026-02-11 13:31:28 +0100 | tremon | (~tremon@83.80.159.219) tremon |
| 2026-02-11 13:30:53 +0100 | fp | (~Thunderbi@wireless-86-50-141-104.open.aalto.fi) fp |
| 2026-02-11 13:29:53 +0100 | ski | would like a mode & determinism tracking system that could be used to ensure that you get the intended efficient switching rather than backtracking, when you expect it, without removing the more general case, nor making it less convenient to express |
| 2026-02-11 13:27:41 +0100 | <tomsmeding> | but I also have to be honest that if you make things more explicit, the whole system doesn't necessarily get nicer -- the rule does somehow strike a balance where a lot of cases can be expressed fairly neatly |
| 2026-02-11 13:26:58 +0100 | <tomsmeding> | I'm not a fan of this model of "backtracking is an error without consuming input", as it's unintuitive and at times inflexible; I prefer my parser combinators more explicit about backtracking and failure |
| 2026-02-11 13:26:05 +0100 | <tomsmeding> | or ("abc" >> eof), if appropriate |
| 2026-02-11 13:25:45 +0100 | <tomsmeding> | ("abc" >> notFollowedBy "d"), for example |
| 2026-02-11 13:25:31 +0100 | <tomsmeding> | The solutions here seem to be swapping the two parsers (in which case the try shouldn't be necessary any more), or augmenting the "abc" parser to explicitly reject a following 'd' |
| 2026-02-11 13:24:44 +0100 | <tomsmeding> | error. |
| 2026-02-11 13:24:42 +0100 | <tomsmeding> | bwe: as people have said, thep roblem is that "abc" succeeds, so the left argument to (<|>) succeeds, so the (<|>) as a whole succeeds and that's that. (Mega)parsec does not do arbitrary backtracking: its model is that if a parser fails while having consumed input, it's an error; if a parser fails without consuming input, we backtrack. 'try' wraps its argument to "undo" the input consumption upon |
| 2026-02-11 13:23:56 +0100 | machinedgod | (~machinedg@d75-159-126-101.abhsia.telus.net) machinedgod |
| 2026-02-11 13:23:25 +0100 | prdak | (~Thunderbi@user/prdak) (Ping timeout: 264 seconds) |
| 2026-02-11 13:22:56 +0100 | <ski> | (mm, right. for some reason i was thinking it did the right distributive law, with `try' .. too bad) |
| 2026-02-11 13:18:34 +0100 | prdak1 | prdak |
| 2026-02-11 13:18:34 +0100 | prdak | (~Thunderbi@user/prdak) (Ping timeout: 246 seconds) |
| 2026-02-11 13:18:29 +0100 | prdak1 | (~Thunderbi@user/prdak) prdak |
| 2026-02-11 13:14:25 +0100 | trickard_ | trickard |
| 2026-02-11 13:14:09 +0100 | <Leary> | No, it's outside of the `<|>`. |
| 2026-02-11 13:13:21 +0100 | <ski> | (seems to me like the failing end of input ought to trigger backtracking, with the `try' present there, no ?) |
| 2026-02-11 13:06:35 +0100 | <Leary> | `parseTest` seems to be for visual inspection, not automated testing. |
| 2026-02-11 13:05:03 +0100 | <__monty__> | Or use parseTest and just add the type annotation that it complains about. |
| 2026-02-11 13:04:51 +0100 | <Leary> | I think they want the opposite; add `<* takeWhileP (const True)`. |
| 2026-02-11 13:03:51 +0100 | <merijn> | i.e.: parseMaybe (foo <* eof) "stuff here" |
| 2026-02-11 13:03:15 +0100 | <merijn> | bwe: I mean, you could just add "<* eof" to each parse before feeding to parseMaybe? :) |
| 2026-02-11 13:02:36 +0100 | <bwe> | Leary: So this answers why `parseMaybe` behaves differently than when I combine the parser with others. What's then the right function to (unit) test parser combinator segments? |
| 2026-02-11 13:00:15 +0100 | <Leary> | bwe: "This function also parses eof, so if the parser doesn't consume all of its input, it will fail." |
| 2026-02-11 12:58:36 +0100 | <bwe> | __monty__: But why does it return Nothing, then? (Flipping fixes it for me but I still don't understand the concept.) |
| 2026-02-11 12:58:10 +0100 | comonad | (~comonad@p200300d02722ae00dce4ce9451b59974.dip0.t-ipconnect.de) |
| 2026-02-11 12:56:33 +0100 | weary-traveler | (~user@user/user363627) user363627 |
| 2026-02-11 12:55:22 +0100 | merijn | (~merijn@77.242.116.146) merijn |
| 2026-02-11 12:54:34 +0100 | housemate | (~housemate@202.7.248.67) (Ping timeout: 260 seconds) |
| 2026-02-11 12:54:19 +0100 | Enrico63 | (~Enrico63@host-79-22-157-220.retail.telecomitalia.it) Enrico63 |
| 2026-02-11 12:53:21 +0100 | trickard_ | (~trickard@cpe-54-98-47-163.wireline.com.au) |
| 2026-02-11 12:47:53 +0100 | <__monty__> | In this case I assume you want to flip the argument order basically. |
| 2026-02-11 12:47:34 +0100 | <__monty__> | bwe: <|> uses its left argument if it succeeds, so if it does the right argument is never tried. |
| 2026-02-11 12:46:31 +0100 | <bwe> | I mean `parseMaybe (try (1 <$ "abc") <|> 1 <$ "abcd") "abcd"` of course. There, the second does not succeed, but I want it to succeed. |
| 2026-02-11 12:46:01 +0100 | trickard_ | (~trickard@cpe-54-98-47-163.wireline.com.au) (Ping timeout: 246 seconds) |
| 2026-02-11 12:42:26 +0100 | <Leary> | bwe: Why would it be? The first succeeds. |
| 2026-02-11 12:40:24 +0100 | j1n37 | (~j1n37@user/j1n37) j1n37 |
| 2026-02-11 12:40:18 +0100 | <bwe> | tomsmeding: Thanks for the recommendation of the fsnotify package (yet to check it out). |
| 2026-02-11 12:39:44 +0100 | <bwe> | Why is the second (Megaparsec) parser not being evaluated? `parseMaybe (try (1 <$ "abc") <|> 1 <$ "abcd") "abcd"` -- parseTest is of no help as it moans about ambiguous types. And no, encapsulating each parser with try doesn't help either (assuming the backtracing is the issue). |
| 2026-02-11 12:38:20 +0100 | j1n37 | (~j1n37@user/j1n37) (Read error: Connection reset by peer) |
| 2026-02-11 12:36:32 +0100 | <ski> | (i'd first done it in a kludgey way, with the traditional precedences, but it turned out to not work for more complex examples. oh, and yea, i'm pretty sure this should work for mixfix with individual precedences specified for the ends of the constituent lexemes (cf. Annika Aasa's papers on parsing)) |
| 2026-02-11 12:35:11 +0100 | trickard_ | (~trickard@cpe-54-98-47-163.wireline.com.au) |
| 2026-02-11 12:35:10 +0100 | merijn | (~merijn@77.242.116.146) (Ping timeout: 246 seconds) |
| 2026-02-11 12:34:58 +0100 | trickard_ | (~trickard@cpe-54-98-47-163.wireline.com.au) (Read error: Connection reset by peer) |
| 2026-02-11 12:34:44 +0100 | <ski> | got annoyed at not having `BlockArguments'-style printing of trailing lambda (including inside of an outer bracketting), with a simple standard precedence printer that i used for some examples i was playing around with, so i threw the above together, to see whether my initial hunch for how to do it would work |
| 2026-02-11 12:34:44 +0100 | comonad | (~comonad@p200300d02722ae00dce4ce9451b59974.dip0.t-ipconnect.de) (Ping timeout: 260 seconds) |
| 2026-02-11 12:30:09 +0100 | <Leary> | Haskell98 printing in a better timeline. |
| 2026-02-11 12:29:50 +0100 | Enrico63 | (~Enrico63@host-79-22-157-220.retail.telecomitalia.it) (Quit: Client closed) |