Exploit "Errors in guards" in defguard

@eksperimental :+1:

@dimitarvp I understand your point.

I am not criticising OP. I don’t know specifics of how non_empty function is being used.

I feel original non_empty function is little over engineered - covers list, map, tuple.

Most of the time, result tuple is pattern matched. Tuples are rarely iterated like list.

I use Enum.empty? Or for empty checks. I have some error_* which return error messages for a Boolean expression.

def error_if(true, msg), do: {:error, msg}
def error_if(_,_), do: :ok

ErrorUtils module has error_unless, error_if_nil, error_if_not_nil, etc.

Using these error funcs, with and case - I never felt need for anything else.

I wrote defguard for the first time today. This non_empty function does not need defguard as such.