You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current generator syntax--e.g. for_all x in int--requires that I learn a new syntax, but it sure looks similar to Elixir's existing for comprehension syntax. Is there any reason that can't be used instead?
For example, looking over the examples in the readme:
property:squaredofor_allxinint,do: x*x>=0end
Could be:
property:squredoforx<-int,do: x*x>=0end
For a more involved example involving a such_that like:
I just tried ExCheck for the first time today so I'm sure there are aspects of it's API I'm not understanding, but it would greatly reduce the learning curve if my existing knowledge of Elixir's for comprehensions could be used instead of learning a new API.
The text was updated successfully, but these errors were encountered:
It should be possible since all those constructs are based upon macros which basically expand the language. I think parroty made them the way they are so the API looks similar to triq syntax, but this syntax does indeed look really nice and intuitive.
A quick experiment using macros:
Interactive Elixir (1.3.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> quote do: for x <- [1,2,3], do: x
{:for, [], [{:<-, [], [{:x, [], Elixir}, [1, 2, 3]]}, [do: {:x, [], Elixir}]]}
iex(2)> quote do: for x <- [1,2,3], x < 2, do: x
{:for, [],
[{:<-, [], [{:x, [], Elixir}, [1, 2, 3]]},
{:<, [context: Elixir, import: Kernel], [{:x, [], Elixir}, 2]},
[do: {:x, [], Elixir}]]}
It should be possible with the power of macros.
Maybe we could even keep the constructs we have now and just build these macros on top of them in order to reduce the amount of work..
The current generator syntax--e.g.
for_all x in int
--requires that I learn a new syntax, but it sure looks similar to Elixir's existingfor
comprehension syntax. Is there any reason that can't be used instead?For example, looking over the examples in the readme:
Could be:
For a more involved example involving a
such_that
like:Could perhaps be:
I just tried ExCheck for the first time today so I'm sure there are aspects of it's API I'm not understanding, but it would greatly reduce the learning curve if my existing knowledge of Elixir's
for
comprehensions could be used instead of learning a new API.The text was updated successfully, but these errors were encountered: