tag:blogger.com,1999:blog-1777990983847811806.post5559496042324984605..comments2024-03-16T16:29:29.582-07:00Comments on Haskell for all: LensesGabriella Gonzalezhttp://www.blogger.com/profile/01917800488530923694noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-1777990983847811806.post-31840628856486745572014-03-22T17:47:21.759-07:002014-03-22T17:47:21.759-07:00Thank you! I fixed it.Thank you! I fixed it.Gabriella Gonzalezhttps://www.blogger.com/profile/01917800488530923694noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-22289062421673137572014-03-14T04:51:41.379-07:002014-03-14T04:51:41.379-07:00Thanks for the article, it has been nicely written...Thanks for the article, it has been nicely written.<br /><br />A small typo: s/x/x'<br /><br />in<br /><br />>>> (Point 3.0 4.0) ^. x<br />3.0<br />>>> (x ^= 10.0) (Point 3.0 4.0)<br />Point {x = 10.0, y = 4.0}Anonymoushttps://www.blogger.com/profile/04713748543760069378noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-89192304327965422262013-01-09T08:16:36.244-08:002013-01-09T08:16:36.244-08:00So I think that the general consensus is that the ...So I think that the general consensus is that the new `lens` package has the right type for lenses. The reason people really like the new lens type is:<br /><br />a) You don't even have to import the package to define lenses<br />b) It's very very elegant and "self-evident" (i.e. there is exactly one right way to implement it)<br />c) It supports polymorphic update<br />d) It supports write-only and read-only lenses<br /><br />Point (a) is very important, because if we define the new record syntax to use lenses you don't want the language definition to dependent on a particular package's data type. The new formulation of a lens requires only `Functor`s, so it is very easy to define a language specification that can automatically derive lenses for an arbitrary data type, even one with multiple constructors.<br /><br />However, although the new lens type is essentially nailed down at this point, people are still debating over what the standard library of lens operators should look like. Edward has done a lot of work with his `lens` package showing the full range of power of the new lenses, but it is a very large and unapproachable package and I think people are waiting for him to distill out a smaller Haskell98 core package with few dependencies before they add lenses to the language.Gabriella Gonzalezhttps://www.blogger.com/profile/01917800488530923694noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-15028868280091235532013-01-09T03:22:40.597-08:002013-01-09T03:22:40.597-08:00A very nice introduction to lenses, thank you! I s...A very nice introduction to lenses, thank you! I sure as hell approve your slam on the record syntax. I can't wait for something to be at last done about it in the language specs. Btw do are there any news on when it's going to happen?Anonymoushttps://www.blogger.com/profile/05378864646230261707noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-22627905875026107312012-08-06T14:16:36.015-07:002012-08-06T14:16:36.015-07:00Thanks! I'll try to write some more introduct...Thanks! I'll try to write some more introductory posts in the near future, too.Gabriella Gonzalezhttps://www.blogger.com/profile/01917800488530923694noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-76763810774857702502012-08-05T19:18:48.467-07:002012-08-05T19:18:48.467-07:00Great article! As a newbie to haskell this has bee...Great article! As a newbie to haskell this has been very enlightening. Now I'm going to rummage through your blog for more :-)drozzyhttps://www.blogger.com/profile/06962143421005350695noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-58088890738377039522012-06-26T02:56:05.927-07:002012-06-26T02:56:05.927-07:00OK, I obviously can't press the right buttons;...OK, I obviously can't press the right buttons; hence the two removals above :) What I wanted to say was this:<br /><br />I am referencing this article on my amateur Haskell blog: http://monoid.se/lenses/. If you find anything objectionable, write me a line.Anonymoushttps://www.blogger.com/profile/10066859973651234163noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-9877899991707935282012-06-26T02:54:48.180-07:002012-06-26T02:54:48.180-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/10066859973651234163noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-64344728186358524872012-06-25T12:01:03.061-07:002012-06-25T12:01:03.061-07:00Yes, Planet Haskell has also been rife with stuff ...Yes, Planet Haskell has also been rife with stuff pertaining to lenses as of late... I'm sure you've read http://comonad.com/reader/2012/mirrored-lenses/ already, and http://r6.ca/blog/20120623T104901Z.htmlAnonymoushttps://www.blogger.com/profile/10066859973651234163noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-85021619767781305752012-06-25T12:00:22.656-07:002012-06-25T12:00:22.656-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/10066859973651234163noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-967899217920146522012-06-25T09:13:22.561-07:002012-06-25T09:13:22.561-07:00Yeah, I will, although I want to wait for the more...Yeah, I will, although I want to wait for the more recent lens discussions on reddit to settle down because it looks like more powerful versions are on the way.Gabriella Gonzalezhttps://www.blogger.com/profile/01917800488530923694noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-54248936537627121372012-06-25T02:35:24.646-07:002012-06-25T02:35:24.646-07:00Don't mention it! :)
Thanks for the easily fo...Don't mention it! :)<br /><br />Thanks for the easily followed "tutorial". Me likes! <br /><br />As a suggestion, I would like to see a guide about how to actually use fclabels and/or data-lens, since the hackage:d packages have no "how to" material whatsoever (although your material here goes a long way). I could even help, if there's anything to help with. I do so like this concept about `Lens`:es. :)Anonymoushttps://www.blogger.com/profile/10066859973651234163noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-61043025008654376412012-06-24T15:35:19.686-07:002012-06-24T15:35:19.686-07:00Thank you so much. Great catches! I believe I fi...Thank you so much. Great catches! I believe I fixed all of them. I really appreciate it.Gabriella Gonzalezhttps://www.blogger.com/profile/01917800488530923694noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-77030853264706879092012-06-24T14:04:13.730-07:002012-06-24T14:04:13.730-07:00Also,
>>> execState goUp (Point 3.0 4.0)...Also,<br /><br />>>> execState goUp (Point 3.0 4.0)<br />Point {x = 10.0, y = 4.0}<br /><br />seems wrong. It should be, if I'm correct, <br /><br />>>> execState goUp (Point 3.0 4.0)<br />Point {x = 3.0, y = 11.0}Anonymoushttps://www.blogger.com/profile/10066859973651234163noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-24982776584216549402012-06-24T13:46:26.299-07:002012-06-24T13:46:26.299-07:00access :: Lens a b -> State a b
access = do
...access :: Lens a b -> State a b<br />access = do<br /> a <- get -- read the current state<br /> let b = getL p a<br /> return b -- return the value<br /><br />should include the parameter `p`, like so:<br /><br />access :: Lens a b -> State a b<br />access p = do<br /> a <- get -- read the current state<br /> let b = getL p a<br /> return b -- return the valueAnonymoushttps://www.blogger.com/profile/10066859973651234163noreply@blogger.comtag:blogger.com,1999:blog-1777990983847811806.post-763127678753731832012-06-24T11:14:40.893-07:002012-06-24T11:14:40.893-07:00s/Property a b /Lens a b/s/Property a b /Lens a b/Anonymoushttps://www.blogger.com/profile/10066859973651234163noreply@blogger.com