<div dir="ltr"><div>Here's a quick example using ghci:</div><div><br></div><div>Prelude> let a = Person length</div><div>Prelude> :type a</div><div>a :: Person</div><div>Prelude> (firstName a) "Bob"</div><div>3</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 5, 2015 at 10:19 PM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi, <div><br></div><div>Could anyone please have a look and let me know how you can create the instance of this data type ?</div><div><br></div><div>---</div><div><font face="monospace, monospace"> data Person = Person { firstName ::String -> Int }</font><br></div><div>---</div><div><br></div><div>I've seen this type of syntax in a lot of places in haskell code where a new data type is defined in terms of functions rather than concrete data types.<br></div><div><br></div><div>I am not trying to achieve anything out of this but purely as an exercise in understanding the record syntax.</div><div><br></div><div>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.</div><div><br></div><div>Thanks,</div><div><span style="font-family:georgia,serif;color:rgb(11,83,148)">Shishir </span></div></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>