You seem rather confused about the topic. What magic were you expecting to happen if something doesn't have a value?

The point of Maybe is it lets you (a) specify exactly where things can lack a value (as, for example, when a database column can produce a NULL instead of a value), and (b) explicitly handle those instead of hoping the program somehow reads your mind to figure out how to deal with it or feeds you some unexpected 'nil' or whatever.

Consider in this case that the database does not care if a column doesn't happen to have any NULLs, it cares only that the column was not declared NOT NULL and therefore *can* contain a NULL. Which is the same condition where you use a Maybe someType in Haskell instead of simply someType.

In particular, if you were expecting a database NULL to turn into the empty string or "NULL" or some other such in-band value, how were you expecting to distinguish the case where the database row actually contains that string? That's why databases have NULL to begin with: "no value" distinct from any possible actual value. If you do not want this, declare the column NOT NULL in the database, don't expect the client program to do magic for you.

On Tue, Dec 18, 2018 at 10:34 AM Damien Mattei <mattei@oca.eu> wrote:
ok well i do not want to open a discussion here, but i do not see any
benefit in Haskell using Nothing and Just compared to other language,
it's the same than if i had written in C something like :
if (x == NULL)
   printf("NULL\n");
else
   printf("%s",*x);

i expected more from Haskell...

ok reading twice the article in link, i admit there should be some
adavantage using Nothing instead of null, such as type, and genericity
and not being spcecific to alloated memory as in C ...

Le 18/12/2018 16:16, Tom Ellis a écrit :
> That is using Maybe and is not a null pointer!
>
> Just and Nothing are the constructors of Maybe.
>
> On Tue, Dec 18, 2018 at 03:43:35PM +0100, Damien Mattei wrote:
>> thank you Tom, it is the kind of answer that help me
>> i insert this and it is ok now:
>> forM_ bd_rows_WDS $ \(Only x) ->
>>       case x of
>>         Nothing -> putStrLn ("x =" ++ "NULL")
>>         Just x -> putStrLn $ ("x =" ++ Text.unpack x)
>> i had seen a such solution on web but thought the Maybe was the
>> solution, i hoped asked could avoid using sort of Null pointer as
>> mentioned in this article:
>> https://www.lucidchart.com/techblog/2015/08/31/the-worst-mistake-of-computer-science/
>> if someone else have a simpler solution email me
>>
>>
>> Le 18/12/2018 13:34, tom.stejskal a écrit :
>>> case x of
>>>     Nothing -> putStrLn "NULL"
>>>     Just y -> putStrLn $ Text.unpack y
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>

--
Damien.Mattei@unice.fr, Damien.Mattei@oca.eu, UNS / OCA / CNRS
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


--
brandon s allbery kf8nh
allbery.b@gmail.com