@@ -39,9 +39,9 @@ module Idris.Core.TT(
39 , discard, emptyContext, emptyFC, explicitNames, fc_end, fc_fname
39 , discard, emptyContext, emptyFC, explicitNames, fc_end, fc_fname
40 , fc_start, fcIn, fileFC, finalise, fmapMB, forget, forgetEnv
40 , fc_start, fcIn, fileFC, finalise, fmapMB, forget, forgetEnv
41 , freeNames, getArgTys, getRetTy, implicitable, instantiate
41 , freeNames, getArgTys, getRetTy, implicitable, instantiate
42− , intTyName, isInjective, isTypeConst, liftPats, lookupCtxt
42+ , intTyName, isInjective, isTypeConst, lookupCtxt
43 , lookupCtxtExact, lookupCtxtName, mapCtxt, mkApp, nativeTyWidth
43 , lookupCtxtExact, lookupCtxtName, mapCtxt, mkApp, nativeTyWidth
44− , nextName, noOccurrence, nsroot, occurrences, orderPats
44+ , nextName, noOccurrence, nsroot, occurrences
45 , pEraseType, pmap, pprintRaw, pprintTT, prettyEnv, psubst, pToV
45 , pEraseType, pmap, pprintRaw, pprintTT, prettyEnv, psubst, pToV
46 , pToVs, pureTerm, raw_apply, raw_unapply, refsIn, safeForget
46 , pToVs, pureTerm, raw_apply, raw_unapply, refsIn, safeForget
47 , safeForgetEnv, showCG, showEnv, showEnvDbg, showSep
47 , safeForgetEnv, showCG, showEnv, showEnvDbg, showSep
@@ -853,7 +853,8 @@ deriving instance Binary Raw
853deriving instance NFData Raw
853deriving instance NFData Raw
856−data ImplicitInfo = Impl { tcinstance :: Bool, toplevel_imp :: Bool }
856+data ImplicitInfo = Impl { tcinstance :: Bool, toplevel_imp :: Bool,
857+ machine_gen :: Bool }
857 deriving (Show, Eq, Ord, Data, Typeable)
858 deriving (Show, Eq, Ord, Data, Typeable)
@@ -1698,30 +1699,6 @@ weakenEnv env = wk (length env - 1) env
1698weakenTmEnv :: Int -> EnvTT n -> EnvTT n
1699weakenTmEnv :: Int -> EnvTT n -> EnvTT n
1699weakenTmEnv i = map (\ (n, b) -> (n, fmap (weakenTm i) b))
1700weakenTmEnv i = map (\ (n, b) -> (n, fmap (weakenTm i) b))
1701−-- | Gather up all the outer 'PVar's and 'Hole's in an expression and reintroduce
1702−-- them in a canonical order
1703−orderPats :: Term -> Term
1704−orderPats tm = op [] tm
1706− op [] (App s f a) = App s f (op [] a) -- for Infer terms
1708− op ps (Bind n (PVar t) sc) = op ((n, PVar t) : ps) sc
1709− op ps (Bind n (Hole t) sc) = op ((n, Hole t) : ps) sc
1710− op ps (Bind n (Pi i t k) sc) = op ((n, Pi i t k) : ps) sc
1711− op ps sc = bindAll (sortP ps) sc
1713− sortP ps = pick [] (reverse ps)
1715− pick acc [] = reverse acc
1716− pick acc ((n, t) : ps) = pick (insert n t acc) ps
1718− insert n t [] = [(n, t)]
1719− insert n t ((n',t') : ps)
1720− | n `elem` (refsIn (binderTy t') ++
1721− concatMap refsIn (map (binderTy . snd) ps))
1722− = (n', t') : insert n t ps
1723− | otherwise = (n,t):(n',t'):ps
1725refsIn :: TT Name -> [Name]
1702refsIn :: TT Name -> [Name]
1726refsIn (P _ n _) = [n]
1703refsIn (P _ n _) = [n]
1727refsIn (Bind n b t) = nub $ nb b ++ refsIn t
1704refsIn (Bind n b t) = nub $ nb b ++ refsIn t
@@ -1731,45 +1708,6 @@ refsIn (Bind n b t) = nub $ nb b ++ refsIn t
1731refsIn (App s f a) = nub (refsIn f ++ refsIn a)
1708refsIn (App s f a) = nub (refsIn f ++ refsIn a)
1732refsIn _ = []
1709refsIn _ = []
1734−-- Make sure all the pattern bindings are as far out as possible
1735−liftPats :: Term -> Term
1736−liftPats tm = let (tm', ps) = runState (getPats tm) [] in
1737− orderPats $ bindPats (reverse ps) tm'
1739− bindPats [] tm = tm
1740− bindPats ((n, t):ps) tm
1741− | n `notElem` map fst ps = Bind n (PVar t) (bindPats ps tm)
1742− | otherwise = bindPats ps tm
1744− getPats :: Term -> State [(Name, Type)] Term
1745− getPats (Bind n (PVar t) sc) = do ps <- get
1748− getPats (Bind n (Guess t v) sc) = do t' <- getPats t
1751− return (Bind n (Guess t' v') sc')
1752− getPats (Bind n (Let t v) sc) = do t' <- getPats t
1755− return (Bind n (Let t' v') sc')
1756− getPats (Bind n (Pi i t k) sc) = do t' <- getPats t
1759− return (Bind n (Pi i t' k') sc')
1760− getPats (Bind n (Lam t) sc) = do t' <- getPats t
1762− return (Bind n (Lam t') sc')
1763− getPats (Bind n (Hole t) sc) = do t' <- getPats t
1765− return (Bind n (Hole t') sc')
1768− getPats (App s f a) = do f' <- getPats f
1770− return (App s f' a')
1771− getPats t = return t
1773allTTNames :: Eq n => TT n -> [n]
1711allTTNames :: Eq n => TT n -> [n]
1774allTTNames = nub . allNamesIn
1712allTTNames = nub . allNamesIn
1775 where allNamesIn (P _ n _) = [n]
1713 where allNamesIn (P _ n _) = [n]