Sorry folks, I did not make it clear. The firstDayOfMonth and lastDayOfMonth was defined earlier in let ... in structure. The problem here is, ghc warned me that "_" and "lastDayOfMonth" was overlapped. And the results showed that, everything that should be worked with "Mider" was done by "not_ ...".
On Thu, Apr 29, 2010 at 1:51 AM, Henning Thielemann <schlepp...@henning-thielemann.de> wrote: > minh thu schrieb: >> 2010/4/28 Magicloud Magiclouds <magicloud.magiclo...@gmail.com>: >>> Hi, I have code as below. How come "case" version works wrong and >>> gives me "overlap" compiling warning? Thanks. >>> if dayOfMonth == firstDayOfMonth >>> then v day (x, y)S >>> else if dayOfMonth == lastDayOfMonth >>> then not_ $ v day (x, y) >>> else Mider day (x, y) >>> >>> case dayOfMonth of >>> firstDayOfMonth -> v day (x, y) >>> lastDay -> not_ $ v day (x, y) >>> _ -> Mider day (x, y) >> >> Hi, >> >> firstDayIfMonth and lastDay are new variables, not previously bound >> variable. This means that trying to pattern match (the value of) >> dayOfMonth will always succeed with the first alternative. > > You can however simulate a 'case' with predefined variables: > http://haskell.org/haskellwiki/Case > -- 竹密岂妨流水过 山高哪阻野云飞 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe