Just checked, it's a known bug: https://github.com/elm-lang/elm-compiler/issues/1373
On Fri, May 20, 2016 at 3:24 PM, Joey Eremondi <[email protected]> wrote: > Try: > > type FilterType = TypeInt (NumberFilter Int) > > and so on. > > The way you have it now, the TypeInt constructor takes two arguments, one > of which is a NumFilter, and the other of which is an Int. But this is an > error, since NumFilter isn't a type, it's a type constructor. > > I think there actually might be a bug here, since your type declaration is > incorrect (NumFilter is not a type, but you use it as a type), so that > should be reported before we ever get to the pattern match. > > On Fri, May 20, 2016 at 3:19 PM, surfncode <[email protected]> wrote: > >> >> Hello, >> >> I seem unable to pattern match on this nested union. Here is the relevant >> code. The try it function is just here to test if the FIlterType union >> works (which doesn't seem to be the case so far) >> type FilterType = TypeInt NumberFilter Int | TypeFloat NumberFilter Float >> | TypeDate DateFilter | TypeEnum EnumFilter | TypeBool BoolFilter >> | TypeGroupBy Int | TypeFiles TextFilter | TypeText TextFilter >> >> type NumberFilter number= NumberIsEmpty | NumberIsNotEmpty | NumberIs >> number | NumberIsNot number | NumberLessThan number | NumberGreaterThan >> number >> | NumberLessOrEqualThan number | NumberGreaterOrEqualThan number | >> NumberGroupMinimum | NumberGroupMaximum >> | NumberGroupLowest Int | NumberGroupHighest Int >> >> tryIt : FilterType -> Bool >> tryIt ft = >> case ft of >> TypeText f -> processTextFilter f (Just "toto") >> TypeFiles f -> processTextFilter f (Just "titi") >> TypeInt f o -> >> case f of >> NumberIs _ -> o==2 -- This is the error line >> NumberIsNot _ -> o/=2 >> NumberIsEmpty -> False >> _ -> False >> _ -> False >> >> I run into this compilation error: >> >> ==== error in src/Model/Filter.elm:66:17: ==== >> Tag `Model.Filter.NumberIs` is causing problems in this pattern match. >> This pattern matches things of type: >> NumberFilter >> But the values it will actually be trying to match are: >> NumberFilter number >> >> I'm confused. I have tried quite a few variations but none of them work. >> >> Any ideas ? >> >> -- >> 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 [email protected]. >> 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
