Add applyExplicitM9 (as a stopgap).

This commit is contained in:
Adam Sampson 2008-04-04 12:10:32 +00:00
parent e52b51b050
commit 8bbca0f760

View File

@ -20,7 +20,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
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