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

Witchcraft.Chain.do_notation/2 intentionally ignores chainer #108

Open
florius0 opened this issue Jan 28, 2022 · 0 comments · May be fixed by #118
Open

Witchcraft.Chain.do_notation/2 intentionally ignores chainer #108

florius0 opened this issue Jan 28, 2022 · 0 comments · May be fixed by #118

Comments

@florius0
Copy link
Contributor

As far as I see, there are multiple places where second argument of chainer is used:

def do_notation(input, _chainer) do
input
|> normalize()
|> Enum.reverse()
|> Witchcraft.Foldable.left_fold(fn
continue, {:let, _, [{:=, _, [assign, value]}]} ->
quote do: unquote(value) |> (fn unquote(assign) -> unquote(continue) end).()
continue, {:<-, _, [assign, value]} ->
quote do
import Witchcraft.Chain, only: [>>>: 2]
unquote(value) >>> fn unquote(assign) -> unquote(continue) end
end
continue, value ->
quote do
import Witchcraft.Chain, only: [>>>: 2]
unquote(value) >>> fn _ -> unquote(continue) end
end
end)
end

Instead >>> (Witchcraft.Chain.chain) is used.

Is it designed to be so, or it is a typo?

PS IMO it should be

def do_notation(input, chainer) do
  input
  |> normalize()
  |> Enum.reverse()
  |> Witchcraft.Foldable.left_fold(fn
    continue, {:let, _, [{:=, _, [assign, value]}]} ->
      quote do: unquote(value) |> (fn unquote(assign) -> unquote(continue) end).()

    continue, {:<-, _, [assign, value]} ->
      quote do
        apply(unquote(chainer), [unquote(value), fn unquote(assign) -> unquote(continue) end])
      end

    continue, value ->
      quote do
        apply(unquote(chainer), [unquote(value), fn _ -> unquote(continue) end])
      end
  end)
end
@florius0 florius0 linked a pull request Apr 16, 2022 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant