@@ -1,6 +1,6 @@
1{-# LANGUAGE PatternGuards #-}
1{-# LANGUAGE PatternGuards #-}
3−module Idris.Erasure (performUsageAnalysis) where
3+module Idris.Erasure (performUsageAnalysis, mkFieldName) where
5import Idris.AbsSyntax
5import Idris.AbsSyntax
6import Idris.Core.CaseTree
6import Idris.Core.CaseTree
@@ -306,7 +306,7 @@ buildDepMap ci ctx mainName = addPostulates $ dfs S.empty M.empty [mainName]
307 -- generate metamethod names, "n" is the instance ctor
307 -- generate metamethod names, "n" is the instance ctor
308 meth :: Int -> Maybe Name
308 meth :: Int -> Maybe Name
309− meth | SN (InstanceCtorN className) <- n = \j -> Just (mkField n j)
309+ meth | SN (InstanceCtorN className) <- n = \j -> Just (mkFieldName n j)
310 | otherwise = \j -> Nothing
310 | otherwise = \j -> Nothing
312 -- Named variables -> DeBruijn variables -> Conds/guards -> Term -> Deps
312 -- Named variables -> DeBruijn variables -> Conds/guards -> Term -> Deps
@@ -423,7 +423,7 @@ buildDepMap ci ctx mainName = addPostulates $ dfs S.empty M.empty [mainName]
423 deps i = M.singleton (metameth, Arg i) S.empty
423 deps i = M.singleton (metameth, Arg i) S.empty
424 bruijns = reverse [\cd -> M.singleton cd (deps i) | i <- [0 .. length args - 1]]
424 bruijns = reverse [\cd -> M.singleton cd (deps i) | i <- [0 .. length args - 1]]
425 cond = S.singleton (metameth, Result)
425 cond = S.singleton (metameth, Result)
426− metameth = mkField ctorName methNo
426+ metameth = mkFieldName ctorName methNo
427 (args, body) = unfoldLams t
427 (args, body) = unfoldLams t
429 -- projections
429 -- projections
@@ -471,9 +471,6 @@ buildDepMap ci ctx mainName = addPostulates $ dfs S.empty M.empty [mainName]
471 unfoldLams (Bind n (Lam ty) t) = let (ns,t') = unfoldLams t in (n:ns, t')
471 unfoldLams (Bind n (Lam ty) t) = let (ns,t') = unfoldLams t in (n:ns, t')
472 unfoldLams t = ([], t)
472 unfoldLams t = ([], t)
474− mkField :: Name -> Int -> Name
475− mkField ctorName fieldNo = SN (WhereN fieldNo ctorName $ sMN fieldNo "field")
477 union :: Deps -> Deps -> Deps
474 union :: Deps -> Deps -> Deps
478 union = M.unionWith (M.unionWith S.union)
475 union = M.unionWith (M.unionWith S.union)
@@ -482,3 +479,6 @@ buildDepMap ci ctx mainName = addPostulates $ dfs S.empty M.empty [mainName]
483 unionMap :: (a -> Deps) -> [a] -> Deps
480 unionMap :: (a -> Deps) -> [a] -> Deps
484 unionMap f = M.unionsWith (M.unionWith S.union) . map f
481 unionMap f = M.unionsWith (M.unionWith S.union) . map f
483+mkFieldName :: Name -> Int -> Name
484+mkFieldName ctorName fieldNo = SN (WhereN fieldNo ctorName $ sMN fieldNo "field")