You can also do equality tests on type values, which means in your first
two cases you can use an if statement.

if someValue == A then
  stuff1
else
  stuff2

This only works if your type values aren't storing any data.

On Fri, Dec 9, 2016 at 7:25 AM, Petr Huřťák <petr.hur...@gmail.com> wrote:

> Hi,
>
> I would like hear some discussion on grouping of branches in `case of`
> statement . Currently it is not possible to use one branch for multiple
> conditions.
>
> Something along these lines:
>
> case someTypeValue of
>     A ->
>         -- code
>
>     B ->
>     C ->
>     D ->
>         -- different code
>
>
> Current alternative is this
>
> case someTypeValue of
>     let
>         stuff2 =
>             -- code
>     in
>         A ->
>             -- different code
>
>         B ->
>             stuff2
>
>         C ->
>             stuff2
>
>         D ->
>             stuff2
>
>
> Which is unnecessarily verbose and harder to read.
>
> One question is how this would work when there in cases where matched
> patterns have some values attached to them
>
> case someTypeValue of
>     A ->
>         -- stuff1
>
>
>     B _ ->
>     C _ _ ->
>     D _ _ _ ->
>         -- stuff2
>
> How is this handled in other languages like OCaml or Haskell?
>
> NOTE: moved from https://groups.google.com/forum/#!topic/elm-dev/
> DtUT2ieYTDo
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to