Skip to content

Commit

Permalink
Fix defpartial and defcurry do not support zero arity functions w…
Browse files Browse the repository at this point in the history
…ithout parentheses witchcrafters#45
  • Loading branch information
Vadim Tsvetkov committed Jun 22, 2022
1 parent 2e8b6d5 commit 78ea435
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/quark/curry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ defmodule Quark.Curry do
end

defp wrap([], body), do: body
defp wrap(nil, body), do: body
end
6 changes: 5 additions & 1 deletion lib/quark/partial.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ defmodule Quark.Partial do
#=> 3
"""
defmacro defpartial({fun_name, ctx, args}, do: body) do
defmacro defpartial({fun_name, ctx, nil}, do: body), do: defpartial_quote({fun_name, ctx, []}, do: body)

defmacro defpartial({fun_name, ctx, args}, do: body), do: defpartial_quote({fun_name, ctx, args}, do: body)

defp defpartial_quote({fun_name, ctx, args}, do: body) do
quote do
defcurry unquote({fun_name, ctx, args}), do: unquote(body)
unquote do: Enum.map(args_scan(args), &rehydrate(fun_name, ctx, &1))
Expand Down

0 comments on commit 78ea435

Please sign in to comment.