on master help sign in
Only rewrite _ under @!

Also generate actual fresh names.

commit8a03679d2401babd711522077da4eeb61f425419 authorDavid Raymond Christiansen <david@davidchristiansen.dk> dateSat 10 Jan 2015, 17:40 (12 years ago) parent0b23ef2
1 file changed+8−2
src/Idris/Elab/AsPat.hs+8−2
src/Idris/Elab/AsPat.hs+8−2
@@ -33,10 +33,16 @@ collectAs x = return x
3333-- | Replace _-patterns under @-patterns with fresh names that can be
3434-- used on the RHS
3535replaceUnderscore :: PTerm -> PTerm
36−replaceUnderscore tm = evalState (transformM replaceUnderscore' tm) 0
36+replaceUnderscore tm = evalState (transformM (underAs replaceUnderscore') tm) 0
3737 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+
3842 fresh :: State Int Name
39− fresh = flip sMN "underscorePatVar" <$> get
43+ fresh = modify (+1) >> flip sMN "underscorePatVar" <$> get
44+
45+
4046 replaceUnderscore' :: PTerm -> State Int PTerm
4147 replaceUnderscore' Placeholder = PRef emptyFC <$> fresh
4248 replaceUnderscore' tm = return tm