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

fmap alias <~ is not working #80

Open
21it opened this issue Mar 7, 2020 · 2 comments
Open

fmap alias <~ is not working #80

21it opened this issue Mar 7, 2020 · 2 comments

Comments

@21it
Copy link

21it commented Mar 7, 2020

fmap alias <~ is not working:

iex(1)> use Witchcraft                                                             
Witchcraft.Comonad                                                                 
iex(2)> &(&1+1) <~ [1, 2, 3]                                                       
#Function<7.126501267/1 in :erl_eval.expr/5>
@asianfilm
Copy link

The following works, so perhaps it's only an issue with the shorthand form when using <~:

fn x -> x + 1 end <~ [1,2,3]

It's probably a separate issue, but I have had nested captures via & are not allowed errors whilst using Witchcraft when trying to chain (not nest) anonymous functions, which I've always resolved by using the fn ... end longhand form. Looking at the examples on various conference slides for the Witchcraft suite, I think this is a known issue and I assume it's to do with how it's shoehorned into Elixir.

@21it
Copy link
Author

21it commented Apr 10, 2020

Actually additional brackets fix behaviour. But result of expression without brackets is completely unexpected. It should be compilation error in my opinion (if it can't be fixed).

iex(1)> use Witchcraft
Witchcraft.Comonad
iex(2)> &(&1+1) <~ [1, 2, 3]
#Function<7.126501267/1 in :erl_eval.expr/5>
iex(3)> (&(&1+1)) <~ [1, 2, 3]
[2, 3, 4]

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

No branches or pull requests

2 participants