Thx for the first Help. Now I changed this. but still a bog error. Is my whole Code wrong or just the part with the weekdays function. How can i call a function inside another function?
data Wochentag = Mo | Di | Mi | Do | Fr | Sa | So
deriving (Eq, Ord, Show, Enum)
data Month = Jan | Feb | März | April | Mai | Juni | Juli | Aug | Sep | Okt | Nov | Dec
deriving (Eq, Ord, Show, Enum)
weekday :: Integer -> Month -> Integer -> Wochentag
weekday day month year = weekdays day (zahlmonth month) year
y1 = year - (14 - zahlmonth) /12
x = y1 + (y1 /4) - (y1 /100) + (y1 /400)
m = zahlmonth + 12 * ((14- zahlmonth) /12) -2
weekdays day zahlmonth year
| mod (day + x + ((31*m) / 12)) 7 == 0 = So
| mod (day + x + ((31*m) / 12)) 7 == 1 = Mo
| mod (day + x + ((31*m) / 12)) 7 == 2 = Di
| mod (day + x + ((31*m) / 12)) 7 == 3 = Mi
| mod (day + x + ((31*m) / 12)) 7 == 4 = Do
| mod (day + x + ((31*m) / 12)) 7 == 5 = Fr
| mod (day + x + ((31*m) / 12)) 7 == 6 = Sa
| otherwise = error "kein Tag"
zahlmonth :: Month -> Integer
zahlmonth month = case month of
Jan -> 1
Feb -> 2
März -> 3
April -> 4
Mai -> 5
Juni -> 6
Juli -> 7
Aug -> 8
Sep -> 9
Okt -> 10
Nov -> 11
Dec -> 12
The error Log is:
Couldn't match expected type `Month -> Integer'
with actual type `Integer'
* In the first argument of `weekdays', namely `day'
In the expression: weekdays day (zahlmonth month) year
In an equation for `weekday':
weekday day month year = weekdays day (zahlmonth month) year
|
95 | weekday day month year = weekdays day (zahlmonth month) year
| ^^^
Variable not in scope: year :: Month -> Integer
|
97 | y1 = year - (14 - zahlmonth) /12
| ^^^^
Totally strange but have no idea how to fix it. When i give weekdays an description it becomes even worse.