fix extraction of command stack of arguments of arrow "forms" (fixes #4236)
authorRoss Paterson <ross@soi.city.ac.uk>
Sun, 22 Aug 2010 09:00:22 +0000 (09:00 +0000)
committerRoss Paterson <ross@soi.city.ac.uk>
Sun, 22 Aug 2010 09:00:22 +0000 (09:00 +0000)
The command stack was being extracted (by unscramble) with the outermost
type first, contrary to the comment on the function.

compiler/typecheck/TcArrows.lhs

index 9fede38..231901c 100644 (file)
@@ -294,14 +294,13 @@ tc_cmd env cmd@(HsArrForm expr fixity cmd_args) (cmd_stk, res_ty)
 
     unscramble :: TcType -> (TcType, [TcType])
     -- unscramble ((w,s1) .. sn)       =  (w, [s1..sn])
-    unscramble ty
+    unscramble ty = unscramble' ty []
+
+    unscramble' ty ss
        = case tcSplitTyConApp_maybe ty of
            Just (tc, [t,s]) | tc == pairTyCon 
-              ->  let 
-                     (w,ss) = unscramble t  
-                  in (w, s:ss)
-                                   
-           _ -> (ty, [])
+              ->  unscramble' t (s:ss)
+           _ -> (ty, ss)
 
 -----------------------------------------------------------------
 --             Base case for illegal commands