tag:blogger.com,1999:blog-8976038770606708499.post2045889309598085057..comments2024-03-15T08:27:35.878+01:00Comments on Graphics and FPL: Don’t use DefaultAnonymoushttp://www.blogger.com/profile/06180476773002153033noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-8976038770606708499.post-23047857077419897782015-07-17T11:52:13.435+02:002015-07-17T11:52:13.435+02:00I disagree, and think this is more of an issue of ...I disagree, and think this is more of an issue of practicality. Monoid is a useful typeclass, and looks like a nice idea for config updates too, but how would that look like in real code? A default + lens (or record update syntax) for updates does the same thing without the need for a Monoid instance.Anonymoushttps://www.blogger.com/profile/08237807148277747031noreply@blogger.comtag:blogger.com,1999:blog-8976038770606708499.post-48848794907799939172015-07-16T22:51:42.370+02:002015-07-16T22:51:42.370+02:00Sure! Typically, a Monoid is a set with a binary a...Sure! Typically, a Monoid is a set with a binary associative function. If you have a Configuration type, you can make it a Monoid by implementing mempty to be the « default configuration », and the binary function would take the right configuration to override the left one. :)Anonymoushttps://www.blogger.com/profile/06180476773002153033noreply@blogger.comtag:blogger.com,1999:blog-8976038770606708499.post-3938029625651363792015-07-16T21:50:40.797+02:002015-07-16T21:50:40.797+02:00Your blog post provides code examples of how not t...Your blog post provides code examples of how not to do it. But as a Haskell newbie I can not imagine how to use Monoid for default values. I'd be thankful for another article about that!Thomas Kochhttp://www.koch.ronoreply@blogger.comtag:blogger.com,1999:blog-8976038770606708499.post-5524970883382879962015-07-16T18:10:51.644+02:002015-07-16T18:10:51.644+02:00the xlsx library uses them
https://hackage.haskell...the xlsx library uses them<br />https://hackage.haskell.org/package/xlsx-0.1.0.4/docs/Codec-Xlsx.htmlAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8976038770606708499.post-49206699249183079052015-07-16T17:39:49.411+02:002015-07-16T17:39:49.411+02:00Well, just implement Monoid. mempty is your defaul...Well, just implement Monoid. mempty is your default, and mappend the way to override the configuration. :)Anonymoushttps://www.blogger.com/profile/06180476773002153033noreply@blogger.comtag:blogger.com,1999:blog-8976038770606708499.post-37572894840785804202015-07-16T17:06:14.877+02:002015-07-16T17:06:14.877+02:00Can you give some examples of APIs which use Defau...Can you give some examples of APIs which use Default? <br /><br />Also, how would you use default in lieu of optional arguments? You alluded to that but I can't picture how it would work.<br /><br />I thought Default was typically used when you need a "don't care" value of some type (which need satisfy no law). Or for configuration data structures, where rather than every `Cfg` type in each library also exporting a "defaultCfg" binding, they can use instance Default for some uniformity in naming.<br />Ryan Newtonhttps://www.blogger.com/profile/15916639901554711946noreply@blogger.com