Skip to content

Commit

Permalink
eh, use not
Browse files Browse the repository at this point in the history
  • Loading branch information
novaugust committed Sep 11, 2024
1 parent 98c8d8d commit 46ad15e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/style/blocks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ defmodule Styler.Style.Blocks do
end
end

#@TODO do i want to be smart and recognize stdlib functions that return bools and use :not instead of :!?
# @TODO do i want to be smart and recognize stdlib functions that return bools and use :not instead of :!?
def run({{:unless, m, [head, do_else]}, _} = zipper, ctx) do
zipper
|> Zipper.replace({:if, m, [invert(head), do_else]})
Expand Down Expand Up @@ -319,6 +319,18 @@ defmodule Styler.Style.Blocks do
|> run(%{ctx | comments: comments})
end

# %{1 => unary_guards, 2 => binary_guards} =
# :functions
# |> Kernel.__info__()
# |> Enum.filter(fn {k, _} ->
# k
# |> to_string()
# |> String.starts_with?("is_")
# end)
# |> Enum.group_by(fn {_, v} -> v end, fn {k, _} -> k end)
#
# @bools ~w(< <= > >= in)

defp invert({:!=, m, [a, b]}), do: {:==, m, [a, b]}
defp invert({:!==, m, [a, b]}), do: {:===, m, [a, b]}
defp invert({:==, m, [a, b]}), do: {:!=, m, [a, b]}
Expand Down

0 comments on commit 46ad15e

Please sign in to comment.