returns icon indicating copy to clipboard operation
returns copied to clipboard

Further explanation needed

Open EricSchles opened this issue 4 years ago β€’ 2 comments

Hi all,

Big fan of functional programming. I'm glad to see ya'll trying to bring this to Python. My question / request is pretty basic, I hope. I was looking over the docs and I saw:

result: Result[int, Any] = Success(1).map(double)

When looking at this I was confused for a couple of reasons, since the syntax is new to me. But the biggest stumbling block was the:

result:

I couldn't find a clear discussion in the documentation for what thing: means. Can you explain this syntax before using it in the document? I am also confused about why you would set this equal to a type? It's not clear to me how or why this works from a syntax standpoint.

Hope these are fair comments and easy to resolve!

EricSchles avatar Sep 03 '21 00:09 EricSchles

Hi! @EricSchles thanks for your question.

result: Result = is a variable with type annotation. It uses the standard Python's syntax: https://www.python.org/dev/peps/pep-0526/#specification

I will add links to peps somewhere early in the docs.

I am also confused about why you would set this equal to a type?

If you are asking about : Result[int, Any] part, we set it because that how type annotations work πŸ™‚ By this we highlight that result variable has Result[int, Any] type.

I hope, that you will like returns! πŸ‘

sobolevn avatar Sep 03 '21 05:09 sobolevn

Ah okay, I get it now. I think it would be helpful to show standard mypy syntax in a function call and then show the variable assignment using your thing. And then just say that these are equivalent. That’s the simplest jump, I think. Linking to the pep’s is probably overkill.

On Fri, Sep 3, 2021 at 1:58 AM Nikita Sobolev @.***> wrote:

Hi! @EricSchles https://github.com/EricSchles thanks for your question.

result: Result = is a variable with type annotation. It uses the standard Python's syntax: https://www.python.org/dev/peps/pep-0526/#specification

I will add links to peps somewhere early in the docs.

I am also confused about why you would set this equal to a type?

If you are asking about : Result[int, Any] part, we set it because that how type annotations work πŸ™‚ By this we highlight that result variable has Result[int, Any] type.

I hope, that you will like returns! πŸ‘

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dry-python/returns/issues/1049#issuecomment-912278754, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHCZPN4XQ5JFECXH5C5I5DUABPXTANCNFSM5DKHDRZA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

EricSchles avatar Sep 03 '21 13:09 EricSchles