on master help sign in
Fix parameter identification

Names may vary between constructors, but what's important is that the parameters are in the same position for each constructor. This fix no longer makes the assumption that the names are the same throughout. Fixes #1467

commita523c20c58ed5464bd609c3ac2cc0a0cc3ac56fa authorEdwin Brady <ecb10@st-andrews.ac.uk> dateTue 12 Aug 2014, 09:49 (12 years ago) parent4c46b0e
1 file changed+9−2
src/Idris/Elab/Data.hs+9−2
src/Idris/Elab/Data.hs+9−2
@@ -132,8 +132,15 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
132132 -- them for repeated arguments
133133
134134 findParams :: [Type] -> [Int]
135− findParams ts = let allapps = concatMap getDataApp ts in
136− paramPos allapps
135+ findParams ts = let allapps = map getDataApp ts
136+ -- do each constructor separately, then merge the results (names
137+ -- may change between constructors)
138+ conParams = map paramPos allapps in
139+ inAll conParams
140+
141+ inAll :: [[Int]] -> [Int]
142+ inAll [] = []
143+ inAll (x : xs) = filter (\p -> all (\ps -> p `elem` ps) xs) x
137144
138145 paramPos [] = []
139146 paramPos (args : rest)