2025/02/10

Newest at the top

2025-02-10 17:41:29 +0100 <bwe> dminuoso: yeah, that's actually what lookahead is doing :). Thanks for pointing me at that.
2025-02-10 17:38:32 +0100jespada(~jespada@2800:a4:224d:2b00:41f1:b3c7:471b:62da) jespada
2025-02-10 17:38:15 +0100 <haskellbridge> <Bowuigi> tomsmeding re:VariantF oh, is it useful for anything else? I can cover that usecase with other features. I think it was used in an effect system at some point
2025-02-10 17:37:24 +0100 <dminuoso> bwe: If all you want is just parse without consuming, use lookahead.
2025-02-10 17:37:04 +0100 <bwe> dminuoso: so, swapping out the underlying buffer to the beginning, that means saving the buffer before parsing, then accessing the saved value and reset it to that when I want it, right?
2025-02-10 17:35:52 +0100 <dminuoso> do { a <- lookahead parser1; b <- parser2 ... }
2025-02-10 17:35:27 +0100 <dminuoso> Yeah that would work for you.
2025-02-10 17:35:21 +0100 <dminuoso> Or I guess you could use `lookahead`
2025-02-10 17:35:14 +0100 <dminuoso> bwe: Like I said, you need something like `refocus` that I mentioned above.
2025-02-10 17:34:35 +0100 <bwe> dminuoso: https://play.haskell.org/saved/HGeKdnSW
2025-02-10 17:34:07 +0100pavonia(~user@user/siracusa) (Quit: Bye!)
2025-02-10 17:33:55 +0100jespada(~jespada@2800:a4:2243:2100:5cc9:2329:b53c:b25f) (Ping timeout: 252 seconds)
2025-02-10 17:31:43 +0100 <dminuoso> What do you mean with "again"?
2025-02-10 17:31:26 +0100 <bwe> dminuoso: I basically want to parse `s` again with another parser in a bigger parser function.
2025-02-10 17:30:47 +0100 <dminuoso> Not sure what the question means
2025-02-10 17:30:42 +0100 <dminuoso> bwe: Well you dont if it succeeds..
2025-02-10 17:30:26 +0100 <bwe> dminuoso: How do I backtrack with Megaparsec if one parser just succeeded?
2025-02-10 17:25:05 +0100 <dminuoso> euouae: Start by writing an instance Functor for that. Once done, give me a ping.
2025-02-10 17:24:27 +0100 <dminuoso> euouae: So imagine you have a simple 3-dimensional vector type: https://paste.tomsmeding.com/RshSBpbw
2025-02-10 17:23:16 +0100 <bwe> Actually you are right: I am solving the wrong problem. I should better introduce a dto intermediary and from that construct a unified result based on the results.
2025-02-10 17:23:08 +0100 <dminuoso> But even without ambient parser state, you could do this.
2025-02-10 17:22:22 +0100 <dminuoso> But it feels awkward and might not make sense if you some outer ambient parser state
2025-02-10 17:21:53 +0100 <dminuoso> Now you could write this for ParsecT too, that way you could do something like `let (b1, b2) = tup in try (refocus b1 $ ...) <|> try (refocus b2 $ ...)
2025-02-10 17:20:59 +0100 <dminuoso> This just swaps out the underlying buffer, runs the parser and then stitches the continuations together
2025-02-10 17:20:30 +0100 <dminuoso> So what I have is something like `refocus :: ByteString -> Get a -> Get a` where `Get` is just some type alias over a fancy parser type.
2025-02-10 17:19:45 +0100 <dminuoso> Lets ignore the fact that this is a very XY problem.
2025-02-10 17:18:57 +0100 <bwe> What I've got is that `Parser a` abstracts away the input that is `Text`. Therefore I conclude that I ought define another `ParserTuple a b` that abstracts away a tuple?
2025-02-10 17:17:32 +0100 <dminuoso> Absolutely, you can do what I do with megaparsec too.
2025-02-10 17:17:19 +0100 <bwe> …is this generally possible with Megaparsec?
2025-02-10 17:15:15 +0100 <dminuoso> There's this combinator I mentioned earlier that I have..
2025-02-10 17:15:06 +0100 <dminuoso> bwe: So I know how this could be done with flatparse...
2025-02-10 17:14:54 +0100jespada(~jespada@2800:a4:2243:2100:5cc9:2329:b53c:b25f) jespada
2025-02-10 17:13:27 +0100 <bwe> Tabular data. And at times stuff belonging into the second cell is being found in the first.
2025-02-10 17:12:37 +0100 <dminuoso> bwe: What does this tuple encode, exactly?
2025-02-10 17:12:13 +0100 <bwe> …and of course, I am referring to Megaparsec
2025-02-10 17:11:58 +0100 <bwe> for `Text` I define `Parser MyDataType`. But how do I parse for example a tuple `(Text, Text)`? I feel defining a function `:: (Text, Text) -> Maybe MyDataType` is not right because I can't combine it with other parsers easily. What's your take on it?
2025-02-10 17:11:40 +0100acidjnk_new3(~acidjnk@p200300d6e7283f99c4dbaee3a15423f1.dip0.t-ipconnect.de) (Ping timeout: 272 seconds)
2025-02-10 17:11:34 +0100alfiee(~alfiee@user/alfiee) (Ping timeout: 252 seconds)
2025-02-10 17:11:33 +0100lortabac(~lortabac@2a01:e0a:541:b8f0:55ab:e185:7f81:54a4) (Quit: WeeChat 4.4.2)
2025-02-10 17:09:23 +0100 <dminuoso> Otherwise you deprive yourself of the wonders of coming up with this yhourself.
2025-02-10 17:09:16 +0100 <euouae> learn fromsome real code
2025-02-10 17:09:13 +0100 <dminuoso> Perhaps try and derive this yohurself first.
2025-02-10 17:09:03 +0100 <euouae> i thought maybe to look into the microlens implementation too
2025-02-10 17:07:21 +0100alfiee(~alfiee@user/alfiee) alfiee
2025-02-10 17:07:02 +0100 <dminuoso> taught me lenses with.
2025-02-10 17:06:53 +0100 <dminuoso> (In fact, these are the very excercises that someone tought me with)
2025-02-10 17:06:45 +0100 <euouae> sure, i will look together with the book
2025-02-10 17:06:27 +0100 <dminuoso> If you are interested.
2025-02-10 17:06:06 +0100 <dminuoso> euouae: You can derive this yourself. I have a set of simple excercises where you could come up with how they work on your own.
2025-02-10 17:05:22 +0100 <dminuoso> That is, in optics you dont ever see any profunctors or some strange missing constraint when misusing the library