tag:blogger.com,1999:blog-8643857899806162280.post3279457792413887193..comments2024-02-25T06:15:55.318-03:00Comments on Bug squash: Lenses in F#Mauricio Schefferhttp://www.blogger.com/profile/15247972578064164206noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-8643857899806162280.post-59112392035416777272013-10-01T01:25:53.593-03:002013-10-01T01:25:53.593-03:00@Edward : indeed! Back when I wrote this in 2011, ...@Edward : indeed! Back when I wrote this in 2011, your lens library wasn't around yet ;-)Mauricio Schefferhttps://www.blogger.com/profile/15247972578064164206noreply@blogger.comtag:blogger.com,1999:blog-8643857899806162280.post-34594940001168784692013-10-01T00:25:48.180-03:002013-10-01T00:25:48.180-03:00The implementation that folks use in Haskell is ac...The implementation that folks use in Haskell is actually http://hackage.haskell.org/package/lens -- The `lenses` package was never really used by anyone.Edward Kmetthttps://www.blogger.com/profile/16144424873202502715noreply@blogger.comtag:blogger.com,1999:blog-8643857899806162280.post-10067989802519851392013-05-23T12:18:17.123-03:002013-05-23T12:18:17.123-03:00This comment has been removed by the author.Tiagohttps://www.blogger.com/profile/18442456213726675162noreply@blogger.comtag:blogger.com,1999:blog-8643857899806162280.post-7675068331410136232013-05-23T12:17:56.629-03:002013-05-23T12:17:56.629-03:00This comment has been removed by a blog administrator.Tiagohttps://www.blogger.com/profile/18442456213726675162noreply@blogger.comtag:blogger.com,1999:blog-8643857899806162280.post-79501810843426733712012-08-29T11:18:51.798-03:002012-08-29T11:18:51.798-03:00Yes, I have seen that article. It uses typeclasses...Yes, I have seen that article. It uses typeclasses and higher-kinded types, which we don't have in .NET, so I don't think it's viable to express that in F#.<br />It still looks overkill, i.e. as I said a getter is just a function.<br />Polymorphic lenses are interesting though, I'll try to investigate them when I get some time.Mauricio Schefferhttps://www.blogger.com/profile/15247972578064164206noreply@blogger.comtag:blogger.com,1999:blog-8643857899806162280.post-1431169589730406522012-08-29T06:15:33.191-03:002012-08-29T06:15:33.191-03:00Supposedly you can solve it with Lenses - http://c...Supposedly you can solve it with Lenses - http://comonad.com/reader/2012/mirrored-lenses, but i did not understand this Haskell stuff.Anonymoushttps://www.blogger.com/profile/01027445565168748925noreply@blogger.comtag:blogger.com,1999:blog-8643857899806162280.post-8027178522847062202012-08-28T23:46:07.657-03:002012-08-28T23:46:07.657-03:00@Dennis : you could write a "forgetful" ...@Dennis : you could write a "forgetful" lens modeling a readonly C# property, but it would violate the SetGet law (also called PutGet or Acceptability law). A lens that doesn't comply with this law is not well-behaved. See <a href="http://grace.gsdlab.org/images/e/e2/Nate-short.pdf" rel="nofollow">these slides</a> for a summary of lens laws. I haven't checked how, exactly, violating this law harms composability. I bet you can come up with such an example ;-)<br />Ultimately though, a readonly property isn't a bidirectional transformation so I don't think it would gain much from being modeled as a lens instead of just trivially modeling it as a function.Mauricio Schefferhttps://www.blogger.com/profile/15247972578064164206noreply@blogger.comtag:blogger.com,1999:blog-8643857899806162280.post-82664372553868524932012-08-28T10:22:24.422-03:002012-08-28T10:22:24.422-03:00But it is not through the lens definition forced t...But it is not through the lens definition forced to always implement getter AND setter, or in other words how you implement a readonly C# Property with Lenses?Anonymoushttps://www.blogger.com/profile/01027445565168748925noreply@blogger.comtag:blogger.com,1999:blog-8643857899806162280.post-48293692058650189982011-11-16T13:10:26.198-03:002011-11-16T13:10:26.198-03:00@Nick : thanks, in the actual code I call this ...@Nick : thanks, in the actual code I call this 'compose' then bind (>>|) to the flipped 'composed', but forgot to flip it here trying to make it simpler.Mauricio Schefferhttps://www.blogger.com/profile/15247972578064164206noreply@blogger.comtag:blogger.com,1999:blog-8643857899806162280.post-3127506375801853122011-11-16T10:18:59.068-03:002011-11-16T10:18:59.068-03:00One small error
This is the correct composition
le...One small error<br />This is the correct composition<br />let inline (>>|) (l1: Lens<_,_>) (l2: Lens<_,_>) = <br /> { Get = l1.Get >> l2.Get <br /> Set = l2.Set >> l1.Update }Nick Palladinoshttp://www.m-brace.netnoreply@blogger.com