2024/04/29

Newest at the top

2024-04-29 18:52:35 +0200tri(~tri@ool-18bbef1a.static.optonline.net) (Ping timeout: 260 seconds)
2024-04-29 18:52:15 +0200 <gaff> Consider the following example. you are writing a bunch of parser combinators, and many of these combinators use `get` and `put`. Is that circumventing the State monad?
2024-04-29 18:52:07 +0200 <ncf> i mean you are asking for a general yes/no answer to something that is essentially a value judgement (bookkeeping) and highly context-dependent
2024-04-29 18:50:28 +0200 <gaff> ncf: I am not really clear what you meant there.
2024-04-29 18:49:44 +0200 <ncf> but other than that get and put are just part of the normal State interface
2024-04-29 18:49:14 +0200 <ncf> if you end up using get and put in between every function call then i would say you are bookkeeping and defeating the purpose of State
2024-04-29 18:48:55 +0200justsomeguy(~justsomeg@user/justsomeguy)
2024-04-29 18:48:26 +0200 <ncf> that's not a well-defined concept, just a vibe
2024-04-29 18:47:57 +0200tri(~tri@ool-18bbef1a.static.optonline.net)
2024-04-29 18:47:53 +0200 <gaff> ncf: well, I want to be clear about what is state "bookkeeping" (which you would have to do if you didn't use the State monad) vs the use of these functions `get` and `put`.
2024-04-29 18:47:50 +0200Lears(~Leary]@user/Leary/x-0910699) (Remote host closed the connection)
2024-04-29 18:47:11 +0200noumenon(~noumenon@113.51-175-156.customer.lyse.net) (Quit: Leaving)
2024-04-29 18:46:46 +0200 <EvanR> I say*
2024-04-29 18:46:39 +0200 <EvanR> you say boilerplate and say can you move the boilerplate to a function which can be called
2024-04-29 18:46:38 +0200 <geekosaur> the state monad would be pretty useless if you couldn't access or update the state
2024-04-29 18:45:33 +0200 <ncf> why else would they be exported
2024-04-29 18:45:10 +0200 <ncf> sure
2024-04-29 18:44:26 +0200rvalue(~rvalue@user/rvalue)
2024-04-29 18:44:25 +0200 <gaff> ncf: thanks. I know. But i am asking that structure I presented, or more generally the use of `get` and `put`, are expected monadic operations in code dealing with the State monad?
2024-04-29 18:43:56 +0200rvalue(~rvalue@user/rvalue) (Read error: Connection reset by peer)
2024-04-29 18:42:34 +0200remedan(~remedan@ip-78-102-118-253.bb.vodafone.cz)
2024-04-29 18:42:11 +0200 <ncf> f = state g
2024-04-29 18:41:52 +0200 <lambdabot> MonadState s m => (s -> (a, s)) -> m a
2024-04-29 18:41:51 +0200 <ncf> :t state
2024-04-29 18:41:50 +0200 <ncf> in that specific case you could perhaps just use `state`
2024-04-29 18:41:24 +0200jumper149(~jumper149@base.felixspringer.xyz) (Quit: WeeChat 4.2.1)
2024-04-29 18:40:09 +0200 <gaff> here is an example: `f = do { s <- get; let (a, b) = g s; put b; return a }` and similar stuff in perhaps other functions as well.
2024-04-29 18:39:53 +0200gmg(~user@user/gehmehgeh)
2024-04-29 18:39:52 +0200stiell_(~stiell@gateway/tor-sasl/stiell)
2024-04-29 18:39:38 +0200chiselfuse(~chiselfus@user/chiselfuse)
2024-04-29 18:38:47 +0200stiell_(~stiell@gateway/tor-sasl/stiell) (Remote host closed the connection)
2024-04-29 18:38:46 +0200chiselfuse(~chiselfus@user/chiselfuse) (Read error: Connection reset by peer)
2024-04-29 18:38:46 +0200gmg(~user@user/gehmehgeh) (Remote host closed the connection)
2024-04-29 18:38:13 +0200 <ncf> i don't know how i'm supposed to answer that without seeing any code!
2024-04-29 18:38:07 +0200lortabac(~lortabac@2a01:e0a:541:b8f0:55ab:e185:7f81:54a4) (Ping timeout: 255 seconds)
2024-04-29 18:36:20 +0200 <gaff> ncf: that repeated use of `get` and `put` in functions involved wouldn't be considered "state bookkeeping" boilerplate code then?
2024-04-29 18:34:57 +0200 <ncf> gaff: sure, if that's the API you're using
2024-04-29 18:31:33 +0200 <ncf> famubu: rep should only parse {n,m} and return the function \r -> Rep r n m
2024-04-29 18:29:51 +0200 <gaff> Using the State monad helps in threading the state through computations behind the scenes, but you will/may still need to use get and put in individual functions involved, right?
2024-04-29 18:29:12 +0200 <ncf> it's a postfix operator
2024-04-29 18:28:10 +0200tzh(~tzh@c-73-164-206-160.hsd1.or.comcast.net)
2024-04-29 18:27:59 +0200remedan(~remedan@ip-78-102-118-253.bb.vodafone.cz) (Quit: Bye!)
2024-04-29 18:27:31 +0200 <famubu> This is what I got now: https://bpa.st/XOWA
2024-04-29 18:26:57 +0200 <famubu> Hi again. I am trying to write a regex parser with megaparsec. Am trying to make a parser to deal with `r{2,3}` where the corresponding constructor is `Rep Re Integer Integer`. How would I do this using operator table? I guess we need the parser to take a regex and 2 integers as argument? But all arguments need to be same type, right? Then that isn't it, right?
2024-04-29 18:24:29 +0200euleritian(~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de)
2024-04-29 18:24:12 +0200euleritian(~euleritia@dynamic-176-007-169-212.176.7.pool.telefonica.de) (Read error: Connection reset by peer)
2024-04-29 18:23:50 +0200euleritian(~euleritia@dynamic-176-007-169-212.176.7.pool.telefonica.de)
2024-04-29 18:23:46 +0200gaff(~gaff@49.207.216.126)
2024-04-29 18:23:44 +0200euleritian(~euleritia@ip4d16fc38.dynamic.kabel-deutschland.de) (Read error: Connection reset by peer)
2024-04-29 18:23:43 +0200lortabac(~lortabac@2a01:e0a:541:b8f0:55ab:e185:7f81:54a4)