Added the Polyplate modules to the Tock build system and fixed various errors

This commit is contained in:
Neil Brown 2008-12-02 13:08:38 +00:00
parent 8b28fee077
commit 77251b842c
3 changed files with 16 additions and 10 deletions

View File

@ -19,6 +19,7 @@ GHC_OPTS = \
-iflow \
-ifrontends \
-ipass \
-ipolyplate \
-ipregen \
-itransformations
@ -188,6 +189,8 @@ tock_SOURCES_hs += pass/Pass.hs
tock_SOURCES_hs += pass/PassList.hs
tock_SOURCES_hs += pass/Properties.hs
tock_SOURCES_hs += pass/Traversal.hs
tock_SOURCES_hs += polyplate/Data/Generics/Polyplate.hs
tock_SOURCES_hs += polyplate/Data/Generics/Polyplate/Schemes.hs
tock_SOURCES_hs += transformations/ImplicitMobility.hs
tock_SOURCES_hs += transformations/SimplifyAbbrevs.hs
tock_SOURCES_hs += transformations/SimplifyComms.hs

View File

@ -31,7 +31,9 @@ module Data.Generics.Polyplate (PolyplateM(..), Polyplate(..),
makeRecurseM, RecurseM,
makeDescendM, DescendM,
BaseOp, baseOp,
ExtOpM, extOp, OneOpM) where
ExtOpM, extOpM, ExtOp, extOp, OneOpM, OneOp, TwoOpM, TwoOp) where
import Control.Monad.Identity
-- | The main Polyplate type-class.
--
@ -90,20 +92,20 @@ class Polyplate t o o' where
transform :: o -> o' -> t -> t
instance (PolyplateM t mo mo' Identity, ConvertOpsToIdentity o mo, ConvertOpsToIdentity o' mo') => Polyplate t o o' where
transform o o' t = runIdentity (transformM o o' t)
transform o o' t = runIdentity (transformM (convertOpsToIdentity o) (convertOpsToIdentity o') t)
-- | A type representing a recursive monadic modifier function that applies the given ops
-- (in the given monad) directly to the given type.
type RecurseM m opT = forall t. Polyplate t opT () m => t -> m t
type RecurseM m opT = forall t. PolyplateM t opT () m => t -> m t
-- | Given a set of operations (as described in the 'PolyplateM' type-class),
-- makes a recursive modifier function.
makeRecurseM :: Monad m => opT -> Recurse m opT
makeRecurseM :: Monad m => opT -> RecurseM m opT
makeRecurseM ops = transformM ops ()
type DescendM m opT = forall t. Polyplate t () opT m => t -> m t
type DescendM m opT = forall t. PolyplateM t () opT m => t -> m t
makeDescendM :: Monad m => opT -> Descend m opT
makeDescendM :: Monad m => opT -> DescendM m opT
makeDescendM ops = transformM () ops
-- | The type of the empty set of operations
@ -138,10 +140,10 @@ extOp ops f = (f, ops)
-- | A handy synonym for an ops set with only one item.
type OneOpM m t = ExtOpM m BaseOp t
-- | A handy synonym for an ops set with only one item.
type OneOp t = ExtOpM m BaseOp t
type OneOp t = ExtOp BaseOp t
-- | A handy synonym for an ops set with only two items.
type TwoOpM m s t = ExtOpM m (ExtOpM m BaseOp s) t
-- | A handy synonym for an ops set with only two items.
type TwoOp s t = ExtOpM (ExtOp BaseOp s) t
type TwoOp s t = ExtOp (ExtOp BaseOp s) t

View File

@ -19,6 +19,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
module Data.Generics.Polyplate.Schemes where
import Data.Generics.Polyplate
-- | Given a list of operations and a modifier function, augments that modifier
-- function to first descend into the value before then applying the modifier function.
@ -27,7 +28,7 @@ module Data.Generics.Polyplate.Schemes where
makeBottomUpM :: PolyplateM t () opT m => opT -> (t -> m t) -> t -> m t
makeBottomUpM ops f v = descend v >>= f
where
descend = makeDescend ops
descend = makeDescendM ops
-- | Given a list of operations and a modifier function, augments that modifier
-- function to first apply the modifier function before then descending into the value.
@ -36,7 +37,7 @@ makeBottomUpM ops f v = descend v >>= f
makeTopDownM :: PolyplateM t () opT m => opT -> (t -> m t) -> t -> m t
makeTopDownM ops f v = f v >>= descend
where
descend = makeDescend ops
descend = makeDescendM ops
-- | Given a list of operations and a modifier function, augments that modifier
-- function to first descend into the value before then applying the modifier function.