Adding the ?. null verification

Meta via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 19 14:56:17 PDT 2014


On Thursday, 19 June 2014 at 21:34:07 UTC, Andrei Alexandrescu 
wrote:
> On 6/18/14, 10:39 AM, deadalnix wrote:
>> Use a maybe monad :
>> Maybe(obj).memeber.nested.val
>
> Yah, I keep on thinking we should explore the maybe monad more 
> thoroughly as a library in D. -- Andrei

The other night for fun I tried implementing an Option type as a 
RandomAccessRange. When a value exists, the range is not empty 
and has length 1, otherwise it is empty and has length 0, with 
the other primitives doing as expected. It's neat how you then 
automatically get all current and future range algorithms for 
free. One problem I found trying to use map like bind in Haskell 
is that it does the exact opposite of what I want. The result is 
not Option!int, but MapResult!(__lambda3, Option!int).


More information about the Digitalmars-d mailing list