# Patternr - experiment with pattern matching

**URL:** <https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566>\
**Category:** Discussions\
**Tags:** pattern-matching, liveview\
**Created:** [February 15, 2021, 8:18pm UTC](https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566 "2021-02-15T20:18:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![serras](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/serras/32/21860_2.png) [@serras](https://forum.elixirforum.com/u/serras)\
**Post date:** [February 15, 2021, 8:18pm UTC](https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566/1 "2021-02-15T20:18:07Z")

</div>

Hi! I’ve created a small application to help learners experiment with pattern matching, [https://www.patternr.dev/](https://www.patternr.dev/). It currently supports (a subset of) Elixir and Haskell syntax. I’m happy to hearn any suggestions you may have 🙂

PS: It’s my first app built with LiveView, and the experience has been great!

---

<div class="post-metadata">

**Author:** ![axelson](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/axelson/32/26351_2.png) [@axelson](https://forum.elixirforum.com/u/axelson)\
**Post date:** [February 16, 2021, 12:14am UTC](https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566/2 "2021-02-16T00:14:41Z")

</div>

This looks like a really neat project! I think it would be really helpful to have a couple links that will prefix an example pattern so users can easily see working examples of supported patterns.

Also it would be good if more complex patterns were accepted:

 ![image](https://forum.elixirforum.com/uploads/default/original/3X/4/b/4be014e4799ff1d03a7a02ab3e31b04a2cf72665.jpeg)

And a minor improvement would be to change “Incorrect Pattern” to “Invalid Pattern”. Incorrect doesn’t really match because you don’t know the users intention.

But overall great job!

---

<div class="post-metadata">

**Author:** ![serras](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/serras/32/21860_2.png) [@serras](https://forum.elixirforum.com/u/serras)\
**Post date:** [February 16, 2021, 4:08pm UTC](https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566/3 "2021-02-16T16:08:08Z")

</div>

Thanks for the comments 🙂 I have implemented your suggestions, and the patterns in the image work now.

As an aside: is there a spec of Elixir’s patterns? I could not find a definite spec, only tutorials and more informal descriptions.

---

<div class="post-metadata">

**Author:** ![eksperimental](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eksperimental/32/1401_2.png) [@eksperimental](https://forum.elixirforum.com/u/eksperimental)\
**Post date:** [February 16, 2021, 4:47pm UTC](https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566/4 "2021-02-16T16:47:39Z")

</div>

Hi, here are some suggestions

1. `case 1..2` does not work

2. `case 1 when x when is_integer(x) -> ` does not work either (maybe guards are not supported yet)

3. I would add an `end` to the the template

```elixir
case [TERM] do
  [PATTERN] -> ...
end

```

---

<div class="post-metadata">

**Author:** ![eksperimental](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eksperimental/32/1401_2.png) [@eksperimental](https://forum.elixirforum.com/u/eksperimental)\
**Post date:** [February 16, 2021, 4:54pm UTC](https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566/5 "2021-02-16T16:54:22Z")

</div>

it is kind of confusing that when the header is purple, it is not Elixir, but Haskell. I guess the both use the same color, but that reddish color for Elixir is disguising

---

<div class="post-metadata">

**Author:** ![serras](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/serras/32/21860_2.png) [@serras](https://forum.elixirforum.com/u/serras)\
**Post date:** [February 16, 2021, 7:44pm UTC](https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566/6 "2021-02-16T19:44:57Z")

</div>

Interesting, I’ve always seen orange as the “Elixir color”, maybe because of the several books which use that color. In any case, I’m changing it now to the same background used in Elixir Forums, which is a nice purple 🙂

---

<div class="post-metadata">

**Author:** ![serras](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/serras/32/21860_2.png) [@serras](https://forum.elixirforum.com/u/serras)\
**Post date:** [February 16, 2021, 8:12pm UTC](https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566/7 "2021-02-16T20:12:43Z")

</div>

Thanks for the feedback. I’ve added support for ranges and ‘end’ to finish the block correctly.

---

<div class="post-metadata">

**Author:** ![Exadra37](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/exadra37/32/9183_2.png) [@Exadra37](https://forum.elixirforum.com/u/Exadra37)\
**Post date:** [February 16, 2021, 9:09pm UTC](https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566/8 "2021-02-16T21:09:02Z")

</div>

> [@serras](#):
>
> Interesting, I’ve always seen orange as the “Elixir color”,

That is the Phoenix color 😉

---

<div class="post-metadata">

**Author:** ![Sebb](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sebb/32/21818_2.png) [@Sebb](https://forum.elixirforum.com/u/Sebb)\
**Post date:** [February 16, 2021, 9:21pm UTC](https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566/9 "2021-02-16T21:21:41Z")

</div>

Very nice!

Are you planning to implement binaries\* and non-atom-keys?

\*) Please! Just to tease the Haskellers 🤓

---

<div class="post-metadata">

**Author:** ![serras](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/serras/32/21860_2.png) [@serras](https://forum.elixirforum.com/u/serras)\
**Post date:** [February 18, 2021, 4:22pm UTC](https://forum.elixirforum.com/t/patternr-experiment-with-pattern-matching/37566/10 "2021-02-18T16:22:17Z")

</div>

Implementing binary matching is really hard. But my PRs are open 😉
