1
我想知道是否有人可以幫助我確定haskell代碼中非詳盡的部分?我看不出列表末尾沒有遇到基本情況。Haskell非耗盡
非常感謝
強尼
type Rule
= (Char, String)
type Rules
= [Rule]
type System
= (Float, String, Rules)
cross, triangle, arrowHead, peanoGosper,
dragon, snowflake, tree, bush :: System
type Vertex
= (Float, Float)
type TurtleState
= (Vertex, Float)
type Stack
= [TurtleState]
type ColouredLine
= (Vertex, Vertex, Colour)
trace :: String -> Float -> Colour -> [ColouredLine]
trace rules angle colour = traceState rules ((0,0),90) []
where
traceState :: String -> TurtleState -> Stack -> [ColouredLine]
traceState [] _ _ = []
traceState (x:xs) t (y:ys)
|x == '[' = traceState xs t (t : (y:ys))
|x == ']' = traceState xs t ys
|x == 'F' = biggieSmalls : traceState xs t (nextY:ys)
|otherwise = traceState xs angledY (angledY:ys)
where
biggieSmalls = (fst(t),fst(nextY),colour)
nextY = move 'F' t angle
angledY = move x t angle
您還沒有匹配'traceState [_] _ []'。如果您編譯時出現警告,GHC應舉出一個無與倫比的模式。 – 2014-10-30 18:40:39
將'-Wall'傳遞給ghc或ghci以啓用警告。 – chi 2014-10-30 19:34:47
非常感謝幫助傢伙!我怎樣才能解決這個問題?我已經開啓了警告(感謝Chi!)並試圖修復不匹配的模式(感謝Benjamin!)。我仍然在努力應付那些讓它變得正確的東西! – FoxGlove 2014-10-30 20:23:32