Skip to content

Commit

Permalink
Closes #7. Cumbersome bitstring matches are not supported.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Matiushkin committed Sep 18, 2019
1 parent a05d8a0 commit fdf35d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .iex.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import_file("~/.iex.exs")
import LazyFor
18 changes: 18 additions & 0 deletions lib/lazy_for.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,24 @@ defmodule LazyFor do
defp clause({:=, meta, [var, expression]}, inner, acc),
do: clause({:<-, meta, [var, [expression]]}, inner, acc)

# TODO
# stream <<r::8, g::8, b::8 <- pixels>>, do: {r, g, b}
# {{:<<>>, _,
# [
# {:"::", _, [{:r, _, nil}, 8]},
# {:"::", _, [{:g, _, nil}, 8]},
# {:<-, _, [{:"::", _, [{:b, _, nil}, 8]}, {:pixels, _, nil}]}
# ]}, {:{}, _, [{:r, _, nil}, {:g, _, nil}, {:b, _, nil}]}}

# binary string
defp clause({:<<>>, _, [{:<-, meta, [var, source]}]}, inner, acc) when is_bitstring(source),
do:
clause(
{:<-, meta, [var, {{:., [], [:erlang, :bitstring_to_list]}, [], [source]}]},
inner,
acc
)

# condition
defp clause(guard, {__s__(), _, _} = inner, _acc),
do: {sfilter(), [], [inner, {:fn, [], [{:->, [], [[{:_, [], Elixir}], guard]}]}]}
Expand Down

0 comments on commit fdf35d2

Please sign in to comment.