[Haskell-beginners] Maybe?

Alexander Chen alexander at chenjia.nl
Wed May 13 14:01:54 UTC 2020


Hi,

safeHead.hs

safeHead :: [a] -> Maybe a
safeHead []    = Nothing
safeHead (x:_) = Just x

prelude> safeHead [23,1,4,2,4,2]
Just 23

Question:
what am i doing wrong?

best,

Alexander  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20200513/a754edbb/attachment.html>


More information about the Beginners mailing list