Skip to content
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

complete todos #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

complete todos #52

wants to merge 3 commits into from

Conversation

bitnom
Copy link

@bitnom bitnom commented Feb 7, 2024

complete todos

complete todos
rm build test badge since I don't think it does anything atm
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

[![Build Status](https://github.com/dry-python/functional-jargon-python/workflows/test/badge.svg?event=push)](https://github.com/dry-python/functional-jargon-python/actions?query=workflow%3Atest)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this badge?


```python
# TODO
def make_adder(x):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer to annotate all functions in this article.


```python
# TODO
def make_adder(x):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def adder(y):
def adder(y: int) -> int:


```python
# TODO
def print_numbers():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def print_numbers():
from typing import Iterator
def print_numbers() -> Iterator[None]:


```python
# TODO
```
from typing import Union
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from typing import Union

if isinstance(value, int):
return f"Integer: {value}"
elif isinstance(value, str):
return f"String: {value}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add a comment that tuple[] is just fine as well.


NoneValue = NoneType()

Option = Union[Some[T], NoneType]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use dry-python's language for Maybe here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants