功能跟踪中的非详尽模式'

Non-exhaustive patterns in function trace'

trace :: String -> Float -> Colour -> [ColouredLine]  
trace (c:cs) angle colour  
 = trace' (c:cs) angle colour (0.0,0.0)  
  where  
   trace' "" angle colour intvertex = []  
   trace' (c:cs) angle colour intvertex  
       | c == 'R' = trace' cs (angle-90) colour intvertex  
       | c == 'L' = trace' cs (angle+90) colour intvertex  
       | c == 'F' = [(intvertex,aftvertex,colour)] ++ trace' cs angle colour aftvertex  
         where  
           aftvertex = fst (move 'F' (intvertex,angle) angle) 

报告:

trace "F[RF][LF][FF]" 45.0 (1.0,0.0,0.0) = Exception: LSystems.hs:(95,4)-(101,61): Non-exhaustive patterns in function trace'

预期的测试用例:

[((-8.742278e-8,2.0),(-1.3113416e-7,3.0),(1.0,0.0,0.0)),((-4.371139e-8,1.0),(-0.7071068,1.7071068),(1.0,0.0,0.0)),((-4.371139e-8,1.0),(-8.742278e-8,2.0),(1.0,0.0,0.0)),((-4.371139e-8,1.0),(0.7071067,1.7071068),(1.0,0.0,0.0)),((0.0,0.0),(-4.371139e-8,1.0),(1.0,0.0,0.0))]

您的测试字符串包含“[”和“]”,但您在模式匹配中仅匹配 'R'、'L' 和 'F'。因此,一旦它到达方括​​号,就会出现异常。