[Haskell-beginners] Maybe and Just

Brandon Allbery allbery.b at gmail.com
Thu Mar 26 15:46:45 UTC 2015


On Thu, Mar 26, 2015 at 11:26 AM, Shishir Srivastava <
shishir.srivastava at gmail.com> wrote:

> ok..but what's with using the keyword 'Just' ? why cannot 'Maybe' be
> defined like this
>
> data Maybe a = a | Nothing
>

Because type inference won't work if you don't have a distinction between
an a and a Maybe a. Also, you end up back where you started --- there's a
distinguished (non)value that appears to be a value of the type, which
leaves you no better off than with C's NULL or Perl's undef, losing the
type safety of "this can't fail" vs. "this may fail and you must deal with
the failure somehow".

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150326/e6dbc786/attachment.html>


More information about the Beginners mailing list