diff --git a/common/OccamEDSL.hs b/common/OccamEDSL.hs index 336597d..b68ef0f 100644 --- a/common/OccamEDSL.hs +++ b/common/OccamEDSL.hs @@ -402,7 +402,7 @@ testOccamPassTransform str trans code pass (exp, expS) = runState expm emptyState (inp, inpS) = runState inpm emptyState in TestCase $ testPassWithStateCheck str (trans $ mkPattern exp) pass inp (put inpS) (testPatternMatchOneOf - (str ++ " state check") [trans $ mkPattern pr | pr <- permutations $ Map.toList $ csNames expS] . Map.toList + (str ++ " state check") [trans $ mkPattern pr | pr <- permutation $ Map.toList $ csNames expS] . Map.toList . csNames) -- It's important to convert the maps to lists first, as Map doesn't have a -- Data instance. diff --git a/common/Utils.hs b/common/Utils.hs index 6a830e6..46c731e 100644 --- a/common/Utils.hs +++ b/common/Utils.hs @@ -241,9 +241,13 @@ productN (xs:xss) = [ y : ys | y <- xs, ys <- yss] -- -- Code is taken from: http://www.haskell.org/pipermail/haskell/2006-July/018298.html -- and then fixed (missing base case, x should have been y) -permutations :: [a] -> [[a]] -permutations [] = [[]] -permutations xs = [y : ps | (y,ys) <- selections xs, ps <- permutations ys] +-- +-- Since GHC 6.10 onwards includes a permutations function, but we don't want to +-- have to mess with the GHC preprocessor just to exclude this one function, I've +-- renamed ours to permutation. +permutation :: [a] -> [[a]] +permutation [] = [[]] +permutation xs = [y : ps | (y,ys) <- selections xs, ps <- permutation ys] where selections [] = [] selections (x:xs) = (x,xs) : [(y,x:ys) | (y,ys) <- selections xs]