2025/01/31

Newest at the top

2025-01-31 02:02:24 +0100joeyadams(~joeyadams@syn-184-054-105-097.res.spectrum.com) (Quit: Leaving)
2025-01-31 02:01:09 +0100merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 246 seconds)
2025-01-31 01:56:47 +0100merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn
2025-01-31 01:56:40 +0100rstromlund(~user@user/rstromlund) (Ping timeout: 265 seconds)
2025-01-31 01:56:36 +0100alfiee(~alfiee@user/alfiee) (Ping timeout: 246 seconds)
2025-01-31 01:54:15 +0100xff0x(~xff0x@2405:6580:b080:900:704:c9bd:a645:9b1d) (Ping timeout: 276 seconds)
2025-01-31 01:53:06 +0100acidjnk_new3(~acidjnk@p200300d6e7283f4679216c0ad7f4b91d.dip0.t-ipconnect.de) (Ping timeout: 246 seconds)
2025-01-31 01:52:41 +0100 <lambdabot> f a b = a (\ c -> c b)
2025-01-31 01:52:40 +0100 <int-e> @djinn ((((a -> r) -> r) -> r) -> r) -> (a -> r) -> r
2025-01-31 01:52:28 +0100alfiee(~alfiee@user/alfiee) alfiee
2025-01-31 01:51:47 +0100rstromlund(~user@user/rstromlund) rstromlund
2025-01-31 01:51:10 +0100 <dminuoso> Anyway. This was just meant as a teaser.
2025-01-31 01:50:58 +0100 <dminuoso> euouae: This is an alternate description of (>>=), and it perhaps visualizes nicely that there's a sort of composition idea going on.
2025-01-31 01:50:03 +0100 <yahb2> join :: Monad m => m (m a) -> m a
2025-01-31 01:50:03 +0100 <dminuoso> % :t join
2025-01-31 01:50:01 +0100 <yahb2> <no output>
2025-01-31 01:50:01 +0100 <dminuoso> % import Control.Monad
2025-01-31 01:49:55 +0100 <yahb2> <interactive>:1:1: error: [GHC-88464] Variable not in scope: join
2025-01-31 01:49:55 +0100 <dminuoso> % :t join
2025-01-31 01:49:18 +0100 <dminuoso> Just keep that thought mind for the future
2025-01-31 01:48:53 +0100 <dminuoso> euouae: One last thing: That "funky composition" you talked about, that's where the monad lies. :-)
2025-01-31 01:48:52 +0100mange(~user@user/mange) mange
2025-01-31 01:46:30 +0100monochrmmonochrom
2025-01-31 01:46:29 +0100monochrom(trebla@216.138.220.146) (Ping timeout: 260 seconds)
2025-01-31 01:46:00 +0100merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 252 seconds)
2025-01-31 01:45:55 +0100 <euouae> But your example is very helpful, to keep in mind pure computation / IO stuff inside parsing
2025-01-31 01:45:40 +0100 <euouae> I think my composable state machine intuition is running into trouble with StateT. Transformers seem like a different beast, I'll have to think about it more.
2025-01-31 01:45:16 +0100monochrm(trebla@216.138.220.146)
2025-01-31 01:44:32 +0100 <euouae> I'm going to assume that it'll leak out the details of try
2025-01-31 01:44:15 +0100 <euouae> right
2025-01-31 01:43:29 +0100 <dminuoso> (Assuming you use `try` of course)
2025-01-31 01:43:15 +0100 <dminuoso> You can also use `ParsecT e s IO`, then you can suddenly do `liftIO (putStrLn "Hello world")` in the middle of your parser. Note, that because megaparsec will do backtracking this will have some interesting/strange behavior... which is non-determinism in fact.
2025-01-31 01:42:13 +0100 <dminuoso> type Parsec e s = ParsecT e s Identity
2025-01-31 01:42:06 +0100 <dminuoso> https://hackage.haskell.org/package/megaparsec-9.7.0/docs/Text-Megaparsec.html#t:Parsec
2025-01-31 01:41:46 +0100 <dminuoso> If you dont want IO, you can just layer it over `Identity`, which is sort of the "does nothing monad", giving you just the parsing effects.
2025-01-31 01:41:25 +0100merijn(~merijn@host-vr.cgnat-g.v4.dfn.nl) merijn
2025-01-31 01:41:14 +0100 <dminuoso> The reason you can do this, is because all this parsing effect is in a transformer ParsecT which you can layer over any other monad.
2025-01-31 01:40:55 +0100 <dminuoso> If you use it together with IO, you can interleave your parser with IO - say print statements or database calls
2025-01-31 01:40:29 +0100 <dminuoso> euouae: Your megaparsec parser can run either in pure mode, or it can run together with IO.
2025-01-31 01:40:04 +0100 <dminuoso> euouae: Lets pick a more concrete examplee:
2025-01-31 01:39:17 +0100 <dminuoso> ANd you can layer it over IO to have state, non-determinism, exceptions and real world nuclear missile effects.
2025-01-31 01:39:00 +0100 <dminuoso> And if you add ListT (which adds non-determinism), you could have non-determinism, state and exceptions
2025-01-31 01:38:35 +0100 <dminuoso> Them being transformers means you can layer them ontop of each other, giving you a Monad that has both state *and* exceptions.
2025-01-31 01:38:33 +0100 <geekosaur> so, StateT doesn't just model state; it adds state to something. It transforms something else by adding state to it
2025-01-31 01:38:20 +0100 <dminuoso> euouae: StateT allows you to drag some state around, while ExceptT allows you to throw exceptions.
2025-01-31 01:37:55 +0100 <dminuoso> THat may or may not make any sense to you.
2025-01-31 01:37:53 +0100 <euouae> With a State I know I have a 'state processor' and an 'output value' but what is the transformer for?
2025-01-31 01:37:49 +0100 <dminuoso> euouae: If we think of Monads not as "state" but as some generalized idea of effects, then transformers lets us combine different effects.
2025-01-31 01:37:24 +0100 <euouae> but what is transformer?
2025-01-31 01:37:19 +0100 <euouae> yup. thank you