Skip to content

Commit b42ac53

Browse files
authored
Merge pull request #31 from yeslogic/brendanzab/rename-cond-types
Rename conditional types to assertion types
2 parents b7d85cf + 4c4e09a commit b42ac53

File tree

13 files changed

+34
-34
lines changed

13 files changed

+34
-34
lines changed

experiments/lean/src/ddl/binary/basic.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ namespace ddl.binary
2323
| struct_nil {} : type
2424
| struct_cons : ℓ → type → type → type
2525
| array : type → host.expr ℓ → type
26-
| cond : type → host.expr ℓ → type
26+
| assert : type → host.expr ℓ → type
2727
| interp : type → host.expr ℓ → host.type ℓ → type
2828
| abs : kind → type → type
2929
| app : type → type → type
3030

3131

32-
-- Abstraction and conditional type notation - note that we are using a
32+
-- Abstraction and assertition type notation - note that we are using a
3333
-- nameless representation so we don't include the argument identifiers
3434
notation `Λ0: ` k `, ` t := type.abs k t
35-
notation `{0: ` t ` | ` e ` }` := type.cond t e
35+
notation `{0: ` t ` | ` e ` }` := type.assert t e
3636
-- Array type syntax
3737
notation `[ ` t `; ` e ` ]` := type.array t e
3838
-- Application operator

experiments/lean/src/ddl/binary/formation.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ namespace ddl.binary
3737
| array {t e} :
3838
well_formed t →
3939
well_formed (array t e)
40-
| cond {t e} :
40+
| assert {t e} :
4141
well_formed t →
42-
well_formed (cond t e)
42+
well_formed (assert t e)
4343
| interp {t e th} :
4444
well_formed t →
4545
well_formed (interp t e th)

experiments/lean/src/ddl/binary/kinding.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace ddl.binary
3333
has_kind Γ t ★ →
3434
host.has_type e host.type.nat →
3535
has_kind Γ [ t; e ] ★
36-
| cond {Γ t e} :
36+
| assert {Γ t e} :
3737
has_kind Γ t ★ →
3838
host.has_type /- FIXME: add binding? -/ e host.type.bool →
3939
has_kind Γ {0: t | e } ★

