From 46ad15ea9c56c8b5422266056335933023d31f05 Mon Sep 17 00:00:00 2001 From: Matt Enlow Date: Wed, 11 Sep 2024 08:41:38 -0600 Subject: [PATCH] eh, use not --- lib/style/blocks.ex | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/style/blocks.ex b/lib/style/blocks.ex index 903ba69..18ee7e0 100644 --- a/lib/style/blocks.ex +++ b/lib/style/blocks.ex @@ -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]}) @@ -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]}