3Description : Idris' Inliner.
6Maintainer : The Idris Community.
8{-# LANGUAGE PatternGuards #-}
10module Idris.Inliner(inlineDef, inlineTerm) where
15inlineDef :: IState -> [([Name], Term, Term)] -> [([Name], Term, Term)]
16inlineDef ist ds = map (\ (ns, lhs, rhs) -> (ns, lhs, inlineTerm ist rhs)) ds
18-- | Inlining is either top level (i.e. not in a function arg) or argument level
20-- For each application in a term:
21-- * Check if the function is inlinable
22-- (Dictionaries are inlinable in an argument, not otherwise)
23-- - If so, try inlining without reducing its arguments
24-- + If successful, then continue on the result (top level)
25-- + If not, reduce the arguments (argument level) and try again
26-- - If not, inline all the arguments (top level)
27inlineTerm :: IState -> Term -> Term
28inlineTerm ist tm = inl tm where
29 inl orig@(P _ n _) = inlApp n [] orig
31 | (P _ fn _, args) <- unApply orig = inlApp fn args orig
32 inl (Bind n (Let rc t v) sc) = Bind n (Let rc t (inl v)) (inl sc)
33 inl (Bind n b sc) = Bind n b (inl sc)
36 inlApp fn args orig = orig
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list