Open
Conversation
complete todos
Update README.md
rm build test badge since I don't think it does anything atm
sobolevn
reviewed
Feb 9, 2024
Member
sobolevn
left a comment
There was a problem hiding this comment.
WOW! This is just great! Thank you some much for working on this.
I have a few comments, though :)
| @@ -1,7 +1,5 @@ | |||
| # Functional Programming Jargon | |||
|
|
|||
| [](https://github.com/dry-python/functional-jargon-python/actions?query=workflow%3Atest) | |||
|
|
||
| ```python | ||
| # TODO | ||
| def make_adder(x): |
Member
There was a problem hiding this comment.
We prefer to annotate all functions in this article.
|
|
||
| ```python | ||
| # TODO | ||
| def make_adder(x): |
Member
There was a problem hiding this comment.
Suggested change
| def make_adder(x): | |
| from typing import Callable | |
| def make_adder(x: int) -> Callable[[int], int]: |
| ```python | ||
| # TODO | ||
| def make_adder(x): | ||
| def adder(y): |
Member
There was a problem hiding this comment.
Suggested change
| def adder(y): | |
| def adder(y: int) -> int: |
|
|
||
| ```python | ||
| # TODO | ||
| def print_numbers(): |
Member
There was a problem hiding this comment.
Suggested change
| def print_numbers(): | |
| from typing import Iterator | |
| def print_numbers() -> Iterator[None]: |
| ```python | ||
| # TODO | ||
| ``` | ||
| from typing import Union |
Member
There was a problem hiding this comment.
Suggested change
| from typing import Union |
| if isinstance(value, int): | ||
| return f"Integer: {value}" | ||
| elif isinstance(value, str): | ||
| return f"String: {value}" |
Member
There was a problem hiding this comment.
It is a good place to use typing.assert_never
| from typing import NamedTuple | ||
|
|
||
| # A product type representing a point in 2D space | ||
| class Point(NamedTuple): |
Member
There was a problem hiding this comment.
I think we can add a comment that tuple[] is just fine as well.
|
|
||
| NoneValue = NoneType() | ||
|
|
||
| Option = Union[Some[T], NoneType] |
Member
There was a problem hiding this comment.
Suggested change
| Option = Union[Some[T], NoneType] | |
| Option = Some[T] | NoneType |
| Option is useful for composing functions that might not return a value. | ||
| This pattern forces the programmer to explicitly handle the case where a value might be missing, leading to safer and more predictable code. | ||
|
|
||
| In languages like Haskell, this type is known as `Maybe`, with the variants being `Just` (for `Some`) and `Nothing` (for `None`). In Rust, it's called `Option`, with the variants `Some` and `None`. |
Member
There was a problem hiding this comment.
Please, use dry-python's language for Maybe here :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
complete todos