Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flatMap and leftMap to Maybe types #221

Closed
joelnet opened this issue Oct 22, 2018 · 5 comments
Closed

Add flatMap and leftMap to Maybe types #221

joelnet opened this issue Oct 22, 2018 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@joelnet
Copy link
Owner

joelnet commented Oct 22, 2018

Add the flatMap and leftMap functions to Just and Nothing.

  • Nothing.flatMap will work just like map and return Nothing.
  • Just.flatMap will be similar to map, but it will not box the value in a Just.
  • Just.leftMap will not execute the function and return the Just.
  • Nothing.leftMap will execute the function and return the value.

Expected behavior

const upper = s => typeof s === 'string' ? Just (s.toUpperCase ()) : Nothing

Just ('abc').flatMap (upper) //=> Just('ABC')
Just (123).flatMap (upper) //=> Nothing
Nothing.flatMap (upper) //=> Nothing

Just ('abc').leftMap (upper) //=> Just('abc')
Nothing.leftMap (() => Just ('ABC')) //=> Just('ABC')
Nothing.leftMap (() => Nothing) //=> Nothing
@joelnet joelnet added enhancement New feature or request good first issue Good for newcomers hacktoberfest labels Oct 22, 2018
@johnpaulada
Copy link

Hi! Can I try working on this?

@joelnet joelnet changed the title Add flatMap to Maybe types Add flatMap and leftMap to Maybe types Oct 25, 2018
@joelnet
Copy link
Owner Author

joelnet commented Oct 25, 2018

How is your progress going? Do you need any help?

I just created a Discord chat channel. Hit me up there if you have questions. https://discord.gg/Gg7ptD5

@thanhcng
Copy link
Contributor

Hi, can I work on this issue instead?

joelnet added a commit that referenced this issue Oct 26, 2018
@joelnet joelnet closed this as completed Oct 26, 2018
@johnpaulada
Copy link

Sorry I was having internet difficulties. Third world country 😞

@joelnet
Copy link
Owner Author

joelnet commented Oct 26, 2018

lol no worries. I am having internet difficulties right now too. Guess it's contagious :)

Still plenty of issues left to tackle :)

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants