mo icon indicating copy to clipboard operation
mo copied to clipboard

Fix the Map for Option type

Open tomohavvk opened this issue 1 year ago • 1 comments

After the first touch of Option type I was confused how the Map is implemented.

In my understanding of functional programming the Map should be applied only for a value and return the value, and never return the no-value.

For case when need to apply function for a value and return Some or None the FlatMap should be used.

Before:

Some(1).
  Map(func(value int) (int, bool) {
    return value + 21, true
  })

After:

Some(1).
  Map(func(value int) int {
    return value + 21
  })

tomohavvk avatar May 15 '24 09:05 tomohavvk

Since this introduces a breaking change, we must wait for v2.

samber avatar Jun 22 '24 21:06 samber