Can fields in a record be optional?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Can fields in a record be optional?

Antoine Latter-2
I would expect I would run into trouble with this approach - when a function
receives one of these records as an argument, how does it know if it is safe
to acces the record fields in question?

I would prefer using Maybe types, different types altogether for summed
contracts, or imaking a Contract a type with two cases (as suggested
earlier).
On Jul 17, 2011 5:19 PM, "David Place" <d at vidplace.com> wrote:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110720/426b16a6/attachment.htm>

Reply | Threaded
Open this post in threaded view
|

Can fields in a record be optional?

David Place
Yes, I agree with you.  In trying to attend to one thing at a time, I copied the use of "undefined" from the original poster's code.   Certainly, it makes it easier to debug code if you can have a Show instance that doesn't throw an error!
____________________
David Place  
Owner, Panpipes Ho! LLC
http://panpipesho.com
d at vidplace.com



On Jul 20, 2011, at 8:35 AM, Antoine Latter wrote:

> I would expect I would run into trouble with this approach - when a function receives one of these records as an argument, how does it know if it is safe to acces the record fields in question?
>
> I would prefer using Maybe types, different types altogether for summed contracts, or imaking a Contract a type with two cases (as suggested earlier).
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110720/6b035e0c/attachment.htm>