Skip to content

Commit

Permalink
[ Refactor ] Moved checkSyntacticEquality from TCM to ReduceM
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesper Cockx committed Oct 16, 2015
1 parent cc13509 commit d52b5b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/full/Agda/TypeChecking/Conversion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ compareTerm cmp a u v = do
checkPointerEquality def = def
checkPointerEquality $ do
-- Check syntactic equality. This actually saves us quite a bit of work.
((u, v), equal) <- SynEq.checkSyntacticEquality u v
((u, v), equal) <- runReduceM $ SynEq.checkSyntacticEquality u v
-- OLD CODE, traverses the *full* terms u v at each step, even if they
-- are different somewhere. Leads to infeasibility in issue 854.
-- (u, v) <- instantiateFull (u, v)
Expand Down
19 changes: 10 additions & 9 deletions src/full/Agda/TypeChecking/SyntacticEquality.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import Control.Monad.State hiding (mapM)
import Agda.Syntax.Common
import Agda.Syntax.Internal

import Agda.TypeChecking.Monad
import Agda.TypeChecking.Reduce (instantiate)
import Agda.TypeChecking.Monad (ReduceM)
import Agda.TypeChecking.Reduce
import Agda.TypeChecking.Reduce.Monad
import Agda.TypeChecking.Substitute

import Agda.Utils.Monad (ifM)
Expand All @@ -43,13 +44,13 @@ import Agda.Utils.Impossible
-- only that @v,v'@ are only fully instantiated to the depth
-- where they are equal.

{-# SPECIALIZE checkSyntacticEquality :: Term -> Term -> TCM ((Term, Term), Bool) #-}
{-# SPECIALIZE checkSyntacticEquality :: Type -> Type -> TCM ((Type, Type), Bool) #-}
checkSyntacticEquality :: (SynEq a) => a -> a -> TCM ((a, a), Bool)
{-# SPECIALIZE checkSyntacticEquality :: Term -> Term -> ReduceM ((Term, Term), Bool) #-}
{-# SPECIALIZE checkSyntacticEquality :: Type -> Type -> ReduceM ((Type, Type), Bool) #-}
checkSyntacticEquality :: (SynEq a) => a -> a -> ReduceM ((a, a), Bool)
checkSyntacticEquality v v' = synEq v v' `runStateT` True

-- | Monad for checking syntactic equality
type SynEqM = StateT Bool TCM
type SynEqM = StateT Bool ReduceM

-- | Return, flagging inequalty.
inequal :: a -> SynEqM a
Expand Down Expand Up @@ -96,7 +97,7 @@ class SynEq a where
-- | Syntactic term equality ignores 'DontCare' stuff.
instance SynEq Term where
synEq v v' = do
(v, v') <- lift $ instantiate (v, v')
(v, v') <- lift $ instantiate' (v, v')
-- currently destroys sharing
-- TODO: preserve sharing!
case (ignoreSharing v, ignoreSharing v') of
Expand Down Expand Up @@ -128,7 +129,7 @@ instance SynEq PlusLevel where

instance SynEq LevelAtom where
synEq l l' = do
l <- lift (unBlock =<< instantiate l)
l <- lift (unBlock =<< instantiate' l)
case (l, l') of
(MetaLevel m vs , MetaLevel m' vs' ) | m == m' -> MetaLevel m <$$> synEq vs vs'
(UnreducedLevel v, UnreducedLevel v' ) -> UnreducedLevel <$$> synEq v v'
Expand All @@ -147,7 +148,7 @@ instance SynEq LevelAtom where

instance SynEq Sort where
synEq s s' = do
(s, s') <- lift $ instantiate (s, s')
(s, s') <- lift $ instantiate' (s, s')
case (s, s') of
(Type l , Type l' ) -> levelSort <$$> synEq l l'
(DLub a b, DLub a' b') -> dLub <$$> synEq a a' <**> synEq' b b'
Expand Down

0 comments on commit d52b5b7

Please sign in to comment.