From 8bbca0f7601891253efca6091b6f4b9b888c9d80 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Fri, 4 Apr 2008 12:10:32 +0000 Subject: [PATCH] Add applyExplicitM9 (as a stopgap). --- pass/Traversal.hs | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/pass/Traversal.hs b/pass/Traversal.hs index e3aab56..cd55b28 100644 --- a/pass/Traversal.hs +++ b/pass/Traversal.hs @@ -20,7 +20,7 @@ with this program. If not, see . module Traversal ( ExplicitTrans, Transform, Check , transformToExplicitDepth, checkToTransform - , applyExplicitM, applyExplicitM2 + , applyExplicitM, applyExplicitM2, applyExplicitM9 , applyDepthM, applyDepthM2 , checkDepthM ) where @@ -83,6 +83,49 @@ applyExplicitM2 f1 f2 = doGeneric `extM` (doSpecific f1) doSpecific :: Data t => ExplicitTrans t -> t -> PassM t doSpecific f x = f doGeneric x +-- | Apply nine explicit transformations (!). +applyExplicitM9 :: forall t1 t2 t3 t4 t5 t6 t7 t8 t9 s. + (Data t1, Data t2, Data t3, Data t4, Data t5, Data t6, + Data t7, Data t8, Data t9, Data s) => + ExplicitTrans t1 + -> ExplicitTrans t2 + -> ExplicitTrans t3 + -> ExplicitTrans t4 + -> ExplicitTrans t5 + -> ExplicitTrans t6 + -> ExplicitTrans t7 + -> ExplicitTrans t8 + -> ExplicitTrans t9 + -> s -> PassM s +applyExplicitM9 f1 f2 f3 f4 f5 f6 f7 f8 f9 + = doGeneric `extM` (doSpecific f1) + `extM` (doSpecific f2) + `extM` (doSpecific f3) + `extM` (doSpecific f4) + `extM` (doSpecific f5) + `extM` (doSpecific f6) + `extM` (doSpecific f7) + `extM` (doSpecific f8) + `extM` (doSpecific f9) + where + typeSet :: [TypeKey] + typeSet = [ typeKey (undefined :: t1) + , typeKey (undefined :: t2) + , typeKey (undefined :: t3) + , typeKey (undefined :: t4) + , typeKey (undefined :: t5) + , typeKey (undefined :: t6) + , typeKey (undefined :: t7) + , typeKey (undefined :: t8) + , typeKey (undefined :: t9) + ] + + doGeneric :: Data t => t -> PassM t + doGeneric = gmapMFor typeSet (applyExplicitM9 f1 f2 f3 f4 f5 f6 f7 f8 f9) + + doSpecific :: Data t => ExplicitTrans t -> t -> PassM t + doSpecific f x = f doGeneric x + -- | Apply a transformation, recursing depth-first. applyDepthM :: forall t1 s. (Data t1, Data s) => Transform t1 -> s -> PassM s