
28 Apr
2010
28 Apr
'10
5:51 p.m.
minh thu schrieb:
2010/4/28 Magicloud Magiclouds
: 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) 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