On Tue, May 5, 2015 at 11:38 AM, Shishir Srivastava <shishir.srivastava@gmail.com> wrote:
I was going to follow up my question with the possible practical use of why and where someone would use such a construct to wrap a function inside a new data-type. 

For all that matters I could have used 'length' function directly to get the same output. 

Because you want a different function for each value, typically. Continuing with the DynamicLog example, I have two different uses of DynamicLog in my xmonad config; one feeds an EWMH panel from the logHook, so it sets

    defaultPP { {- ... -}, ppOutput = dbusOutput ch }

where ch was previously associated with a dbus endpoint. This is executed whenever the focused window changes or the current workspace changes.

The second is in a keybinding I use for debugging and outputs to the session log (~/.xsession-errors):

    defaultPP { {- ... -}, ppOutput = hPutStrLn stderr }

(The ellipsis comments customize the value in other ways not important here.)

You might think of this use of record syntax as being the Haskell version of "named parameters" (as distinct from positional parameters) present in some other languages.

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net