Commit 4a1b418e authored by simonpj's avatar simonpj
Browse files

[project @ 2001-07-19 09:26:08 by simonpj]

Move eqListBy to Util, and use it
parent 2ab55bbc
...@@ -26,7 +26,7 @@ module HsCore ( ...@@ -26,7 +26,7 @@ module HsCore (
-- friends: -- friends:
import HsTypes ( HsType, pprParendHsType, pprHsTyVarBndr, toHsType, import HsTypes ( HsType, pprParendHsType, pprHsTyVarBndr, toHsType,
HsTupCon(..), EqHsEnv, hsTupParens, HsTupCon(..), EqHsEnv, hsTupParens,
emptyEqHsEnv, extendEqHsEnv, eqListBy, emptyEqHsEnv, extendEqHsEnv,
eq_hsType, eq_hsVars eq_hsType, eq_hsVars
) )
...@@ -48,6 +48,7 @@ import Type ( Kind, eqKind ) ...@@ -48,6 +48,7 @@ import Type ( Kind, eqKind )
import BasicTypes ( Arity ) import BasicTypes ( Arity )
import FiniteMap ( lookupFM ) import FiniteMap ( lookupFM )
import CostCentre import CostCentre
import Util ( eqListBy )
import Outputable import Outputable
\end{code} \end{code}
......
...@@ -42,6 +42,7 @@ import FunDeps ( pprFundeps ) ...@@ -42,6 +42,7 @@ import FunDeps ( pprFundeps )
import Class ( FunDep, DefMeth(..) ) import Class ( FunDep, DefMeth(..) )
import CStrings ( CLabelString ) import CStrings ( CLabelString )
import Outputable import Outputable
import Util ( eqListBy )
import SrcLoc ( SrcLoc ) import SrcLoc ( SrcLoc )
import FastString import FastString
\end{code} \end{code}
......
...@@ -46,6 +46,7 @@ import PrelNames ( mkTupConRdrName, listTyConKey, usOnceTyConKey, usManyTyConKey ...@@ -46,6 +46,7 @@ import PrelNames ( mkTupConRdrName, listTyConKey, usOnceTyConKey, usManyTyConKey
usOnceTyConName, usManyTyConName usOnceTyConName, usManyTyConName
) )
import FiniteMap import FiniteMap
import Util ( eqListBy )
import Outputable import Outputable
\end{code} \end{code}
...@@ -470,10 +471,4 @@ eq_hsPred env (HsClassP c1 tys1) (HsClassP c2 tys2) ...@@ -470,10 +471,4 @@ eq_hsPred env (HsClassP c1 tys1) (HsClassP c2 tys2)
eq_hsPred env (HsIParam n1 ty1) (HsIParam n2 ty2) eq_hsPred env (HsIParam n1 ty1) (HsIParam n2 ty2)
= n1 == n2 && eq_hsType env ty1 ty2 = n1 == n2 && eq_hsType env ty1 ty2
eq_hsPred env _ _ = False eq_hsPred env _ _ = False
-------------------
eqListBy :: (a->a->Bool) -> [a] -> [a] -> Bool
eqListBy eq [] [] = True
eqListBy eq (x:xs) (y:ys) = eq x y && eqListBy eq xs ys
eqListBy eq xs ys = False
\end{code} \end{code}
...@@ -41,7 +41,7 @@ module Util ( ...@@ -41,7 +41,7 @@ module Util (
foldl2, count, foldl2, count,
-- comparisons -- comparisons
thenCmp, cmpList, prefixMatch, suffixMatch, eqListBy, thenCmp, cmpList, prefixMatch, suffixMatch,
-- strictness -- strictness
foldl', seqList, foldl', seqList,
...@@ -639,6 +639,11 @@ count p (x:xs) | p x = 1 + count p xs ...@@ -639,6 +639,11 @@ count p (x:xs) | p x = 1 + count p xs
%************************************************************************ %************************************************************************
\begin{code} \begin{code}
eqListBy :: (a->a->Bool) -> [a] -> [a] -> Bool
eqListBy eq [] [] = True
eqListBy eq (x:xs) (y:ys) = eq x y && eqListBy eq xs ys
eqListBy eq xs ys = False
thenCmp :: Ordering -> Ordering -> Ordering thenCmp :: Ordering -> Ordering -> Ordering
{-# INLINE thenCmp #-} {-# INLINE thenCmp #-}
thenCmp EQ any = any thenCmp EQ any = any
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment