Move snocView in the file, nearer the other spliting functions
[ghc-hetmet.git] / compiler / utils / Util.lhs
index 279a108..4ce14ab 100644 (file)
@@ -303,6 +303,18 @@ listLengthCmp = atLength atLen atEnd
   atLen []     = EQ
   atLen _      = GT
 
+equalLength :: [a] -> [b] -> Bool
+equalLength [] []         = True
+equalLength (_:xs) (_:ys) = equalLength xs ys
+equalLength xs    ys      = False
+
+compareLength :: [a] -> [b] -> Ordering
+compareLength [] []         = EQ
+compareLength (_:xs) (_:ys) = compareLength xs ys
+compareLength [] _ys        = LT
+compareLength _xs []        = GT
+
+----------------------------
 singleton :: a -> [a]
 singleton x = [x]
 
@@ -314,15 +326,6 @@ notNull :: [a] -> Bool
 notNull [] = False
 notNull _  = True
 
-snocView :: [a] -> Maybe ([a],a)
-       -- Split off the last element
-snocView [] = Nothing
-snocView xs = go [] xs
-           where
-               -- Invariant: second arg is non-empty
-             go acc [x]    = Just (reverse acc, x)
-             go acc (x:xs) = go (x:acc) xs
-
 only :: [a] -> a
 #ifdef DEBUG
 only [a] = a
@@ -617,6 +620,15 @@ splitAtList (_:xs) (y:ys) = (y:ys', ys'')
     where
       (ys', ys'') = splitAtList xs ys
 
+snocView :: [a] -> Maybe ([a],a)
+       -- Split off the last element
+snocView [] = Nothing
+snocView xs = go [] xs
+           where
+               -- Invariant: second arg is non-empty
+             go acc [x]    = Just (reverse acc, x)
+             go acc (x:xs) = go (x:acc) xs
+
 split :: Char -> String -> [String]
 split c s = case rest of
                []     -> [chunk] 
@@ -648,17 +660,6 @@ eqListBy eq []     []     = True
 eqListBy eq (x:xs) (y:ys) = eq x y && eqListBy eq xs ys
 eqListBy eq xs     ys     = False
 
-equalLength :: [a] -> [b] -> Bool
-equalLength [] []         = True
-equalLength (_:xs) (_:ys) = equalLength xs ys
-equalLength xs    ys      = False
-
-compareLength :: [a] -> [b] -> Ordering
-compareLength [] []         = EQ
-compareLength (_:xs) (_:ys) = compareLength xs ys
-compareLength [] _ys        = LT
-compareLength _xs []        = GT
-
 cmpList :: (a -> a -> Ordering) -> [a] -> [a] -> Ordering
     -- `cmpList' uses a user-specified comparer