on master help sign in
Only rewrite _ under @!
8a03679David Raymond Christiansen
src/Idris/Elab/AsPat.hs+8−2
@@ -33,10 +33,16 @@ collectAs x = return x
33-- | Replace _-patterns under @-patterns with fresh names that can be
33-- | Replace _-patterns under @-patterns with fresh names that can be
34-- used on the RHS
34-- used on the RHS
35replaceUnderscore :: PTerm -> PTerm
35replaceUnderscore :: PTerm -> PTerm
36−replaceUnderscore tm = evalState (transformM replaceUnderscore' tm) 0
36+replaceUnderscore tm = evalState (transformM (underAs replaceUnderscore') tm) 0
37 where
37 where
38+ underAs :: (PTerm -> State Int PTerm) -> PTerm -> State Int PTerm
39+ underAs f (PAs fc n tm) = PAs fc n <$> transformM f tm
40+ underAs f x = return x
41+
38 fresh :: State Int Name
42 fresh :: State Int Name
39− fresh = flip sMN "underscorePatVar" <$> get
43+ fresh = modify (+1) >> flip sMN "underscorePatVar" <$> get
44+
45+
40 replaceUnderscore' :: PTerm -> State Int PTerm
46 replaceUnderscore' :: PTerm -> State Int PTerm
41 replaceUnderscore' Placeholder = PRef emptyFC <$> fresh
47 replaceUnderscore' Placeholder = PRef emptyFC <$> fresh
42 replaceUnderscore' tm = return tm
48 replaceUnderscore' tm = return tm