<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, May 5, 2015 at 11:19 AM, Shishir Srivastava <span dir="ltr"><<a href="mailto:shishir.srivastava@gmail.com" target="_blank">shishir.srivastava@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">As far as I understand the data type is function based and takes a 'function' instead of a value of a concrete type so how does one create an instance of this type.</blockquote></div><br>Functions are first class and fairly concrete (unless polymorphic) in functional languages. (But I wonder at your example as it seems pretty strange to have firstName be String -> Int.)</div><div class="gmail_extra"><br></div><div class="gmail_extra"> Person { firstName = \name -> whatever }</div><div class="gmail_extra"> Person { firstName = length }<br><div><br></div><div>Practical example from xmonad-contrib:</div><div><br></div><div> logHook = dynamicLogWithPP $ defaultPP { ppOutput = hPutStrLn dock }</div><div><br></div><div>(two such fields for the price of one! logHook and ppOutput are both function-valued) where dock is from a spawnPipe call that launches something like dzen or xmobar with a pipe connected to its stdin. (See <a href="http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html#g:1">http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html#g:1</a>)</div><div><br></div><div>It is worth remembering lazy evaluation; the functions are not evaluated at the time of assignment.</div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>
</div></div>