名前を定義する場所を定義しましたearthSecondsAYear。悲しいことに、それは前のwhere節の範囲に収まらない。私は何をしないのですsecondここでnameは前のwhere句の範囲にはありません
:14:34: error:
Variable not in scope: earthSecondsAYear
:
module SpaceAge (Planet(..), ageOn) where
data Planet = Mercury
| Venus
| Earth
| Mars
| Jupiter
| Saturn
| Uranus
| Neptune
ageOn :: Planet -> Float -> Float
ageOn planet seconds = (seconds/100) * planetYearSecs planet
where planetYearSecs Mercury = (earthSecondsAYear/100) * 0.2408
planetYearSecs Venus = 0.6151
planetYearSecs Mars = 1.8808
planetYearSecs Jupiter = 11.8626
planetYearSecs Saturn = 29.4474
planetYearSecs Uranus = 84.0168
planetYearSecs Neptune = 164.7913
planetYearSecs Earth = 100
where earthSecondsAYear = 31557600
エラーメッセージ:ここに
は、コードのですか?
'where'は' planetYearSecs Earth = 100'のすぐ上の定義にのみ適用されます。これはいつも私をかむ。 :) – Alec