11 May 01:04
Re: Maybe a, The Rationale
From: Brandon S. Allbery KF8NH <allbery <at> ece.cmu.edu>
Subject: Re: Maybe a, The Rationale
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2008-05-10 23:04:11 GMT
Subject: Re: Maybe a, The Rationale
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2008-05-10 23:04:11 GMT
On 2008 May 10, at 18:56, PR Stanley wrote: > >>> Paul: Hi folks >>> >>> data Maybe a = Nothing | Just a >>> >>> What is the underlying rationale for the Maybe data type? >>> is it the >>> safe style of programming it encourages/ >>> Something tells me this is going to start a lengthy discussion.>> >> Bob: Pure and simple -- it allows you to represent partial >> functions. >> Looking up a map will only sometimes find a value, so we either >> return >> Nothing, or Just that value. > > Paul: Would yu like to demonstrate this in an example? Um, I was encountering and recognizing times when I really needed an out-of-band "null", and the pain of representing such in C, shortly after I started serious programming in C (call it 1984-5). Is this really difficult? -- -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery <at> kf8nh.com system administrator [openafs,heimdal,too many hats] allbery <at> ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
>>
>> Bob: Pure and simple -- it allows you to represent partial
>> functions.
>> Looking up a map will only sometimes find a value, so we either
>> return
>> Nothing, or Just that value.
>
> Paul: Would yu like to demonstrate this in an example?
Um, I was encountering and recognizing times when I really needed an
out-of-band "null", and the pain of representing such in C, shortly
after I started serious programming in C (call it 1984-5). Is this
really difficult?
RSS Feed