Logs: liberachat/#haskell
| 2021-06-10 21:59:36 | → | Erutuon joins (~Erutuon@user/erutuon) |
| 2021-06-10 22:02:44 | × | azeem quits (~azeem@dynamic-adsl-94-34-34-125.clienti.tiscali.it) (Read error: Connection reset by peer) |
| 2021-06-10 22:03:05 | bah_ | is now known as bah |
| 2021-06-10 22:05:35 | → | killsushi joins (~killsushi@user/killsushi) |
| 2021-06-10 22:06:19 | × | thyriaen__ quits (~thyriaen@45.178.73.238) (Remote host closed the connection) |
| 2021-06-10 22:06:30 | → | thyriaen__ joins (~thyriaen@45.178.73.238) |
| 2021-06-10 22:07:41 | × | michalz quits (~michalz@185.246.204.126) (Remote host closed the connection) |
| 2021-06-10 22:07:42 | <hugo> | Hi! Am I correct in my understanding of Lenses that a Prism can't (properly) focus a single element of a list, and I need traversals for that? |
| 2021-06-10 22:08:01 | <hugo> | I'm trying to focus the first element of a stack which matches a given predicate |
| 2021-06-10 22:09:02 | × | sayola quits (~vekto@dslc-082-082-145-205.pools.arcor-ip.net) (Read error: Connection reset by peer) |
| 2021-06-10 22:09:19 | → | Profpatsch joins (~Profpatsc@static.88-198-193-255.clients.your-server.de) |
| 2021-06-10 22:09:32 | → | lavaman joins (~lavaman@98.38.249.169) |
| 2021-06-10 22:10:06 | <shachaf> | A prism is like a constructor, so it can construct. |
| 2021-06-10 22:10:25 | <shachaf> | So something like a traversal is probably what you want. |
| 2021-06-10 22:10:29 | × | gehmehgeh quits (~user@user/gehmehgeh) (Quit: Leaving) |
| 2021-06-10 22:11:07 | <Profpatsch> | Which is more performant: Map.foldMapWithKey (\key val -> Map.singleton (f key) (g val) or Map.foldlWithKey' (\m key val -> Map.insert (f key) (f val) m) |
| 2021-06-10 22:11:27 | → | BosonCollider joins (~olofs@90-227-86-119-no542.tbcn.telia.com) |
| 2021-06-10 22:11:29 | <Profpatsch> | (typed from the top of my head, so sorry if it doesn’t typechecks |
| 2021-06-10 22:11:38 | <hugo> | shachaf: Given the right closue I can construct any list through a given function ;) |
| 2021-06-10 22:11:50 | × | codedmart quits (~codedmart@li335-49.members.linode.com) (Quit: ZNC 1.7.5+deb4 - https://znc.in) |
| 2021-06-10 22:12:08 | <Profpatsch> | I’d expect the right to build less thunks and be relatively in-place |
| 2021-06-10 22:12:12 | → | codedmart joins (codedmart@2600:3c01::f03c:92ff:fefe:8511) |
| 2021-06-10 22:12:12 | <shachaf> | Well, what I mean is, if you have a type like data T = Foo A | Bar B | ..., a prism is like Foo or Bar. |
| 2021-06-10 22:12:19 | <hugo> | But a traversal (as you say) matches what I have found on my own |
| 2021-06-10 22:12:21 | × | Shaeto quits (~Shaeto@94.25.234.158) (Ping timeout: 272 seconds) |
| 2021-06-10 22:12:28 | <shachaf> | Which means you have a prism function : A -> T. |
| 2021-06-10 22:12:48 | <shachaf> | And if a T matches the Foo prism, then the A is the entirety of the contents of it. |
| 2021-06-10 22:13:38 | <hugo> | I think my confusion comes from the description of prisms as focusing "0 or 1 objects", which matches a find ((a -> Bool) -> [a] -> Maybe a) function |
| 2021-06-10 22:14:07 | × | lavaman quits (~lavaman@98.38.249.169) (Ping timeout: 244 seconds) |
| 2021-06-10 22:14:13 | <shachaf> | I think a lot of people end up with this confusion, so the documentation could maybe be improved. |
| 2021-06-10 22:14:15 | <hugo> | But as your last example, that doesn't allow a rewind, since the context is unknown at that point |
| 2021-06-10 22:15:16 | <hugo> | Most of the documentation in the different parts of the lens (https://hackage.haskell.org/package/lens-5.0.1/docs/Control-Lens.html) library have been of very little help, due to them expceting that I already understand everything |
| 2021-06-10 22:16:18 | → | Shaeto joins (~Shaeto@94.25.234.158) |
| 2021-06-10 22:16:30 | × | mastarija quits (~mastarija@31.217.22.43) (Quit: Leaving) |
| 2021-06-10 22:20:41 | × | eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:2121:a570:d35e:ba7a) (Remote host closed the connection) |
| 2021-06-10 22:21:20 | × | Shaeto quits (~Shaeto@94.25.234.158) (Ping timeout: 264 seconds) |
| 2021-06-10 22:21:24 | × | agumonke` quits (~user@88.163.231.79) (Read error: Connection reset by peer) |
| 2021-06-10 22:21:41 | → | jakalx joins (~jakalx@base.jakalx.net) |
| 2021-06-10 22:21:49 | → | agumonke` joins (~user@88.163.231.79) |
| 2021-06-10 22:24:56 | ← | delYsid parts (~user@84-115-55-45.cable.dynamic.surfer.at) (ERC (IRC client for Emacs 27.1.50)) |
| 2021-06-10 22:30:39 | → | eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:2121:a570:d35e:ba7a) |
| 2021-06-10 22:33:33 | → | fizbin joins (~fizbin@c-73-33-197-160.hsd1.nj.comcast.net) |
| 2021-06-10 22:34:19 | × | paddymahoney quits (~paddymaho@cpe9050ca207f83-cm9050ca207f80.cpe.net.cable.rogers.com) (Remote host closed the connection) |
| 2021-06-10 22:34:31 | → | Shaeto joins (~Shaeto@94.25.234.158) |
| 2021-06-10 22:36:45 | × | mikoto-chan quits (~mikoto-ch@ip-213-49-189-31.dsl.scarlet.be) (Ping timeout: 252 seconds) |
| 2021-06-10 22:37:51 | × | fizbin quits (~fizbin@c-73-33-197-160.hsd1.nj.comcast.net) (Ping timeout: 252 seconds) |
| 2021-06-10 22:38:57 | × | Shaeto quits (~Shaeto@94.25.234.158) (Ping timeout: 252 seconds) |
| 2021-06-10 22:40:03 | × | dhil quits (~dhil@80.208.56.181) (Ping timeout: 252 seconds) |
| 2021-06-10 22:41:23 | → | jmcarthur joins (~jmcarthur@c-73-29-224-10.hsd1.nj.comcast.net) |
| 2021-06-10 22:43:22 | × | econo quits (uid147250@user/econo) (Quit: Connection closed for inactivity) |
| 2021-06-10 22:43:39 | → | Shaeto joins (~Shaeto@94.25.234.158) |
| 2021-06-10 22:48:18 | × | Shaeto quits (~Shaeto@94.25.234.158) (Ping timeout: 252 seconds) |
| 2021-06-10 22:49:32 | → | abhixec joins (~abhixec@c-67-169-139-16.hsd1.ca.comcast.net) |
| 2021-06-10 22:49:40 | × | altern quits (~Sergii@altern.corbina.com.ua) (Ping timeout: 272 seconds) |
| 2021-06-10 22:52:46 | → | Shaeto joins (~Shaeto@94.25.234.158) |
| 2021-06-10 22:53:23 | × | jmcarthur quits (~jmcarthur@c-73-29-224-10.hsd1.nj.comcast.net) (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
| 2021-06-10 22:54:03 | <zzz> | the syntax for strict record types is T = T { strict :: !Some , lazy :: Other ... } right? |
| 2021-06-10 22:54:26 | <geekosaur> | yes |
| 2021-06-10 22:54:26 | <janus> | monochrom: thanks for the link to your Cont monad piece, i am still working through it, very educational |
| 2021-06-10 22:55:08 | → | teaSlurper joins (~chris@81.96.113.213) |
| 2021-06-10 22:56:17 | × | xff0x_ quits (~xff0x@2001:1a81:5309:4200:5885:4f5d:c0ef:4e6d) (Remote host closed the connection) |
| 2021-06-10 22:56:28 | <janus> | is there any point in writing a manual MonadReader MyType instance? i almost always see it derived |
| 2021-06-10 22:56:34 | → | xff0x_ joins (~xff0x@2001:1a81:5309:4200:43f:9f66:b597:77c7) |
| 2021-06-10 22:57:20 | <geekosaur> | only if you're diretly implementing it (something like ReaderT or RWST) |
| 2021-06-10 22:57:38 | × | abhixec quits (~abhixec@c-67-169-139-16.hsd1.ca.comcast.net) (Quit: leaving) |
| 2021-06-10 22:57:42 | <janus> | what the alternative to "directly implementing" it? |
| 2021-06-10 22:57:51 | → | abhixec joins (~abhixec@c-67-169-139-16.hsd1.ca.comcast.net) |
| 2021-06-10 22:57:52 | × | Shaeto quits (~Shaeto@94.25.234.158) (Ping timeout: 268 seconds) |
| 2021-06-10 22:57:56 | × | Erutuon quits (~Erutuon@user/erutuon) (Quit: WeeChat 2.8) |
| 2021-06-10 22:58:47 | <geekosaur> | usually when it's derived, it's via GND to expose an underlying MonadReader |
| 2021-06-10 22:59:50 | <janus> | right. so let's say i have some App context which is a record with a single destructor, then people need GeneralizedNewtypeDeriving to derive MonadReader for that? |
| 2021-06-10 23:00:00 | <geekosaur> | there's little point to writing those by hand because they're mechanical and there's only one way to do it |
| 2021-06-10 23:00:03 | → | sh9 joins (~sh9@softbank060116136158.bbtec.net) |
| 2021-06-10 23:00:48 | <janus> | but why does it say Newtype if it is a record ... hmmm ... does it only work if the App Monad is a newtype and not a record? |
| 2021-06-10 23:00:51 | × | eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:2121:a570:d35e:ba7a) (Remote host closed the connection) |
| 2021-06-10 23:00:52 | <geekosaur> | right, but GND is one of those extensions that practically everyone turns on (and was even present in other Haskell implementations back when there were others) |
| 2021-06-10 23:01:27 | <janus> | how does the record contents need to look for GND to be able to derive MonadReader? |
| 2021-06-10 23:01:37 | <geekosaur> | yes, your App would be a newtype over a ReaderT YourAppState |
| 2021-06-10 23:01:53 | → | Shaeto joins (~Shaeto@94.25.234.158) |
| 2021-06-10 23:02:31 | <janus> | but then, if it is a stack of monads, will it still be able to derive it if ReaderT is not the outermost? |
| 2021-06-10 23:02:50 | <geekosaur> | if for some reason you got the way of using a data, you would indeed ned to write your own MonadReader instance; there's little point in doing so when you can newtype over the provided one instead |
| 2021-06-10 23:03:01 | → | eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:2121:a570:d35e:ba7a) |
| 2021-06-10 23:03:22 | <shachaf> | hugo: Yes, I meant to write up a nice introduction a long time ago but I never did. |
| 2021-06-10 23:04:48 | <janus> | ok i will try to use a newtype instead, sounds advantageous. |
| 2021-06-10 23:06:27 | × | Shaeto quits (~Shaeto@94.25.234.158) (Ping timeout: 252 seconds) |
| 2021-06-10 23:07:00 | × | agumonke` quits (~user@88.163.231.79) (Ping timeout: 252 seconds) |
| 2021-06-10 23:09:37 | <ski> | janus : would the `App' context be the monad, or the environment that's to be accessed via `MonadReader' ? |
| 2021-06-10 23:11:00 | → | Shaeto joins (~Shaeto@94.25.234.158) |
| 2021-06-10 23:12:50 | <janus> | ski: the when i say App, it is the monad that everything is working in, and that i wish to implement MonadReader for. the data that is read is just a record. so in the signature "MonadReader r m", the r is my record, let's call it MyEnv. and m would be App. When i look at the signature of "ask :: m r", that must be so, because i want ask to return me the MyEnv |
| 2021-06-10 23:14:08 | <geekosaur> | that changes the answer a bit |
| 2021-06-10 23:14:46 | <janus> | oh, sorry if i have previously answered in a misleading manner |
| 2021-06-10 23:14:47 | <geekosaur> | you want ReaderT MyEnv App |
| 2021-06-10 23:15:08 | <janus> | right, that should be the contents of the newtype, right? and then i can derive MonadReader |
| 2021-06-10 23:15:14 | <geekosaur> | correct |
| 2021-06-10 23:15:25 | <geekosaur> | but you'd made it sound like App was the name of the newtype |
| 2021-06-10 23:15:41 | × | Shaeto quits (~Shaeto@94.25.234.158) (Ping timeout: 272 seconds) |
| 2021-06-10 23:16:31 | <janus> | but wait, if i have ReaderT MyEnv App, then the Reader is outside the App, then MonadReader MyEnv App will not be implemented, or? |
| 2021-06-10 23:16:52 | <geekosaur> | ReaderT implements MonadReader |
| 2021-06-10 23:17:53 | <janus> | right, but i don't want functions in add to mention ReaderT, they should only require MonadReader |
| 2021-06-10 23:18:09 | <janus> | sounds like i am mixing up my monad stack levels somehow... hmm |
All times are in UTC.