Newest at the top
2024-05-31 15:17:41 +0200 | danse-nr3 | (~danse-nr3@151.19.228.85) (Ping timeout: 240 seconds) |
2024-05-31 15:06:43 +0200 | [exa] | (~exa@user/exa/x-3587197) (Ping timeout: 256 seconds) |
2024-05-31 15:04:43 +0200 | destituion | (~destituio@2a02:2121:28c:be84:309e:b5ea:1c6b:9320) |
2024-05-31 15:04:30 +0200 | danse-nr3 | (~danse-nr3@151.19.228.85) |
2024-05-31 15:03:58 +0200 | danse-nr3 | (~danse-nr3@151.57.225.167) (Read error: Connection reset by peer) |
2024-05-31 15:03:15 +0200 | <lxsameer> | Thank you |
2024-05-31 15:03:13 +0200 | <sshine> | also, I apologize for the mixture of camelCase and snake_case :-D I didn't write Haskell for a long time and my brain apparently defaults to snake_case now. |
2024-05-31 15:02:01 +0200 | <sshine> | lxsameer, a bit of the point is lost when FibReader is so specialized towards the function it runs over, since it's not reusable in other monadic contexts. |
2024-05-31 15:01:11 +0200 | <sshine> | lxsameer, you wouldn't do the last thing unless you're following some course that asks you to reconstruct monads from the bottom up to get a better understanding. |
2024-05-31 15:00:53 +0200 | <sshine> | lxsameer, https://play.haskell.org/saved/zpN4C4Zk -- I made two more examples, one more that uses mtl Reader, and another that defines a custom Reader that doesn't parameterise the 'r' argument and is explicit about what's going on. |
2024-05-31 14:56:34 +0200 | cfricke | (~cfricke@user/cfricke) |
2024-05-31 14:51:45 +0200 | xdminsy | (~xdminsy@117.147.70.212) |
2024-05-31 14:44:51 +0200 | rosco | (~rosco@90.58.221.226) |
2024-05-31 14:44:07 +0200 | Feuermagier | (~Feuermagi@user/feuermagier) |
2024-05-31 14:42:44 +0200 | cfricke | (~cfricke@user/cfricke) (Ping timeout: 260 seconds) |
2024-05-31 14:41:23 +0200 | destituion | (~destituio@85.221.111.174) (Ping timeout: 264 seconds) |
2024-05-31 14:39:46 +0200 | <lxsameer> | sshine: thank you |
2024-05-31 14:21:37 +0200 | <sshine> | lxsameer, https://play.haskell.org/saved/nnUbuaAA -- I don't know if this is a good example. |
2024-05-31 14:14:19 +0200 | xff0x | (~xff0x@2405:6580:b080:900:75ce:7dd6:5a9:4d8a) |
2024-05-31 14:12:39 +0200 | <lxsameer> | thanks for you time and clarifications |
2024-05-31 14:12:29 +0200 | <lxsameer> | I have to read it more |
2024-05-31 14:12:22 +0200 | <lxsameer> | I think I got it :P |
2024-05-31 14:12:14 +0200 | zer0bitz | (~zer0bitz@user/zer0bitz) (Ping timeout: 256 seconds) |
2024-05-31 14:12:13 +0200 | <lxsameer> | ah got it |
2024-05-31 14:12:02 +0200 | <ncf> | m :: ((->) XConf) XConf |
2024-05-31 14:11:40 +0200 | <lxsameer> | and the compiler would know what implementation of `ask` to use because `m :: XConf` right? |
2024-05-31 14:11:30 +0200 | <ncf> | runX is just doing this with a few newtype wrappers in between (and more monads in the stack) |
2024-05-31 14:11:03 +0200 | <ncf> | the actual value of c isn't determined until i actually run m by applying it to an XConf |
2024-05-31 14:10:35 +0200 | <ncf> | so, if i write something like `m = (do c <- ask; return c) :: XConf -> XConf`, i am describing a computation that takes an XConf and just returns it unchanged |
2024-05-31 14:09:25 +0200 | <ncf> | ask :: XConf -> XConf is just the identity function |
2024-05-31 14:09:06 +0200 | <ncf> | (>>=) :: (XConf -> a) -> (a -> XConf -> b) -> XConf -> b chains computations together by duplicating the environment |
2024-05-31 14:08:59 +0200 | ddellacosta | (~ddellacos@ool-44c73d29.dyn.optonline.net) (Ping timeout: 264 seconds) |
2024-05-31 14:08:27 +0200 | <ncf> | return :: a -> XConf -> a is just the `const` function that ignores the XConf argument |
2024-05-31 14:08:21 +0200 | zer0bitz_ | (~zer0bitz@user/zer0bitz) |
2024-05-31 14:08:01 +0200 | <ncf> | this is a monad that describes computations that *depend* on a global environment value of type XConf, i.e. aren't fully determined until you give them an XConf |
2024-05-31 14:07:28 +0200 | <ncf> | maybe it would help to think about the native reader monad, ((->) XConf) |
2024-05-31 14:06:15 +0200 | <lxsameer> | so that's why I'm confused then |
2024-05-31 14:06:08 +0200 | <lxsameer> | ahhhhhh |
2024-05-31 14:05:47 +0200 | <ncf> | no! |
2024-05-31 14:05:44 +0200 | <lxsameer> | runX in the catchX? |
2024-05-31 14:05:25 +0200 | <ncf> | the environment provided to runX |
2024-05-31 14:05:01 +0200 | <lxsameer> | but where does ask takes the value from? |
2024-05-31 14:04:49 +0200 | <lxsameer> | getChar reads from stdin for example |
2024-05-31 14:04:34 +0200 | <lxsameer> | ncf: i understand that part but |
2024-05-31 14:04:11 +0200 | <ncf> | this is only determined when you actually run the catchX call, so when you call runX on some action that uses catchX |
2024-05-31 14:03:48 +0200 | <ncf> | so in the same way, the value of c here is the result of the "ask" action |
2024-05-31 14:03:34 +0200 | <ncf> | right |
2024-05-31 14:03:28 +0200 | <lxsameer> | ther result of getChar action |
2024-05-31 14:03:11 +0200 | <ncf> | lxsameer: think about IO; if i write `do c <- getChar; print c`, what value does c have? |
2024-05-31 14:02:51 +0200 | <ncf> | or irrelevant |