|
definition: |
insertLetInExp :: [Rule] -> Term -> Term
insertLetInExp _ (Var i) = Var i
insertLetInExp rls (Func Cons c args) =
Func Cons c (map (insertLetInExp rls) args)
insertLetInExp rls (Func Def f args) =
let (_,hashp) = break (=='#') f
in if null hashp || take 4 hashp /= "#LET"
then Func Def f (map (insertLetInExp rls) args)
else let letrules = funcRules f rls
in if length letrules /= 1
then error $ "LetDropping: incorrect rules for " ++ f
else let (largs,lexp) = head letrules
freenums = case readNat (fst (break (=='_')
(drop 4 hashp))) of
[(n,"")] -> n
_ -> error $ "readNat in insertLetInExp"
in replaceLetCall f args freenums
(insertLetInRule rls (Rule f largs lexp))
|
|
demand: |
argument 2 |
|
deterministic: |
deterministic operation |
|
failfree: |
<FAILING> |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_,{Var}) |-> {Var} || (_,{Func}) |-> _}
|
|
name: |
insertLetInExp |
|
precedence: |
no precedence defined |
|
result-values: |
_ |
|
signature: |
[TRS.Rule] -> TRS.Term -> TRS.Term |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |