我的編譯器抱怨兩個值:一些奇怪的故障(在我的模型記錄?)
在此摘錄model.firstChord.fifth
和model.secondChord.fifth
:
-- render frets
renderFret : Model -> Fret -> Html Msg
renderFret model fret =
let
(pitchName, pitchLevel) = fret.pitch
(firstChordRootPitchName, firstChordRootPitchLevel) = model.firstChord.root
(firstChordThirdPitchName, firstChordThirdPitchLevel) = model.firstChord.third
(firstChordFifthPitchName, firstChordFifthPitchLevel) = model.firstChord.fifth
(secondChordRootPitchName, secondChordRootPitchLevel) = model.secondChord.root
(secondChordThirdPitchName, secondChordThirdPitchLevel) = model.secondChord.third
(secondChordFifthPitchName, secondChordFifthPitchLevel) = model.secondChord.fifth
in
...
它告訴我:
model.firstChord
沒有名爲fifth
的字段。 - 類型的model.firstChord
是:也許和絃
不包含名爲
fifth
場。
但我的模型有一個字段fifth
:
-- initial model
init : (Model, Cmd Msg)
init =
(
{ firstChord =
Just
{ root = ("C", 3)
, third = ("E", 3)
, fifth = ("G", 3)
}
, secondChord =
Just
{ root = ("F", 3)
, third = ("A", 3)
, fifth = ("C", 4)
}
}
,
Cmd.none
)
類型的和絃是:
-- chords
type alias Chord =
{ root : Pitch
, third : Pitch
, fifth : Pitch
}
每個音都有此類型:
-- pitch
type alias Pitch = (PitchName, PitchLevel)
-- pitch name
type alias PitchName = String
-- pitch level
type alias PitchLevel = Int
哪裏能是問題嗎?
謝謝。
你確定它是'let'繼'case'? – Timo
'它看起來像關鍵字案例被用作一個變量。 - 將它重命名爲其他東西......這是消息。 – Timo
是的,這是一個錯誤。我修好了它。 –