repeale / fp-go

fp-go is a collection of Functional Programming helpers powered by Golang 1.18+ generics.

Home Page:https://pkg.go.dev/github.com/repeale/fp-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about Option's Map and Match type signatures

tttardigrado opened this issue · comments

I was trying to improve the option implementation and realized that map has the following type signature:
func Map[T any](fn fp.LazyVal[T]) func(o Option[T]) Option[T] or map :: (a -> a) -> Option a -> Option a in a haskell-like syntax.

Is there a reason for it not being map :: (a -> b) -> Option a -> Option b

The same question applies to Match not being match :: ( () -> b ) -> ( a -> b ) -> Option a -> b

@Force4760 you are absolutely right! Thanks for spotting it.
I will try to address it asap (couple of weeks reasonably)

I'd be more than happy to work on it if you want.

If you like it's open. As a reference please take a look at these implementations https://github.com/gcanti/fp-ts/blob/master/src/Option.ts
It's a really good reference I took for the whole project

thanks @Force4760 i've enriched a bit the testing part and split the work in a PR with a smaller scope