on master help sign in
Remove collapsibility and forceability altogether.
commiteedf4893cc154d392940a82f76ea56d29af3f35e authorMatus Tejiscak <ziman@functor.sk> dateMon 24 Mar 2014, 16:31 (13 years ago) parent5c0c63a
6 files changed+38−336
src/Idris/AbsSyntaxTree.hs+1−17 src/Idris/DataOpts.hs+14−231 src/Idris/DeepSeq.hs+2−6 src/Idris/ElabDecls.hs+18−67 src/Idris/Erasure.hs+1−1 src/Idris/IBC.hs+2−14
src/Idris/AbsSyntaxTree.hs+1−17
@@ -833,23 +833,7 @@ data TIData = TIPartial -- ^ a function with a partially defined type
833833 | TISolution [Term] -- ^ possible solutions to a metavariable in a type
834834 deriving Show
835835
836−-- An argument is conditionally forceable iff its forceability
837−-- depends on the collapsibility of the whole type.
838−data Forceability = Conditional | Unconditional deriving (Show, Enum, Bounded, Eq, Ord)
839−
840−{-!
841−deriving instance Binary Forceability
842−deriving instance NFData Forceability
843−!-}
844−
845−data OptInfo = Optimise { collapsible :: Bool,
846− isnewtype :: Bool,
847− -- The following should actually be (IntMap Forceability)
848− -- but the corresponding Binary instance seems to be broken.
849− -- Let's store a list and convert it to IntMap whenever needed.
850− forceable :: [(Int, Forceability)],
851− recursive :: [Int],
852− inaccessible :: [(Int,Name)], -- names for error reporting
836+data OptInfo = Optimise { inaccessible :: [(Int,Name)], -- includes names for error reporting
853837 detaggable :: Bool }
854838 deriving Show
855839{-!
src/Idris/DataOpts.hs+14−231
@@ -9,224 +9,48 @@ import Idris.AbsSyntaxTree
99import Idris.Core.TT
1010
1111import Control.Applicative
12−import qualified Data.IntMap as M
1312import Data.List
1413import Data.Maybe
1514import Debug.Trace
1615
17−type ForceMap = M.IntMap Forceability
18−
19−-- Calculate the forceable arguments to a constructor
20−-- and update the set of optimisations.
21−forceArgs :: Name -> Name -> [Int] -> Type -> Idris ()
22−forceArgs typeName n expforce t = do
23− ist <- getIState
24− let fargs = getForcedArgs ist typeName t
25− copt = case lookupCtxt n (idris_optimisation ist) of
26− [] -> Optimise False False [] [] [] False
27− op:_ -> op
28− opts = addDef n (copt { forceable = M.toList fargs ++
29− zip expforce (repeat Unconditional) })
30− (idris_optimisation ist)
31− putIState (ist { idris_optimisation = opts })
32− addIBC (IBCOpt n)
33− iLOG $ "Forced: " ++ show n ++ " " ++ show fargs ++ "\n from " ++ show t
34−
35−getForcedArgs :: IState -> Name -> Type -> ForceMap
36−getForcedArgs ist typeName t = M.empty -- addCollapsibleArgs 0 t $ forcedInTarget 0 t
37− where
38− maxUnion = M.unionWith max
39−
40− -- Label all occurrences of the variable bound in Pi in the rest of
41− -- the term with the number i so that we can recognize them anytime later.
42− label i = instantiate $ P Bound (sMN i "ctor_arg") Erased
43−
44− addCollapsibleArgs :: Int -> Type -> ForceMap -> ForceMap
45− addCollapsibleArgs i (Bind vn (Pi ty) rest) alreadyForceable
46− = addCollapsibleArgs (i+1) (label i rest) (forceable $ unApply ty)
47− where
48− -- forceable takes an un-applied type of a ctor argument
49− forceable (P _ tn _, args)
50− -- if `ty' is collapsible, the argument is unconditionally forceable
51− | isCollapsible tn
52− = M.insert i Unconditional alreadyForceable
53−
54− -- a recursive occurrence with known indices is conditionally forceable
55− | tn == typeName
56− = M.insertWith max i Conditional alreadyForceable
57−
58− forceable _ = alreadyForceable
59−
60− isCollapsible :: Name -> Bool
61− isCollapsible n = case lookupCtxt n (idris_optimisation ist) of
62− [oi] -> collapsible oi
63− _ -> False
64−
65− addCollapsibleArgs _ _ fs = fs
66−
67− forcedInTarget :: Int -> Type -> ForceMap
68− forcedInTarget i (Bind _ (Pi _) rest) = forcedInTarget (i+1) (label i rest)
69− forcedInTarget i t@(App f a) | (_, as) <- unApply t = unionMap guardedArgs as
70− forcedInTarget _ _ = M.empty
71−
72− guardedArgs :: Term -> ForceMap
73− guardedArgs t@(App f a) | (P (DCon _ _) _ _, args) <- unApply t
74− = unionMap bareArg args `maxUnion` unionMap guardedArgs args
75− guardedArgs t = bareArg t
76−
77− bareArg :: Term -> ForceMap
78− bareArg (P _ (MN i ctor_arg) _)
79− | ctor_arg == txt "ctor_arg" = M.singleton i Unconditional
80− bareArg _ = M.empty
81−
82− unionMap :: (a -> ForceMap) -> [a] -> ForceMap
83− unionMap f = M.unionsWith max . map f
84−
85−-- Calculate whether a collection of constructors is collapsible
86−-- and update the state accordingly.
87−collapseCons :: Name -> [(Name, Type)] -> Idris ()
88−collapseCons tn ctors = do
89− ist <- getIState
90− case ctors of
91− _
92− | all (ctorCollapsible ist) ctors
93− , disjointTerms ctorTargetArgs
94− -> return () -- mapM_ setCollapsible (tn : map fst ctors)
95−
96− [(cn, ct)]
97− -> checkNewType ist cn ct
98−
99− _ -> return () -- nothing can be done
100− where
101− ctorTargetArgs = map (snd . unApply . getRetTy . snd) ctors
102−
103− ctorArity :: Type -> Int
104− ctorArity = length . getArgTys
105−
106− ctorCollapsible :: IState -> (Name, Type) -> Bool
107− ctorCollapsible ist (n, t) = all (`M.member` forceMap) [0 .. ctorArity t - 1]
108− where
109− forceMap = case lookupCtxt n (idris_optimisation ist) of
110− oi:_ -> M.fromList $ forceable oi
111− _ -> M.empty
112−
113− -- one constructor; if one remaining argument, treat as newtype
114− checkNewType :: IState -> Name -> Type -> Idris ()
115− checkNewType ist cn ct
116− | oi:_ <- lookupCtxt cn opt
117− , length (getArgTys ct) == 1 + forcedCnt (M.fromList $ forceable oi)
118− = putIState ist{ idris_optimisation = opt' oi }
119− | otherwise = return ()
120− where
121− opt = idris_optimisation ist
122− opt' oi = addDef cn oi{ isnewtype = True } opt
123−
124− setCollapsible :: Name -> Idris ()
125− setCollapsible n
126− = do i <- getIState
127− iLOG $ show n ++ " collapsible"
128− case lookupCtxt n (idris_optimisation i) of
129− (oi:_) -> do let oi' = oi { collapsible = True }
130− let opts = addDef n oi' (idris_optimisation i)
131− putIState (i { idris_optimisation = opts })
132− [] -> do let oi = Optimise True False [] [] [] False
133− let opts = addDef n oi (idris_optimisation i)
134− putIState (i { idris_optimisation = opts })
135− addIBC (IBCOpt n)
136−
137− disjointTerms :: [[Term]] -> Bool
138− disjointTerms [] = True
139− disjointTerms [xs] = True
140− disjointTerms (xs : xss) =
141− -- xs is disjoint with every pattern from xss
142− all (or . zipWith disjoint xs) xss
143− -- and xss is pairwise disjoint, too
144− && disjointTerms xss
145−
146− -- Return True if the two patterns are provably disjoint.
147− -- Return False if they're not or if unsure.
148− disjoint :: Term -> Term -> Bool
149− disjoint x y = case (cx, cy) of
150− -- data constructors -> compare their names
151− (P (DCon _ _) nx _, P (DCon _ _) ny _)
152− | nx /= ny -> True
153− | otherwise -> or $ zipWith disjoint xargs yargs
154− _ -> False
155− where
156− (cx, xargs) = unApply x
157− (cy, yargs) = unApply y
158−
15916class Optimisable term where
16017 applyOpts :: term -> Idris term
161− stripCollapsed :: term -> Idris term
16218
16319instance (Optimisable a, Optimisable b) => Optimisable (a, b) where
16420 applyOpts (x, y) = (,) <$> applyOpts x <*> applyOpts y
165− stripCollapsed (x, y) = (,) <$> stripCollapsed x <*> stripCollapsed y
16621
16722instance (Optimisable a, Optimisable b) => Optimisable (vs, a, b) where
16823 applyOpts (v, x, y) = (,,) v <$> applyOpts x <*> applyOpts y
169− stripCollapsed (v, x, y) = (,,) v <$> stripCollapsed x <*> stripCollapsed y
17024
17125instance Optimisable a => Optimisable [a] where
17226 applyOpts = mapM applyOpts
173− stripCollapsed = mapM stripCollapsed
17427
17528instance Optimisable a => Optimisable (Either a (a, a)) where
17629 applyOpts (Left t) = Left <$> applyOpts t
17730 applyOpts (Right t) = Right <$> applyOpts t
178− stripCollapsed (Left t) = Left <$> stripCollapsed t
179− stripCollapsed (Right t) = Right <$> stripCollapsed t
18031
18132-- Raw is for compile time optimisation (before type checking)
18233-- Term is for run time optimisation (after type checking, collapsing allowed)
183−
18434-- Compile time: no collapsing
18535
18636instance Optimisable Raw where
18737 applyOpts t@(RApp f a)
18838 | (Var n, args) <- raw_unapply t -- MAGIC HERE
189− = do args' <- mapM applyOpts args
190− i <- getIState
191− return $ case lookupCtxt n (idris_optimisation i) of
192− oi:_ -> applyDataOpt oi n args'
193− _ -> raw_apply (Var n) args'
39+ = raw_apply (Var n) <$> mapM applyOpts args
19440 | otherwise = RApp <$> applyOpts f <*> applyOpts a
19541
19642 applyOpts (RBind n b t) = RBind n <$> applyOpts b <*> applyOpts t
19743 applyOpts (RForce t) = applyOpts t
19844 applyOpts t = return t
19945
200− stripCollapsed t = return t
201−
20246-- Erase types (makes ibc smaller, and we don't need them)
20347instance Optimisable (Binder (TT Name)) where
20448 applyOpts (Let t v) = Let <$> return Erased <*> applyOpts v
20549 applyOpts b = return (b { binderTy = Erased })
206− stripCollapsed (Let t v) = Let <$> return Erased <*> stripCollapsed v
207− stripCollapsed b = return (b { binderTy = Erased })
20850
20951instance Optimisable (Binder Raw) where
21052 applyOpts b = do t' <- applyOpts (binderTy b)
21153 return (b { binderTy = t' })
212− stripCollapsed (Let t v) = Let <$> stripCollapsed t <*> stripCollapsed v
213− stripCollapsed b = do t' <- stripCollapsed (binderTy b)
214− return (b { binderTy = t' })
215−
216−forcedArgSeq :: OptInfo -> [Maybe Forceability]
217−forcedArgSeq oi = map (\i -> M.lookup i forceMap) [0..]
218− where
219− forceMap = M.fromList $ forceable oi
220−
221−forcedCnt :: ForceMap -> Int
222−forcedCnt = length . filter (== Unconditional) . M.elems
223−
224−applyDataOpt :: OptInfo -> Name -> [Raw] -> Raw
225−applyDataOpt oi n args
226− = raw_apply (Var n) $ zipWith doForce (forcedArgSeq oi) args
227− where
228− doForce (Just Unconditional) a = RForce a
229− doForce _ a = a
23054
23155-- Run-time: do everything
23256
@@ -249,54 +73,22 @@ instance Optimisable (TT Name) where
24973 | fn == txt "toIntegerNat" && mod == prel
25074 = return (App (P Ref (sNS (sUN "id") ["Basics","Prelude"]) Erased) Erased)
25175 applyOpts c@(P (DCon t arity) n _)
252− = do i <- getIState
253− case lookupCtxt n (idris_optimisation i) of
254− (oi:_) -> return $ applyDataOptRT oi n t arity []
255− _ -> return c
76+ = return $ applyDataOptRT n t arity []
25677 applyOpts t@(App f a)
25778 | (c@(P (DCon t arity) n _), args) <- unApply t
258− = do args' <- mapM applyOpts args
259− i <- getIState
260− case lookupCtxt n (idris_optimisation i) of
261− (oi:_) -> do return $ applyDataOptRT oi n t arity args'
262− _ -> return (mkApp c args')
263− | otherwise = do f' <- applyOpts f
264− a' <- applyOpts a
265− return (App f' a')
266− applyOpts (Bind n b t) = do b' <- applyOpts b
267− t' <- applyOpts t
268− return (Bind n b' t')
269− applyOpts (Proj t i) = do t' <- applyOpts t
270− return (Proj t' i)
79+ = applyDataOptRT n t arity <$> mapM applyOpts args
80+ | otherwise = App <$> applyOpts f <*> applyOpts a
81+ applyOpts (Bind n b t) = Bind n <$> applyOpts b <*> applyOpts t
82+ applyOpts (Proj t i) = Proj <$> applyOpts t <*> pure i
27183 applyOpts t = return t
27284
273− stripCollapsed (Bind n (PVar x) t) | (P _ ty _, _) <- unApply x
274− = do i <- getIState
275− -- NOTE: This assumes that 'ty' is in normal form, which it
276− -- has to be before now because we're not keeping track of
277− -- an environment so we can't do it here.
278− case lookupCtxt ty (idris_optimisation i) of
279− [oi] -> if collapsible oi
280− then do t' <- stripCollapsed t
281− return (Bind n (PVar x) (instantiate Erased t'))
282− else do t' <- stripCollapsed t
283− return (Bind n (PVar x) t')
284− _ -> do t' <- stripCollapsed t
285− return (Bind n (PVar x) t')
286− stripCollapsed (Bind n (PVar x) t)
287− = do t' <- stripCollapsed t
288− return (Bind n (PVar x) t')
289− stripCollapsed t = return t
290−
291−-- Need to saturate arguments first to ensure that erasure happens uniformly
292−
293−applyDataOptRT :: OptInfo -> Name -> Int -> Int -> [Term] -> Term
294−applyDataOptRT oi n tag arity args
295− | length args == arity = doOpts n args (collapsible oi) (M.fromList $ forceable oi)
85+-- Need to saturate arguments first to ensure that optimisation happens uniformly
86+applyDataOptRT :: Name -> Int -> Int -> [Term] -> Term
87+applyDataOptRT n tag arity args
88+ | length args == arity = doOpts n args
29689 | otherwise = let extra = satArgs (arity - length args)
29790 tm = doOpts n (args ++ map (\n -> P Bound n Erased) extra)
298− (collapsible oi) (M.fromList $ forceable oi) in
299− bind extra tm
91+ in bind extra tm
30092 where
30193 satArgs n = map (\i -> sMN i "sat") [1..n]
30294
@@ -305,20 +97,11 @@ applyDataOptRT oi n tag arity args
30597
30698 -- Nat special cases
30799 -- TODO: Would be nice if this was configurable in idris source!
308− doOpts (NS (UN z) [nat, prelude]) [] _ _
100+ doOpts (NS (UN z) [nat, prelude]) []
309101 | z == txt "Z" && nat == txt "Nat" && prelude == txt "Prelude"
310102 = Constant (BI 0)
311− doOpts (NS (UN s) [nat, prelude]) [k] _ _
103+ doOpts (NS (UN s) [nat, prelude]) [k]
312104 | s == txt "S" && nat == txt "Nat" && prelude == txt "Prelude"
313105 = App (App (P Ref (sUN "prim__addBigInt") Erased) k) (Constant (BI 1))
314106
315− doOpts n args True _ = Erased
316− doOpts n args _ forceMap
317− | isnewtype oi = case args' of
318− [val] -> val
319− _ -> error $ "Can't happen (newtype not a singleton): " ++ show args'
320− | otherwise = mkApp ctor' args'
321− where
322− ctor' = (P (DCon tag (arity - forcedCnt forceMap)) n Erased)
323− args' = [t | (f, t) <- zip (forcedArgSeq oi) args, f /= Just Unconditional]
324−
107+ doOpts n args = mkApp (P (DCon tag arity) n Erased) args
src/Idris/DeepSeq.hs+2−6
@@ -50,10 +50,6 @@ instance NFData CT.NumWrapper where
5050
5151-- All generated by 'derive'
5252
53−instance NFData Forceability where
54− rnf Conditional = ()
55− rnf Unconditional = ()
56−
5753instance NFData IntTy where
5854 rnf (ITFixed x1) = rnf x1 `seq` ()
5955 rnf ITNative = ()
@@ -290,8 +286,8 @@ instance NFData ClassInfo where
290286 rnf x2 `seq` rnf x3 `seq` rnf x4 `seq` rnf x5 `seq` rnf x6 `seq` ()
291287
292288instance NFData OptInfo where
293− rnf (Optimise x1 x2 x3 x4 x5 x6)
294− = rnf x1 `seq` rnf x2 `seq` rnf x3 `seq` rnf x4 `seq` rnf x5 `seq` rnf x6 `seq` ()
289+ rnf (Optimise x1 x2)
290+ = rnf x1 `seq` rnf x2 `seq` ()
295291
296292instance NFData TypeInfo where
297293 rnf (TI x1 x2 x3 x4) = rnf x1 `seq` rnf x2 `seq` rnf x3 `seq` rnf x4 `seq` ()
src/Idris/ElabDecls.hs+18−67
@@ -189,7 +189,7 @@ saveInaccArgs n is = do
189189
190190 _ -> do
191191 putIState ist{ idris_optimisation =
192− addDef n (Optimise False False [] [] is False) (idris_optimisation ist) }
192+ addDef n (Optimise is False) (idris_optimisation ist) }
193193 addIBC (IBCOpt n)
194194
195195-- Get the list of (index, name) of inaccessible arguments from the type.
@@ -212,29 +212,6 @@ elabPostulate info syn doc fc opts n ty = do
212212 -- remove it from the deferred definitions list
213213 solveDeferred n
214214
215−{- NB. this check has been superseded by usage analysis
216− -
217− -- make sure it's collapsible, so it is never needed at run time
218− -- start by getting the elaborated type
219− ctxt <- getContext
220− fty <- case lookupTy n ctxt of
221− [] -> tclift $ tfail $ (At fc (NoTypeDecl n)) -- can't happen!
222− [ty] -> return ty
223− ist <- getIState
224− let (ap, _) = unApply (getRetTy (normalise ctxt [] fty))
225−
226− logLvl 5 $ "Checking collapsibility of " ++ show (ap, fty)
227− let postOK = case ap of
228− P _ tn _ -> case lookupCtxt tn
229− (idris_optimisation ist) of
230− [oi] -> collapsible oi
231− _ -> False
232− _ -> False
233− when (not postOK)
234− $ tclift $ tfail (At fc (NonCollapsiblePostulate n))
235−-}
236−
237−
238215elabData :: ElabInfo -> SyntaxInfo -> Docstring -> [(Name, Docstring)] -> FC -> DataOpts -> PData -> Idris ()
239216elabData info syn doc argDocs fc opts (PLaterdecl n t_in)
240217 = do let codata = Codata `elem` opts
@@ -296,12 +273,12 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
296273 let metainf = DataMI params
297274 addIBC (IBCMetaInformation n metainf)
298275 -- TMP HACK! Make this a data option
299− when (n /= sUN "Lazy'") $ collapseCons n cons
300276 updateContext (addDatatype (Data n ttag cty cons))
301277 updateContext (setMetaInformation n metainf)
302278 mapM_ (checkPositive n) cons
303279
304− -- if there's exactly one constructor, mark both the type and the constructor
280+ -- if there's exactly one constructor,
281+ -- mark both the type and the constructor as detaggable
305282 case cons of
306283 [(cn,ct)] -> setDetaggable cn >> setDetaggable n
307284 >> addIBC (IBCOpt cn) >> addIBC (IBCOpt n)
@@ -317,7 +294,7 @@ elabData info syn doc argDocs fc opts (PDatadecl n t_in dcons)
317294 let opt = idris_optimisation ist
318295 case lookupCtxt n opt of
319296 [oi] -> putIState ist{ idris_optimisation = addDef n oi{ detaggable = True } opt }
320− _ -> putIState ist{ idris_optimisation = addDef n (Optimise False False [] [] [] True) opt }
297+ _ -> putIState ist{ idris_optimisation = addDef n (Optimise [] True) opt }
321298
322299 checkDefinedAs fc n t ctxt
323300 = case lookupDef n ctxt of
@@ -907,6 +884,11 @@ elabRecord info syn doc fc tyn ty cdoc cn cty
907884 (map pexp rhsArgs)) []
908885 return (pn, pfnTy, PClauses fc [] setname [pclause])
909886
887+-- FIXME: 'forcenames' is an almighty hack! Need a better way of
888+-- erasing non-forceable things
889+-- ^^^
890+-- TODO: the above is a comment from the past;
891+-- forcenames is probably no longer needed
910892elabCon :: ElabInfo -> SyntaxInfo -> Name -> Bool ->
911893 (Docstring, [(Name, Docstring)], Name, PTerm, FC, [Name]) -> Idris (Name, Type)
912894elabCon info syn tn codata (doc, argDocs, n, t_in, fc, forcenames)
@@ -937,10 +919,6 @@ elabCon info syn tn codata (doc, argDocs, n, t_in, fc, forcenames)
937919 addIBC (IBCDoc n)
938920 saveInaccArgs n inacc
939921 addIBC (IBCOpt n)
940− let fs = map (getNamePos 0 t) forcenames
941− -- FIXME: 'forcenames' is an almighty hack! Need a better way of
942− -- erasing non-forceable things
943− forceArgs tn n (mapMaybe (getNamePos 0 t) forcenames) cty'
944922 return (n, cty')
945923 where
946924 tyIs (Bind n b sc) = tyIs sc
@@ -975,7 +953,7 @@ elabClauses info fc opts n_in cs = let n = liftname info n_in in
975953 do ctxt <- getContext
976954 ist <- getIState
977955 let inacc = case lookupCtxt n (idris_optimisation ist) of
978− [Optimise _ _ _ _ inacc _] -> map fst inacc
956+ [Optimise inacc _] -> map fst inacc
979957 _ -> []
980958 -- Check n actually exists, with no definition yet
981959 let tys = lookupTy n ctxt
@@ -994,29 +972,13 @@ elabClauses info fc opts n_in cs = let n = liftname info n_in in
994972
995973 logLvl 3 $ "Elaborated patterns:\n" ++ show pats_in
996974
997− -- if the return type of 'ty' is collapsible, the optimised version should
998− -- just do nothing
999− ist <- getIState
1000− let (ap, _) = unApply (getRetTy fty)
1001− logLvl 5 $ "Checking collapsibility of " ++ show (ap, fty)
1002− -- FIXME: Really ought to only do this for total functions!
1003− let doNothing = case ap of
1004− P _ tn _ -> case lookupCtxt tn
1005− (idris_optimisation ist) of
1006− [oi] -> collapsible oi
1007− _ -> False
1008− _ -> False
1009975 solveDeferred n
976+
1010977 ist <- getIState
1011− when doNothing $
1012− case lookupCtxt n (idris_optimisation ist) of
1013− [oi] -> do let opts = addDef n (oi { collapsible = True })
1014− (idris_optimisation ist)
1015− putIState (ist { idris_optimisation = opts })
1016− _ -> do let opts = addDef n (Optimise True False [] [] [] False)
1017− (idris_optimisation ist)
1018− putIState (ist { idris_optimisation = opts })
1019− addIBC (IBCOpt n)
978+ let opts = addDef n (Optimise [] False) (idris_optimisation ist)
979+ in putIState (ist { idris_optimisation = opts })
980+ addIBC (IBCOpt n)
981+
1020982 ist <- getIState
1021983 let pats = map (simple_lhs (tt_ctxt ist)) $ doTransforms ist pats_in
1022984
@@ -1026,11 +988,8 @@ elabClauses info fc opts n_in cs = let n = liftname info n_in in
1026988 let tcase = opt_typecase (idris_options ist)
1027989
1028990 -- Summary of what's about to happen: Definitions go:
1029−
1030− -- pats_in -> pats -> optpats
1031− -- pdef comes from pats,
1032− -- optpdef comes from optpats
1033− -- Then pdef' is optpdef with forcing/collapsing applied everywhere
991+ --
992+ -- pats_in -> pats -> pdef -> pdef'
1034993
1035994 -- addCaseDef builds case trees from <pdef> and <pdef'>
1036995
@@ -1059,18 +1018,10 @@ elabClauses info fc opts n_in cs = let n = liftname info n_in in
10591018
10601019 numArgs <- tclift $ sameLength pdef
10611020
1062− -- patterns after collapsing optimisation applied
1063− -- (i.e. check if the function should do nothing at run time)
1064− optpats <- if doNothing
1065− then return $ [Right (mkApp (P Bound n Erased)
1066− (take numArgs (repeat Erased)), Erased)]
1067− else stripCollapsed pats
1068−
10691021 case specNames opts of
10701022 Just _ -> logLvl 5 $ "Partially evaluated:\n" ++ show pats
10711023 _ -> return ()
10721024
1073− let optpdef = map debind optpats -- \$ map (simple_lhs (tt_ctxt ist)) optpats
10741025 tree@(CaseDef scargs sc _) <- tclift $
10751026 simpleCase tcase False reflect CompileTime fc inacc atys pdef
10761027 cov <- coverage
@@ -1094,7 +1045,7 @@ elabClauses info fc opts n_in cs = let n = liftname info n_in in
10941045 let pcover = null pmissing
10951046
10961047 -- pdef' is the version that gets compiled for run-time
1097− pdef_in' <- applyOpts optpdef
1048+ pdef_in' <- applyOpts pdef
10981049 let pdef' = map (simple_rt (tt_ctxt ist)) pdef_in'
10991050
11001051 logLvl 5 $ "After data structure transformations:\n" ++ show pdef'
src/Idris/Erasure.hs+1−1
@@ -128,7 +128,7 @@ performUsageAnalysis = do
128128
129129 checkAccessibility :: Ctxt OptInfo -> (Name, IntMap (Set Reason)) -> Idris ()
130130 checkAccessibility opt (n, reachable)
131− | [Optimise col nt forc rec inaccessible dt] <- lookupCtxt n opt
131+ | [Optimise inaccessible dt] <- lookupCtxt n opt
132132 , eargs@(_:_) <- [fmt n (S.toList rs) | (i,n) <- inaccessible, rs <- maybeToList $ IM.lookup i reachable]
133133 = warn $ show n ++ ": inaccessible arguments reachable:\n " ++ intercalate "\n " eargs
134134
src/Idris/IBC.hs+2−14
@@ -1093,10 +1093,6 @@ safeToEnum label x' = result
10931093 = error $ label ++ ": corrupted binary representation in IBC"
10941094 | otherwise = toEnum x
10951095
1096−instance Binary Forceability where
1097− put = putWord8 . fromIntegral . fromEnum
1098− get = safeToEnum "Forceability" `fmap` getWord8
1099−
11001096instance Binary PReason where
11011097 put x
11021098 = case x of
@@ -2100,21 +2096,13 @@ instance Binary ClassInfo where
21002096 return (CI x1 x2 x3 x4 x5 [])
21012097
21022098instance Binary OptInfo where
2103− put (Optimise x1 x2 x3 x4 x5 x6)
2099+ put (Optimise x1 x2)
21042100 = do put x1
21052101 put x2
2106− put x3
2107− put x4
2108− put x5
2109− put x6
21102102 get
21112103 = do x1 <- get
21122104 x2 <- get
2113− x3 <- get
2114− x4 <- get
2115− x5 <- get
2116− x6 <- get
2117− return (Optimise x1 x2 x3 x4 x5 x6)
2105+ return (Optimise x1 x2)
21182106
21192107instance Binary TypeInfo where
21202108 put (TI x1 x2 x3 x4) = do put x1