[Haskell-cafe] handling NULL value in database query with Maybe (or other ...)
Tom Ellis
tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Tue Dec 18 15:16:39 UTC 2018
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
More information about the Haskell-Cafe
mailing list