These are chat archives for evhub/coconut

19th
Jun 2018
balajeerc
@balajeerc
Jun 19 2018 02:23
@acdimalev Thanks for taking a look at it and confirming that I'm on the right track. @eindiran Yes, I did come across the article today. Did you also stumble on it via a comment on HN on the post on Maybe implementation in Swift?
@eindiran I find your use of wrappers to accomplish this very elegant! :) Thanks for that.
Elliott Indiran
@eindiran
Jun 19 2018 02:48
@balajeerc That is also where I found it 😀
'jamin
@acdimalev
Jun 19 2018 06:36

Somewhat thinking outloud... if you use a decorator to apply bind functionality, you can effectively drop in a Right(value) (i.e. my_func(Right(value))) to recover the initial function. I could see how having functions that assume an Either input might save on typing.

That skip_on_error function seems a little odd to me for two reasons. I'm hoping you can call out if there's something I'm missing... . It looks like it's handling the map portion, applying the function only to Right(val), but it passes the whole Either into the function that it wraps. It also doesn't guarantee Either as a return type since the wrapped function is free to return any value it likes, so the output could easily be typing.Union[T, Either]. Is there any advantage to these design choices?

Elliott Indiran
@eindiran
Jun 19 2018 21:22
@acdimalev I think you're right that guaranteeing Either as a return type is the right way to go. I'm not sure I understand your first point though. What would it ideally do instead of passing in the whole Either?
Would that version make the decorator an implementation of bind for Either?