Skip to content
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.

A Maybe instance should have a map function (or equivalent) #1

Open
timbuckley opened this issue Jun 12, 2017 · 0 comments
Open

A Maybe instance should have a map function (or equivalent) #1

timbuckley opened this issue Jun 12, 2017 · 0 comments

Comments

@timbuckley
Copy link

timbuckley commented Jun 12, 2017

Something wrapped in a maybe should have a .map() method, which takes a function that will be applied to x if that Maybe contains a Just x, or just pass along Nothing.

For example, in Haskell:

addOneOrNah :: Maybe Int -> Maybe Int
addOneOrNah maybeInt = fmap (+1) maybeInt

addOneOrNah Nothing
-- -> Nothing
addOneOrNah (Just 3)
-- -> Just 4
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant