Logs: freenode/#haskell
| 2021-03-15 13:49:40 | × | codygman__ quits (~user@47.186.207.161) (Ping timeout: 265 seconds) |
| 2021-03-15 13:50:52 | × | royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Quit: Connection closed) |
| 2021-03-15 13:51:02 | → | zebrag joins (~inkbottle@aaubervilliers-654-1-101-29.w86-212.abo.wanadoo.fr) |
| 2021-03-15 13:51:12 | → | royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) |
| 2021-03-15 13:52:26 | → | Sgeo joins (~Sgeo@ool-18b98aa4.dyn.optonline.net) |
| 2021-03-15 13:54:08 | → | st8less joins (~st8less@inet-167-224-197-181.isp.ozarksgo.net) |
| 2021-03-15 13:54:13 | → | isson joins (1b7769ae@27.119.105.174) |
| 2021-03-15 13:54:41 | <isson> | thanks minoru_shirae |
| 2021-03-15 13:54:41 | <isson> | test = f id |
| 2021-03-15 13:54:42 | <isson> | f :: (a -> b -> c) -> String |
| 2021-03-15 13:54:42 | <isson> | f g = "test" |
| 2021-03-15 13:54:43 | <isson> | it compiles successfully. |
| 2021-03-15 13:54:43 | <isson> | id have a type a -> a |
| 2021-03-15 13:54:44 | <isson> | but f have a type it's first argument is (a -> b -> c) |
| 2021-03-15 13:54:44 | × | isson quits (1b7769ae@27.119.105.174) (Killed (Sigyn (Spam is off topic on freenode.))) |
| 2021-03-15 13:55:49 | → | carlomagno joins (~cararell@148.87.23.6) |
| 2021-03-15 13:57:02 | <mouseghost> | cant "g" be very well (a -> b -> c) ? |
| 2021-03-15 13:57:05 | <geekosaur> | which becomes (b -> c) -> (b -> c) |
| 2021-03-15 13:57:59 | × | elfets quits (~elfets@ip-37-201-23-96.hsi13.unitymediagroup.de) (Ping timeout: 256 seconds) |
| 2021-03-15 13:58:15 | × | jumper149 quits (~jumper149@ip185225.wh.uni-hannover.de) (Quit: WeeChat 3.1) |
| 2021-03-15 13:58:32 | → | qwerty2o joins (~qwerty2o@138.199.52.69) |
| 2021-03-15 13:58:46 | <geekosaur> | which can also be written (b -> c) -> b -> c which matches a -> b -> c |
| 2021-03-15 13:59:00 | <geekosaur> | (that is, a is found to be b -> c) |
| 2021-03-15 14:00:07 | × | xff0x quits (~xff0x@2001:1a81:52b7:0:73fe:50f7:6050:551e) (Ping timeout: 272 seconds) |
| 2021-03-15 14:00:20 | <jess> | that looks like an accidental spam kline |
| 2021-03-15 14:00:38 | <jess> | i've removed it |
| 2021-03-15 14:00:51 | → | xff0x joins (~xff0x@2001:1a81:52b7:0:8b9f:ee81:7bdc:f7e8) |
| 2021-03-15 14:01:00 | × | geekosaur quits (ac3a3c95@172.58.60.149) (Quit: Connection closed) |
| 2021-03-15 14:02:33 | × | Mrbuck quits (~Mrbuck@gateway/tor-sasl/mrbuck) (Quit: WeeChat 2.8) |
| 2021-03-15 14:03:47 | <__minoru__shirae> | isson, I was thinking about what happens to fmap when you translate regular functions to kleisli arrows, it was not related to your question, but if you found it useful, that's even better |
| 2021-03-15 14:09:58 | × | chirpsalot quits (~Chirps@pool-98-115-239-235.phlapa.fios.verizon.net) (Quit: WeeChat 1.9.1) |
| 2021-03-15 14:09:58 | × | Chobbes quits (~Chobbes@pool-98-115-239-235.phlapa.fios.verizon.net) (Quit: WeeChat 1.9.1) |
| 2021-03-15 14:10:04 | → | DTZUZU joins (~DTZUZO@205.ip-149-56-132.net) |
| 2021-03-15 14:10:31 | → | chirpsalot joins (~Chirps@pool-98-115-239-235.phlapa.fios.verizon.net) |
| 2021-03-15 14:10:35 | → | Chobbes joins (~Chobbes@pool-98-115-239-235.phlapa.fios.verizon.net) |
| 2021-03-15 14:11:47 | → | yangby joins (~secret@115.199.177.193) |
| 2021-03-15 14:11:57 | × | yangby quits (~secret@115.199.177.193) (Client Quit) |
| 2021-03-15 14:12:38 | × | DTZUZU_ quits (~DTZUZO@207.81.119.43) (Ping timeout: 264 seconds) |
| 2021-03-15 14:14:46 | <hololeap> | fmap' :: Monad m => (a -> m b) -> f a -> m (f b) |
| 2021-03-15 14:15:58 | <hololeap> | :t mapM |
| 2021-03-15 14:16:00 | <lambdabot> | (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) |
| 2021-03-15 14:16:29 | <hololeap> | __minoru__shirae: i think fmap would translate to mapM |
| 2021-03-15 14:16:57 | <hololeap> | maybe not quite... |
| 2021-03-15 14:17:08 | × | ukari quits (~ukari@unaffiliated/ukari) (Ping timeout: 245 seconds) |
| 2021-03-15 14:18:46 | <hololeap> | although that is interesting that fmap in a kleisli category looks _very_ similar to mapM |
| 2021-03-15 14:20:02 | <__minoru__shirae> | I think fmap would translate to nested monads, so that if you call join on them they would become one layer |
| 2021-03-15 14:20:28 | <__minoru__shirae> | there is a definition of bind in terms of fmap and join |
| 2021-03-15 14:20:59 | × | DataComputist quits (~lumeng@50.43.26.251) (Quit: Leaving...) |
| 2021-03-15 14:21:16 | → | epstein joins (~dwsjeid91@193.27.14.71) |
| 2021-03-15 14:21:26 | → | Jd007 joins (~Jd007@162.156.11.151) |
| 2021-03-15 14:22:44 | dminuoso_ | is now known as dminuoso |
| 2021-03-15 14:23:17 | <__minoru__shirae> | I forgot that you can define a monad using only the definitions of return and join |
| 2021-03-15 14:24:13 | <__minoru__shirae> | so monad is something like a weird joinable functor |
| 2021-03-15 14:24:50 | × | dminuoso quits (~dminuoso@static.88-198-218-68.clients.your-server.de) (Changing host) |
| 2021-03-15 14:24:50 | → | dminuoso joins (~dminuoso@unaffiliated/dminuoso) |
| 2021-03-15 14:24:58 | → | vBm1 joins (~vBm@195.140.213.38) |
| 2021-03-15 14:25:23 | <dminuoso> | __minoru__shirae: To make a slight connection to a common joke, there's a monoid here! |
| 2021-03-15 14:25:35 | × | aarvar quits (~foewfoiew@2601:602:a080:fa0:6cfb:c91f:3c9a:a8cb) (Ping timeout: 240 seconds) |
| 2021-03-15 14:25:46 | <dminuoso> | This act of "joining" can be thought of as "combining" layers - and that happens to be monoidal (with all the laws) |
| 2021-03-15 14:26:43 | × | qwerty2o quits (~qwerty2o@138.199.52.69) (Ping timeout: 245 seconds) |
| 2021-03-15 14:27:03 | <dminuoso> | https://gist.github.com/dminuoso/d5ab4ba5d8a5142dde9f4d4c736e3ecb |
| 2021-03-15 14:27:08 | <__minoru__shirae> | dminuoso: what's the identity of that monoid? I mean, mempty |
| 2021-03-15 14:27:22 | ← | jakalx parts (~jakalx@base.jakalx.net) ("Error from remote client") |
| 2021-03-15 14:27:34 | → | heatsink joins (~heatsink@2600:1700:bef1:5e10:7c0e:3b57:dfb:2cb4) |
| 2021-03-15 14:27:38 | <__minoru__shirae> | Identity monad? |
| 2021-03-15 14:27:39 | <dminuoso> | __minoru__shirae: the layer introduced by return. |
| 2021-03-15 14:27:46 | <dminuoso> | __minoru__shirae: Checkout my gist, I made some drawings even |
| 2021-03-15 14:28:11 | <dminuoso> | Note that :.: is type level composition. That is `(T :.: T) a` is isomorphic to `T (T a)` |
| 2021-03-15 14:28:38 | <dminuoso> | That helps you realize that `Monad` is really *just* about the these `T` layers, not the `a` |
| 2021-03-15 14:29:08 | × | LKoen quits (~LKoen@194.250.88.92.rev.sfr.net) (Quit: “It’s only logical. First you learn to talk, then you learn to think. Too bad it’s not the other way round.”) |
| 2021-03-15 14:30:06 | → | cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net) |
| 2021-03-15 14:30:33 | → | ukari joins (~ukari@unaffiliated/ukari) |
| 2021-03-15 14:31:20 | <__minoru__shirae> | hey, those are monad laws |
| 2021-03-15 14:31:53 | <dminuoso> | Cute, isnt it? :) |
| 2021-03-15 14:32:26 | × | heatsink quits (~heatsink@2600:1700:bef1:5e10:7c0e:3b57:dfb:2cb4) (Ping timeout: 264 seconds) |
| 2021-03-15 14:33:07 | <__minoru__shirae> | I've read in some article lately, that monad laws are a specialization of some more general laws - category laws |
| 2021-03-15 14:33:19 | <dminuoso> | Well they can be stated as category laws too |
| 2021-03-15 14:33:35 | <__minoru__shirae> | so, in the category of functions, you have the same laws for functions |
| 2021-03-15 14:33:46 | <__minoru__shirae> | in the category of functors - the same |
| 2021-03-15 14:33:54 | <__minoru__shirae> | and for monads you have monad laws |
| 2021-03-15 14:34:53 | <__minoru__shirae> | so, we have functions, lifted functions and kleisli arrows |
| 2021-03-15 14:35:06 | <dminuoso> | Roughly, and this is with a bit of handwaving, a third way of expressing the above (monoid and/or monad laws) is this: |
| 2021-03-15 14:35:07 | <__minoru__shirae> | or we have regular values, functors and monads |
| 2021-03-15 14:35:13 | <dminuoso> | Kleisli composition is associative |
| 2021-03-15 14:35:38 | <dminuoso> | that is: (f >=> g) >=> h === f >=> (g >=> h) |
| 2021-03-15 14:35:48 | <dminuoso> | And `return` is both left and right identity for (>=>) |
| 2021-03-15 14:35:59 | <dminuoso> | They're all equivalent |
| 2021-03-15 14:36:01 | → | jayok joins (~jayok@cpc147358-belf12-2-0-cust581.2-1.cable.virginm.net) |
| 2021-03-15 14:36:36 | <dminuoso> | The interface of `=<<` has very quirky and non-elegant laws. But we have =<< because it has the right ergonomics for us as a programmer most of the time |
| 2021-03-15 14:36:44 | <__minoru__shirae> | I'm waiting for something to "click" in my head, but maybe there is nothing to click, there is just an equivalence and that's all |
| 2021-03-15 14:36:50 | <dminuoso> | That's fine, really |
| 2021-03-15 14:37:02 | <dminuoso> | Perhaps, think of associativity of having the following relevant impact: |
| 2021-03-15 14:37:14 | <dminuoso> | Say you're writing some code in do-notation |
| 2021-03-15 14:37:41 | <dminuoso> | do { f <- x; g f; h f; pure (i f) } |
| 2021-03-15 14:37:59 | <dminuoso> | Then associativity says floating any fragment out into a separate binding does not alter meaning |
| 2021-03-15 14:38:31 | <dminuoso> | So `let c t = g t >> h t in do { f <- x; c f; pure (i f) }` is the same thing |
| 2021-03-15 14:39:05 | <dminuoso> | As long as monad laws hold, you can refactor into bindings (changing how things associate implicitly) without altering meaning |
| 2021-03-15 14:39:19 | <dminuoso> | And this holds regardless of the monad |
| 2021-03-15 14:39:36 | <dminuoso> | So say for `IO`, the following two pieces have the same meaning: |
| 2021-03-15 14:40:18 | <dminuoso> | % let f = putStr "Hello" >> putStr " World" in f >> (putStrLn ", Frank") |
All times are in UTC.