on master help sign in
Allow @-patterns under PAlternative
commit7c2bdb4c19401e175eec3a4425fd702c2368461c authorEdwin Brady <ecb10@st-andrews.ac.uk> dateSun 20 Mar 2016, 01:08 (11 years ago) parentdf05f31
1 file changed+8
src/Idris/Elab/AsPat.hs+8
src/Idris/Elab/AsPat.hs+8
@@ -28,6 +28,14 @@ collectAs (PApp fc t as)
2828 = do as_tm <- mapM collectAs (map getTm as)
2929 let as' = zipWith (\a tm -> a { getTm = tm }) as as_tm
3030 return (PApp fc t as') -- only valid on args
31+-- only for 'ExactlyOne' since it means the alternatives will have the
32+-- same form, so we can assume we only need to extract from the first one
33+collectAs tm@(PAlternative ns (ExactlyOne d) (a : as))
34+ = do a' <- collectAs a
35+ pats <- get
36+ as' <- mapM collectAs as -- just to drop the '@'
37+ put pats -- discard later ones, since they're repeated
38+ return (PAlternative ns (ExactlyOne d) (a' : as'))
3139collectAs x = return x
3240
3341-- | Replace _-patterns under @-patterns with fresh names that can be