Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

20220629 typed language #48

Open
wants to merge 132 commits into
base: base
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
5e0f6b0
All needed code transcribed from haskell implementation ... first we'…
prozacchiwawa Jun 30, 2022
4580b16
Ensure theory is represented
prozacchiwawa Jun 30, 2022
e336aa3
mod
prozacchiwawa Jun 30, 2022
22448ba
ported haskell implementation of 'Jana Dunfield and Neelakantan R. Kr…
prozacchiwawa Jun 30, 2022
385d5b4
Cradle for testing type theory
prozacchiwawa Jul 1, 2022
53b64bd
Start nailing down typed expressions
prozacchiwawa Jul 2, 2022
4564294
More tests
prozacchiwawa Jul 2, 2022
7347f85
More
prozacchiwawa Jul 2, 2022
0a80f01
More
prozacchiwawa Jul 2, 2022
e802e4b
more
prozacchiwawa Jul 2, 2022
1f6a9bb
Start unwinding type inf
prozacchiwawa Jul 6, 2022
0a5d2aa
Fix up guard i missed in TExists cases in subtype
prozacchiwawa Jul 9, 2022
dd1bd46
Add test
prozacchiwawa Jul 9, 2022
c50903d
WIP more type checking ... i think i'm understanding more of the comp…
prozacchiwawa Jul 10, 2022
ea3d747
Make drop and break more monadic, separate hypothesis from evolution …
prozacchiwawa Jul 10, 2022
0e6f202
More type resolution at the endpoints
prozacchiwawa Jul 11, 2022
e03c883
more working typings
prozacchiwawa Jul 12, 2022
c3b9e77
enough is functioning that we can describe functions by variable name…
prozacchiwawa Jul 12, 2022
3be61a1
We typecheck apply, but maybe not synthesize properly from it yet
prozacchiwawa Jul 12, 2022
35979b9
All type checking
prozacchiwawa Jul 14, 2022
c044b42
some is not a special expr anymore either, just a type signature
prozacchiwawa Jul 14, 2022
f81c367
More well formed assertions
prozacchiwawa Jul 14, 2022
4d6d35e
More well formed assertions
prozacchiwawa Jul 14, 2022
bc9aa92
Well formed assertions
prozacchiwawa Jul 14, 2022
9b5c53c
preliminary support for type applications and named polymorphic types…
prozacchiwawa Jul 15, 2022
cc102f3
Add typeable tests for list with annotation
prozacchiwawa Jul 15, 2022
f0cad78
Add a way to accumulate helper functions in typetest
prozacchiwawa Jul 15, 2022
3a0dd49
WIP checkpoint
prozacchiwawa Jul 15, 2022
1183751
All tests passing again, i have pretty good confidence after wringing…
prozacchiwawa Jul 18, 2022
8be25c5
Start adding types in the chialisp language itself
prozacchiwawa Jul 18, 2022
f4cfd75
Block out type checking chialisp programs
prozacchiwawa Jul 18, 2022
7b682cb
More tests
prozacchiwawa Jul 19, 2022
c6d7a7e
Enough to do basic args
prozacchiwawa Jul 19, 2022
a81ef36
We have the first working type annotation of a chialisp program
prozacchiwawa Jul 19, 2022
3f1585d
Simple argument destructuring type smoke test
prozacchiwawa Jul 19, 2022
971b49e
Test of 'c' operator type
prozacchiwawa Jul 19, 2022
f544a32
sha256 yields atom32
prozacchiwawa Jul 19, 2022
3d8ec07
Show that Atom doesn't subtype (Atom 32)
prozacchiwawa Jul 19, 2022
448c37b
Added a more ergonomic syntax for typing
prozacchiwawa Jul 20, 2022
c37dd3c
Fixing more stuff, formalizing into chialisp rather than abstract in …
prozacchiwawa Jul 20, 2022
dd83b50
More checks
prozacchiwawa Jul 20, 2022
bffc77f
Add more typing tests; move onto 'if'
prozacchiwawa Jul 21, 2022
59c3fc9
macros involving apply should be well formed now
prozacchiwawa Jul 21, 2022
f341a40
Fixed a bunch of things (turns out solve was something adding things …
prozacchiwawa Jul 21, 2022
2037cd3
Abstract deftype routed
prozacchiwawa Jul 22, 2022
71fc51a
Provide struct and helpers
prozacchiwawa Jul 25, 2022
37acfe9
add failing struct member type test
prozacchiwawa Jul 25, 2022
4548adb
Last feature of structs: construction
prozacchiwawa Jul 25, 2022
9ecccea
WIP: almost done with untype
prozacchiwawa Jul 26, 2022
3b5d8f6
type stripping functions and type generated inlines working
prozacchiwawa Jul 26, 2022
1a6ddbe
Add prims
prozacchiwawa Jul 26, 2022
5d25f43
Add typecheck command line argument
prozacchiwawa Jul 26, 2022
5d4791f
We can do structs with type variables
prozacchiwawa Jul 27, 2022
6559b13
Member access in structs with variables
prozacchiwawa Jul 27, 2022
d9f385c
test of bless
prozacchiwawa Jul 27, 2022
c19bfaf
Final bits: ensure let is well typed
prozacchiwawa Jul 27, 2022
6335eec
Todos neutralized so we won't panic unexpectedly
prozacchiwawa Jul 27, 2022
8a072b9
Fix some clippy traffic
prozacchiwawa Jul 27, 2022
a222657
Add doc
prozacchiwawa Jul 27, 2022
7dce442
Missing
prozacchiwawa Jul 27, 2022
226cea9
fmt
prozacchiwawa Jul 27, 2022
c79a720
fmt
prozacchiwawa Jul 27, 2022
506ae09
Move quotes to stop fmt spiral
prozacchiwawa Jul 27, 2022
34b5a72
fix strong clippy warning
prozacchiwawa Jul 27, 2022
7ebdd26
Loosen f and r on lists
prozacchiwawa Jul 27, 2022
8722796
fmt
prozacchiwawa Jul 27, 2022
d04a551
ensure that List and other TApps synthesize their representation for …
prozacchiwawa Jul 27, 2022
ad22f3c
fmt
prozacchiwawa Jul 27, 2022
1b9ea84
Ensure the repl can use the new type generated helpers
prozacchiwawa Jul 27, 2022
8cd9700
fmt
prozacchiwawa Jul 27, 2022
5aadc18
Change (Atom 32) to Atom32
prozacchiwawa Jul 28, 2022
cc559a7
fmt
prozacchiwawa Jul 28, 2022
a4df5b1
More stuff, changed type application order and added FixedList
prozacchiwawa Jul 29, 2022
1373625
Fmt
prozacchiwawa Jul 29, 2022
93d2d23
Some more fixes, new test, write types.md
prozacchiwawa Jul 29, 2022
a5f65ac
fmt
prozacchiwawa Jul 29, 2022
a9de3a0
Last additions
prozacchiwawa Jul 29, 2022
d338b6d
fix
prozacchiwawa Jul 29, 2022
73aa729
fix doc
prozacchiwawa Jul 29, 2022
c0ae901
clean up prose
prozacchiwawa Jul 29, 2022
0e6c1ce
Fix
prozacchiwawa Jul 29, 2022
0f01621
File removed
prozacchiwawa Jul 30, 2022
2583a0e
Add tests for examples in types.md and more tests that differing stru…
prozacchiwawa Jul 31, 2022
32b9122
fmt
prozacchiwawa Jul 31, 2022
83d2504
forgotten tag
prozacchiwawa Jul 31, 2022
bc00628
Tweak reify, fix issues in context and other places. De-recurse appl…
prozacchiwawa Aug 20, 2022
7b8e38f
Some additional tests that pin things down
prozacchiwawa Aug 20, 2022
002330c
fmt
prozacchiwawa Aug 20, 2022
db25a58
Merge branch 'base' into 20220629-typed-language
prozacchiwawa Aug 20, 2022
d643f87
Update cargo.lock
prozacchiwawa Aug 20, 2022
2645846
bring in base after big clippy merged and purify
prozacchiwawa Sep 15, 2022
2b76409
fmt
prozacchiwawa Sep 15, 2022
55ffa43
clippy
prozacchiwawa Sep 15, 2022
17a30ab
mirror removed artifacts
prozacchiwawa Sep 15, 2022
1ecb9b1
Update to current base
prozacchiwawa Oct 27, 2022
3d1d114
pull in base
prozacchiwawa Oct 31, 2022
782e6cd
Merge up base
prozacchiwawa Nov 9, 2022
6d91994
fmt + clippy
prozacchiwawa Nov 9, 2022
9fcbb3b
clippy
prozacchiwawa Nov 9, 2022
1f44130
fmt
prozacchiwawa Nov 9, 2022
cff4037
Pull in base
prozacchiwawa Dec 4, 2022
e00810e
Merge up
prozacchiwawa Dec 16, 2022
4c9a9d9
Merge up
prozacchiwawa Dec 16, 2022
bbcbd7a
Merge up
prozacchiwawa Jan 12, 2023
2d48a83
Merge up
prozacchiwawa Feb 1, 2023
d46bd94
fmt + clippy + merge
prozacchiwawa Feb 1, 2023
282b65a
Merge up
prozacchiwawa Feb 5, 2023
b667d14
fmt + clippy
prozacchiwawa Feb 5, 2023
beb655a
Lower stack limit for the moment. Will add a trampoline to evaluate
prozacchiwawa Feb 5, 2023
5fd4d59
Merge up
prozacchiwawa Mar 16, 2023
0239d3e
fmt
prozacchiwawa Mar 16, 2023
cca4617
Merge up
prozacchiwawa Apr 6, 2023
e76ce50
fmt + clippy
prozacchiwawa Apr 6, 2023
4d7874a
Merge remote-tracking branch 'chia/base' into 20220629-typed-language
prozacchiwawa Apr 19, 2023
f7f15e4
Merge remote-tracking branch 'chia/base' into 20220629-typed-language
prozacchiwawa May 15, 2023
429f107
Add coverage
prozacchiwawa May 15, 2023
92cea6f
fmt
prozacchiwawa May 15, 2023
45e1891
More coverage
prozacchiwawa May 15, 2023
08d59de
fmt
prozacchiwawa May 15, 2023
18b96df
Test that subtype recognizes that an existential tv subtypes itself w…
prozacchiwawa May 15, 2023
7580f51
fmt
prozacchiwawa May 15, 2023
7bc1dff
More coverage
prozacchiwawa May 15, 2023
66b4b03
More coverage
prozacchiwawa May 16, 2023
1d5f473
more coverage
prozacchiwawa May 16, 2023
c53ed3f
More coverage
prozacchiwawa May 16, 2023
15476b3
Tighten up theory a bit
prozacchiwawa May 16, 2023
7f7176f
Merge rest args with types
prozacchiwawa Aug 2, 2023
5e3cc15
fmt
prozacchiwawa Aug 2, 2023
e98c841
Merge up
prozacchiwawa Aug 3, 2023
e6a9c6f
Merge up base
prozacchiwawa Aug 8, 2023
4fc31c3
Merge up
prozacchiwawa Sep 8, 2023
9ca0d9b
fmt + clippy
prozacchiwawa Sep 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 112 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ serde_json = "1.0"
sha2 = "0.9.5"
tempfile = "3.3.0"
clvmr = { version = "0.2.6", features = ["pre-eval"] }
env_logger = "0.9.0"
log = "0.4.17"
binascii = "0.1.4"
yaml-rust = "0.4"
linked-hash-map = "0.5.6"
Expand Down Expand Up @@ -98,3 +100,7 @@ path = "src/classic/bins/clisp_to_json.rs"
[[bin]]
name = "repl"
path = "src/classic/bins/repl.rs"

[[bin]]
name = "typetest"
path = "src/classic/bins/typetest.rs"
3 changes: 2 additions & 1 deletion src/classic/bins/repl.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
extern crate clvmr as clvm_rs;

use std::io::{self, BufRead, Write};

use std::rc::Rc;

use clvm_rs::allocator::Allocator;
Expand All @@ -12,6 +11,8 @@ use clvm_tools_rs::compiler::repl::Repl;
use clvm_tools_rs::classic::clvm_tools::stages::stage_0::DefaultProgramRunner;

fn main() {
env_logger::init();

let mut allocator = Allocator::new();
let runner = Rc::new(DefaultProgramRunner::new());
let opts = Rc::new(DefaultCompilerOpts::new("*program*"));
Expand Down
66 changes: 66 additions & 0 deletions src/classic/bins/typetest.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
extern crate clvmr as clvm_rs;

use std::env;

use clvm_tools_rs::compiler::comptypes::CompileErr;
use clvm_tools_rs::compiler::sexp::parse_sexp;
use clvm_tools_rs::compiler::srcloc::Srcloc;
use clvm_tools_rs::compiler::typecheck::{parse_expr_sexp, TheoryToSExp};
use clvm_tools_rs::compiler::typechia::standard_type_context;
use clvm_tools_rs::compiler::types::ast::{ContextElim, Var};
use clvm_tools_rs::compiler::types::theory::TypeTheory;

fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("give type theory expressions");
return;
}

env_logger::init();

let loc = Srcloc::start("*program*");
let mut context = standard_type_context();

let mut takename = true;
let mut name = "".to_string();
for arg in args.iter().take(args.len() - 1).skip(1) {
if takename {
name = arg.to_string();
} else {
match parse_sexp(loc.clone(), arg.bytes())
.map_err(|e| CompileErr(e.0.clone(), e.1))
.and_then(|parsed_program| parse_expr_sexp(parsed_program[0].clone()))
.and_then(|result| context.typesynth(&result))
{
Ok((ty, _)) => {
context = context.snoc(ContextElim::CVar(Var(name.clone(), loc.clone()), ty));
}
Err(e) => {
println!("error in helper {name}: {e:?}");
return;
}
}
}

takename = !takename;
}

println!("starting context {}", context.to_sexp());

parse_sexp(loc, args[args.len() - 1].bytes())
.map_err(|e| CompileErr(e.0.clone(), e.1))
.and_then(|parsed_program| parse_expr_sexp(parsed_program[0].clone()))
.and_then(|result| {
println!("parsed: {}", result.to_sexp());
context.typesynth(&result)
})
.map(|(ty, ctx)| {
println!("typed: {}", ctx.reify(&ty, None).to_sexp());
println!("context: {}", ctx.to_sexp());
})
.map_err(|e| {
println!("failed: {e:?}");
})
.ok();
}
5 changes: 4 additions & 1 deletion src/classic/clvm_tools/clvmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use crate::compiler::compiler::{run_optimizer, DefaultCompilerOpts};
use crate::compiler::comptypes::{CompileErr, CompilerOpts};
use crate::compiler::dialect::detect_modern;
use crate::compiler::runtypes::RunFailure;
use crate::compiler::srcloc::Srcloc;
use crate::compiler::untype::untype_code;

pub fn write_sym_output(
compiled_lookup: &HashMap<String, String>,
Expand All @@ -48,6 +50,7 @@ pub fn compile_clvm_text(
) -> Result<NodePtr, EvalErr> {
let ir_src = read_ir(text).map_err(|s| EvalErr(allocator.null(), s.to_string()))?;
let assembled_sexp = assemble_from_ir(allocator, Rc::new(ir_src))?;
let untyped_sexp = untype_code(allocator, Srcloc::start(input_path), assembled_sexp)?;

let dialect = detect_modern(allocator, assembled_sexp);
// Now the stepping is optional (None for classic) but we may communicate
Expand All @@ -68,7 +71,7 @@ pub fn compile_clvm_text(
.map_err(|s| EvalErr(allocator.null(), s.1))
} else {
let compile_invoke_code = run(allocator);
let input_sexp = allocator.new_pair(assembled_sexp, allocator.null())?;
let input_sexp = allocator.new_pair(untyped_sexp, allocator.null())?;
let run_program = run_program_for_search_paths(input_path, &opts.get_search_paths(), false);
if classic_with_opts {
run_program.set_compiler_opts(Some(opts));
Expand Down
Loading
Loading