[Haskell-beginners] Maybe?

Imants Cekusins imantc at gmail.com
Wed May 13 14:32:08 UTC 2020


Maybe a is a sum type.

Show instance for sum types displays the constructor.

For example, if we used another sum type:
Either Int Int,
then
Left 23 /= Right 23

So we'd be interested to see the constructor to tell them apart. 23
wouldn't be sufficiently clear.


On Wed, May 13, 2020 at 5:18 PM Velichko Lefterov <
velichko.lefterov at gmail.com> wrote:

> The function returns Maybe a.
>
> On Wed, May 13, 2020 at 5:16 PM Alexander Chen <alexander at chenjia.nl>
> wrote:
>
>> I expected
>>
>> prelude> safeHead [23,1,4,2,4,2]
>> 23
>>
>> not
>> Just 23
>>
>> May 13, 2020 4:11:47 PM CEST Imants Cekusins <imantc at gmail.com> wrote:
>>
>> prelude> safeHead [23,1,4,2,4,2]
>> Just 23
>>
>>
>> Looks good.
>>
>> What did you expect to see?
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>>
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20200513/425f2e09/attachment-0001.html>


More information about the Beginners mailing list