Fixed the apply function, which (mainly due to having the wrong type signature, but also its use of extTransformRoute) was not as polymorphic as it should have been, which was breaking the traversal (I think it would only work on one Structured type)
This commit is contained in:
parent
9be287f157
commit
e5ed7e07b7
|
@ -289,13 +289,12 @@ traverse typeSet f route tr
|
|||
|
||||
-- The return of this function is ignored. All changes should be done in the
|
||||
-- state.
|
||||
apply :: forall a. Data a => TypeSet -> (a -> CheckOptM' a ()) ->
|
||||
(a, Route a A.AST) -> RestartT CheckOptM a
|
||||
apply :: TypeSet -> (forall a. Data a => a -> CheckOptM' a ()) ->
|
||||
(forall b. Data b => (b, Route b A.AST) -> RestartT CheckOptM b)
|
||||
apply typeSet f (x, route)
|
||||
= (flip runReaderT route (deCheckOptM' (f x)))
|
||||
>> (lift (CheckOptM get) >>* ast >>* routeGet route)
|
||||
>>= gmapMForRoute typeSet (extTransformRoute baseTransformRoute $
|
||||
\(y, route') -> apply typeSet f (y, route @-> route'))
|
||||
= (lift . CheckOptM $ modify $ \d -> if findMeta x == emptyMeta then d else d {lastValidMeta = findMeta x})
|
||||
>> (flip runReaderT route (deCheckOptM' (f x)))
|
||||
>> gmapMForRoute typeSet (\(y, route') -> apply typeSet f (y, route @-> route')) x
|
||||
|
||||
-- | For both of these functions I'm going to need to mark all analyses as no longer
|
||||
-- valid, but more difficult will be to maintain the current position (if possible
|
||||
|
|
|
@ -30,7 +30,6 @@ module GenericUtils (
|
|||
, gmapMForRoute
|
||||
, routeModify, routeGet, routeSet, Route(..), (@->), routeIdentity, routeId, routeList
|
||||
, route22, route23, route33, route34, route44, route45, route55
|
||||
, baseTransformRoute, extTransformRoute
|
||||
) where
|
||||
|
||||
import Control.Monad.Identity
|
||||
|
@ -42,7 +41,6 @@ import Data.IntSet (IntSet)
|
|||
import qualified Data.IntSet as IntSet
|
||||
import Data.List
|
||||
import Data.Typeable
|
||||
import GHC.Base (unsafeCoerce#)
|
||||
import System.IO.Unsafe
|
||||
|
||||
import qualified AST as A
|
||||
|
@ -220,17 +218,6 @@ gmapMWithRoute f = gmapFuncs [GM {unGM = f' n} | n <- [0..]]
|
|||
f' :: Int -> (forall b. Data b => b -> m b)
|
||||
f' n x = f (x, makeRoute n)
|
||||
|
||||
baseTransformRoute :: forall m s t. (Data s, Monad m) => (s, Route s t) -> m s
|
||||
baseTransformRoute (x, _) = return x
|
||||
|
||||
extTransformRoute :: forall s m t. (Data s, Monad m) => (forall a. Data a => (a, Route a t) -> m a) -> ((s, Route s t) -> m
|
||||
s) -> (forall a. Data a => (a, Route a t) -> m a)
|
||||
extTransformRoute generalFunc specificFunc (x, route)
|
||||
= case cast x of
|
||||
Just x' -> do Just y <- specificFunc (x', unsafeCoerce# route) >>* cast
|
||||
return y
|
||||
Nothing -> generalFunc (x, route)
|
||||
|
||||
-- Given a number, makes a route function for that child:
|
||||
makeRoute :: (Data s, Data t) => Int -> Route s t
|
||||
makeRoute target = Route [target] (\f -> gmapFuncs [mkM' (if n == target then f else return) | n <- [0..]])
|
||||
|
|
Loading…
Reference in New Issue
Block a user