experiments/lean/src/ddl/binary/monad.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace ddl.binary.type
1616
| (struct_nil) f := struct_nil
1717
| (struct_cons l t₁ t₂) f := struct_cons l (bind t₁ f) (bind t₂ f)
1818
| (array t e) f := array (bind t f) e
19-
| (cond t e) f := cond (bind t f) e
19+
| (assert t e) f := assert (bind t f) e
2020
| (interp t e th) f := interp (bind t f) e th
2121
| (abs k t) f := abs k (bind t f)
2222
| (app t₁ t₂) f := app (bind t₁ f) (bind t₂ f)
@@ -45,7 +45,7 @@ namespace ddl.binary.type
4545
simp [bind, function.comp],
4646
rw [ht],
4747
},
48-
case cond t e ht {
48+
case assert t e ht {
4949
simp [bind, function.comp],
5050
rw [ht],
5151
},
@@ -85,7 +85,7 @@ namespace ddl.binary.type
8585
simp [bind] at ht,
8686
rw [ht]
8787
},
88-
case cond t e ht {
88+
case assert t e ht {
8989
simp [bind],
9090
simp [bind] at ht,
9191
rw [ht]

experiments/lean/src/ddl/binary/repr.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ddl.binary
1818
| (struct_nil) := host.type.struct_nil
1919
| (struct_cons l t₁ t₂) := host.type.struct_cons l t₁.repr t₂.repr
2020
| (array t e) := host.type.array (t.repr)
21-
| (cond t e) := t.repr
21+
| (assert t e) := t.repr
2222
| (interp t e ht) := ht
2323
| _ := sorry
2424

@@ -43,7 +43,7 @@ namespace ddl.binary
4343
case well_formed.array t₁ e hbtwf₁ hhtwf₁ {
4444
exact host.type.well_formed.array hhtwf₁,
4545
},
46-
case well_formed.cond t₁ e hbtwf₁ hhtwf₁ {
46+
case well_formed.assert t₁ e hbtwf₁ hhtwf₁ {
4747
exact hhtwf₁,
4848
},
4949
case well_formed.interp t₁ e ht hbtwf₁ hhtwf₁ {

experiments/lean/src/ddl/binary/subst.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ddl.binary
1818
| i x (struct_nil) := struct_nil
1919
| i x (struct_cons l t₁ t₂) := struct_cons l (open_var i x t₁) (open_var i x t₂)
2020
| i x (array t e) := array (open_var i x t) e
21-
| i x (cond t e) := cond (open_var i x t) e
21+
| i x (assert t e) := assert (open_var i x t) e
2222
| i x (interp t e th) := interp (open_var i x t) e th
2323
| i x (abs k t) := abs k (open_var (i + 1) x t)
2424
| i x (app t₁ t₂) := app (open_var i x t₁) (open_var i x t₂)
@@ -32,7 +32,7 @@ namespace ddl.binary
3232
| i x (struct_nil) := struct_nil
3333
| i x (struct_cons l t₁ t₂) := struct_cons l (close_var i x t₁) (close_var i x t₂)
3434
| i x (array t e) := array (close_var i x t) e
35-
| i x (cond t e) := cond (close_var i x t) e
35+
| i x (assert t e) := assert (close_var i x t) e
3636
| i x (interp t e th) := interp (close_var i x t) e th
3737
| i x (abs k t) := abs k (close_var (i + 1) x t)
3838
| i x (app t₁ t₂) := app (close_var i x t₁) (close_var i x t₂)
@@ -51,7 +51,7 @@ namespace ddl.binary
5151
case struct_nil { admit },
5252
case struct_cons l t₁ t₂ ht₁ ht₂ { admit },
5353
case array t e ht { admit },
54-
case cond t e ht { admit },
54+
case assert t e ht { admit },
5555
case interp t e ht hht { admit },
5656
case abs k t ht { admit },
5757
case app t₁ t₂ ht₁ ht₂ { admit },
@@ -71,7 +71,7 @@ namespace ddl.binary
7171
case struct_nil { admit },
7272
case struct_cons l t₁ t₂ ht₁ ht₂ { admit },
7373
case array t e ht { admit },
74-
case cond t e ht { admit },
74+
case assert t e ht { admit },
7575
case interp t e ht hht { admit },
7676
case abs k t ht { admit },
7777
case app t₁ t₂ ht₁ ht₂ { admit },

src/nominal/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub enum Type<N> {
108108
/// so there is no need to generate new types for these
109109
Array(RcType<N>, host::RcExpr<N>),
110110
/// Types dependent on some kind of condition
111-
Cond(RcType<N>, host::RcExpr<N>),
111+
Assert(RcType<N>, host::RcExpr<N>),
112112
/// Interpreted types
113113
Interp(RcType<N>, host::RcExpr<N>, host::RcType<N>),
114114
}

src/nominal/compile/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ fn compile_ty(
9999

100100
Type::path(path.clone())
101101
}
102-
binary::Type::Cond(_, ref ty, ref pred_expr) => {
102+
binary::Type::Assert(_, ref ty, ref pred_expr) => {
103103
let inner_path = path.append_child("Inner");
104104
let inner_ty = compile_ty(program, &inner_path, ty);
105105

106-
Type::Cond(Rc::new(inner_ty), pred_expr.clone())
106+
Type::Assert(Rc::new(inner_ty), pred_expr.clone())
107107
}
108108
binary::Type::Interp(_, ref ty, ref conv_expr, ref conv_ty) => {
109109
let inner_path = path.append_child("Inner");

src/structural/ast/binary.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ pub enum Type<N> {
4848
Union(Span, Vec<RcType<N>>),
4949
/// A struct type, with fields: eg. `struct { field : T, ... }`
5050
Struct(Span, Vec<Field<N, RcType<N>>>),
51-
/// A type constrained by a predicate: eg. `T where x => x == 3`
52-
Cond(Span, RcType<N>, host::RcExpr<N>),
51+
/// A type that is constrained by a predicate: eg. `T where x => x == 3`
52+
Assert(Span, RcType<N>, host::RcExpr<N>),
5353
/// An interpreted type
5454
Interp(Span, RcType<N>, host::RcExpr<N>, host::RcType<N>),
5555
/// Type abstraction: eg. `\(a : Type) -> T`
@@ -117,13 +117,13 @@ impl<N: Name> Type<N> {
117117
Type::Struct(span, fields)
118118
}
119119

120-
/// A type constrained by a predicate: eg. `T where x => x == 3`
121-
pub fn cond<T1, E1>(span: Span, ty: T1, pred: E1) -> Type<N>
120+
/// A type that is constrained by a predicate: eg. `T where x => x == 3`
121+
pub fn assert<T1, E1>(span: Span, ty: T1, pred: E1) -> Type<N>
122122
where
123123
T1: Into<RcType<N>>,
124124
E1: Into<host::RcExpr<N>>,
125125
{
126-
Type::Cond(span, ty.into(), pred.into())
126+
Type::Assert(span, ty.into(), pred.into())
127127
}
128128

129129
/// An interpreted type
@@ -186,7 +186,7 @@ impl<N: Name> Type<N> {
186186
}
187187
return;
188188
}
189-
Type::Cond(_, ref mut ty, ref mut _pred) => {
189+
Type::Assert(_, ref mut ty, ref mut _pred) => {
190190
Rc::make_mut(ty).substitute(substs);
191191
// Rc::make_mut(pred).substitute(substs);
192192
return;
@@ -225,7 +225,7 @@ impl<N: Name> Type<N> {
225225
Type::Struct(_, ref mut fields) => for (i, field) in fields.iter_mut().enumerate() {
226226
Rc::make_mut(&mut field.value).abstract_name_at(name, level + i as u32);
227227
},
228-
Type::Cond(_, ref mut ty, ref mut pred) => {
228+
Type::Assert(_, ref mut ty, ref mut pred) => {
229229
Rc::make_mut(ty).abstract_name_at(name, level);
230230
Rc::make_mut(pred).abstract_name_at(name, level + 1);
231231
}
@@ -264,7 +264,7 @@ impl<N: Name> Type<N> {
264264
Type::Array(_, ref mut elem_ty, _) => {
265265
Rc::make_mut(elem_ty).instantiate_at(level, src);
266266
}
267-
Type::Cond(_, ref mut ty, _) => {
267+
Type::Assert(_, ref mut ty, _) => {
268268
Rc::make_mut(ty).instantiate_at(level + 1, src);
269269
}
270270
Type::Interp(_, ref mut ty, _, _) => {
@@ -303,7 +303,7 @@ impl<N: Name> Type<N> {
303303

304304
Ok(Rc::new(host::Type::array(elem_repr_ty, size_expr)))
305305
}
306-
Type::Cond(_, ref ty, _) => ty.repr(),
306+
Type::Assert(_, ref ty, _) => ty.repr(),
307307
Type::Interp(_, _, _, ref repr_ty) => Ok(repr_ty.clone()),
308308
Type::Union(_, ref tys) => {
309309
let repr_tys = tys.iter().map(|ty| ty.repr()).collect::<Result<_, _>>()?;

src/structural/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub fn kind_of<N: Name>(
286286
}
287287

288288
// Conditional types
289-
Type::Cond(_, ref ty, ref pred_expr) => {
289+
Type::Assert(_, ref ty, ref pred_expr) => {
290290
expect_ty_kind(ctx, ty)?;
291291
let pred_ty = host::Type::arrow(ty.repr()?, host::Type::bool());
292292
expect_ty(ctx, pred_expr, pred_ty)?;

src/structural/parser/grammar.lalrpop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ PrimaryType: RcType<String> = {
9292
let repr_ty = ty.repr().map_err(|err| {
9393
ParseError::User { error: GrammarError::from(err) }
9494
})?;
95-
Ok(Type::cond(
95+
Ok(Type::assert(
9696
Span::new(lo1, hi),
9797
ty,
9898
Expr::abs(

src/structural/parser/snapshots/tests.parse_ty_where.snap renamed to src/structural/parser/snapshots/tests.parse_ty_assert.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
Cond(
1+
Assert(
22
Span {
33
lo: BytePos(9),
44
hi: BytePos(117)
55
},
6-
Cond(
6+
Assert(
77
Span {
88
lo: BytePos(9),
99
hi: BytePos(91)
@@ -16,7 +16,7 @@ Cond(
1616
[
1717
Field {
1818
name: "x",
19-
value: Cond(
19+
value: Assert(
2020
Span {
2121
lo: BytePos(33),
2222
hi: BytePos(54)

src/structural/parser/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn parse_ty_empty_struct() {
114114
}
115115

116116
#[test]
117-
fn parse_ty_where() {
117+
fn parse_ty_assert() {
118118
let src = "
119119
struct {
120120
x: u32 where x => x == 3,
@@ -123,7 +123,7 @@ fn parse_ty_where() {
123123
where x => x == 1
124124
";
125125

126-
assert_snapshot!(parse_ty_where, binary::Type::from_str(src).unwrap());
126+
assert_snapshot!(parse_ty_assert, binary::Type::from_str(src).unwrap());
127127
}
128128

129129
#[test]

0 commit comments

Comments
 (0)