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

Implement Nounable Protocol for Booleans #1817

Open
wants to merge 1 commit into
base: base
Choose a base branch
from

Conversation

agureev
Copy link
Contributor

@agureev agureev commented Jan 24, 2025

No description provided.

Comment on lines 62 to 68
@spec from_noun(Noun.t()) :: {:ok, list(Noun.t())} | :error
def from_noun(0), do: {:ok, true}
def from_noun(1), do: {:ok, false}

def from_noun(_) do
:error
end
Copy link
Member

Choose a reason for hiding this comment

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

Covered by the atom case

Copy link
Contributor Author

@agureev agureev Jan 24, 2025

Choose a reason for hiding this comment

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

No, it is not

Nounable for Atom only implements to_noun

Even then, it would have different semantics

@agureev agureev force-pushed the artem/noun-nounable-bool branch from a69f21a to 0e086ae Compare January 24, 2025 15:24
Comment on lines +52 to +56
def to_noun(bool) when bool in [true, false] do
Nounable.to_noun(bool)
end

def to_noun(), do: :error
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is specifically for converting to noun something that we assume is a boolean so that if it is another atom it fails

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

Successfully merging this pull request may close these issues.

2 participants