Using Maybe type in Haskell

后端 未结 6 2006
孤独总比滥情好
孤独总比滥情好 2020-12-01 13:46

I\'m trying to utilize the Maybe type in Haskell. I have a lookup for key, value tuples that returns a Maybe. How do I access the data that was wrapped by Maybe? For exam

6条回答
  •  难免孤独
    2020-12-01 14:31

    Examples for "maybe":

    > maybe 0 (+ 42) Nothing
    0
    > maybe 0 (+ 42) (Just 12)
    54
    

提交回复
热议问题