-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Transforming return type when using map #66
Comments
this is needed badly |
I found som commented out code ./options/transforms.go. I looks like someone tried it but gave up. |
I happened to come up with the same code as workaround. Why would this not
be provided?
Beste Grüße
Alexander Thom
…On Tue, Mar 11, 2025 at 5:54 AM Bardia Jedi ***@***.***> wrote:
I found som commented out code ./options/transforms.go
<https://github.com/samber/mo/blob/master/options/transforms.go>.
I looks like someone tried it but gave up.
—
Reply to this email directly, view it on GitHub
<#66 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACTUZSWUMRC5VWTGQNYJCD2T2XDRAVCNFSM6AAAAABYMEMOKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJTGQZDQMJYHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
[image: Luviz]*Luviz* left a comment (samber/mo#66)
<#66 (comment)>
I found som commented out code ./options/transforms.go
<https://github.com/samber/mo/blob/master/options/transforms.go>.
I looks like someone tried it but gave up.
—
Reply to this email directly, view it on GitHub
<#66 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACTUZSWUMRC5VWTGQNYJCD2T2XDRAVCNFSM6AAAAABYMEMOKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJTGQZDQMJYHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
We could always fork it and make the change. @samber haven't responded and if you were able to find a workaround, I would love to check it out and see we could use it as well. |
I'm using func FlatMap[T any, V any](
result mo.Result[T],
f func(T) mo.Result[V],
) mo.Result[V] {
v, err := result.Get()
if err != nil {
return mo.Err[V](err)
}
return f(v)
} |
Hi I have been looking to use this package in my solution however every time I have tried to so I feel like something is missing.
In our solution we want to use Options and Results every time we are uncertain of the return value.
I do use monads in python and node (typescript) and it's great there is a a lot that we can do with elegantly, and I do like
MarshalJSON
function that you have implemented.My issue with mo is that when we need to map a type to another type, see example below.
Here I want to get a option of
UserRequestForm
and if it has a value I wan't to convert it to a TDO and push it to a DB.So something looking like this:
I'm kind new to GO thereby I might be a bit ignorerat, so there might be that writing something like the code above is might not be a good idea.
However I know that there is good support generics and type inference in GO. So I don't see any issues with creating functions looking like this:
Here is my question, is there a reson why the Map and FlatMap function is hard code as generic. Or is just that you haven't implemented support for it yet, and in that case can I try to make PR?
The text was updated successfully, but these errors were encountered: