MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
direct.h
Go to the documentation of this file.
1#pragma once
2
3#include <mim/rewrite.h>
4
6
8
9/// @name %%direct.cps2ds_dep
10/// ```
11/// let k: Cn [t: T, Cn U t] = ...;
12/// let f: [t: T] → U = %direct.cps2ds_dep (T, lm (t': T): * = [t → t']U) k;
13/// ```
14///@{
16 auto& w = k->world();
17 auto K = Pi::isa_cn(k->type());
18 auto T = K->dom(2, 0);
19 auto U = Pi::isa_cn(K->dom(2, 1))->dom();
20 auto l = w.mut_lam(T, w.type())->set("Uf");
21 auto body = U;
22
23 if (auto dom = K->dom()->isa_mut<Sigma>(); dom && dom->has_var())
24 body = VarRewriter(dom->var(), l->var()).rewrite(U); // TODO typeof(dom->var()) != typeof(l->var())
25 l->set(true, body);
26
27 return w.app(w.app(w.annex<direct::cps2ds_dep>(), {T, l}), k);
28}
29///@}
30
31} // namespace mim::plug::direct
Ref type() const
Definition def.h:251
World & world() const
Definition def.cpp:411
const Var * has_var()
Only returns not nullptr, if Var of this mutable has ever been created.
Definition def.h:399
static const Pi * isa_cn(Ref d)
Is this a continuation - i.e. is the Pi::codom mim::Bottom?
Definition lam.h:44
Ref dom() const
Definition lam.h:32
Helper class to retrieve Infer::arg if present.
Definition def.h:86
virtual Ref rewrite(Ref)
Definition rewrite.cpp:9
A dependent tuple type.
Definition tuple.h:9
The direct style Plugin
Definition direct.h:7
Ref op_cps2ds_dep(Ref k)
Definition direct.h:15