[Haskell-beginners] use of First or Last
Johan Tibell
johan.tibell at gmail.com
Mon Jul 26 04:33:27 EDT 2010
Hi Johann,
On Mon, Jul 26, 2010 at 10:20 AM, Johann Bach <johann.bach1127 at gmail.com>wrote:
> I am reading "typeclassopedia" and got curious about how the monoid
> instances First or Last could be applied to a real problem. Any
> suggestions for improvement would be welcome.
>
The code looks fine to me.
The Last monoid is useful when parsing command line flags and you want the
last mention of a flag to have precedence. You can further extend this to
allow for default values of flags and flag definitions in config files. See
Duncan's explanation of how this is used in Cabal:
http://www.mail-archive.com/cabal-devel@haskell.org/msg01492.html
Cheers,
Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100726/0e3cbfab/attachment.html
More information about the Beginners
mailing list