diff --git a/Cargo.lock b/Cargo.lock index 7efe2d92..07b7149d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,11 +51,12 @@ version = "0.1.0" dependencies = [ "base64", "failure", - "frunk", + "frunk_core", "itertools", "lazy_static", "nom", "petgraph", + "serde", "sha2", "strum", "strum_macros", @@ -69,7 +70,7 @@ name = "aris-auto-grader" version = "0.1.0" dependencies = [ "aris", - "frunk", + "frunk_core", ] [[package]] @@ -85,16 +86,27 @@ name = "aris-java" version = "0.1.0" dependencies = [ "aris", - "frunk", + "frunk_core", "jni", ] +[[package]] +name = "aris-js" +version = "0.1.0" +dependencies = [ + "aris", + "frunk_core", + "js-sys", + "serde-wasm-bindgen", + "wasm-bindgen", +] + [[package]] name = "aris-web-app" version = "0.1.0" dependencies = [ "aris", - "frunk", + "frunk_core", "gloo", "js-sys", "strum", @@ -362,70 +374,13 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "frunk" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8313555ac9fdcbe88b502fbd5b9f7de3270654635444d8279242613ad3fdc41e" -dependencies = [ - "frunk_core", - "frunk_derives", - "frunk_proc_macros", -] - [[package]] name = "frunk_core" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26c09b4b25ef220d9b6ac31dc0bb3479fccdf539598893f1cbf27d5a5bc324b5" - -[[package]] -name = "frunk_derives" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04a917380b97872efb7a5e560cbd67f6234c90133a60a8a17aa3b053b95d103f" -dependencies = [ - "frunk_core", - "frunk_proc_macro_helpers", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "frunk_proc_macro_helpers" -version = "0.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "127176d3c96d6a9011bdb87194bd06b6f01c2524070a61669ad600cb4f3f08f6" -dependencies = [ - "frunk_core", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "frunk_proc_macros" -version = "0.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a82ea7fce299f0f0f78233cdf373425b13fa9c2b04df42d2bd3187d2cfe4fb" dependencies = [ - "frunk_core", - "frunk_proc_macros_impl", - "proc-macro-hack", - "quote 0.6.13", - "syn 0.15.44", -] - -[[package]] -name = "frunk_proc_macros_impl" -version = "0.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98e073845f3791501385f17aa96d03527d982a9483013706684c86450c4fe3d0" -dependencies = [ - "frunk_core", - "frunk_proc_macro_helpers", - "proc-macro-hack", - "quote 0.6.13", - "syn 0.15.44", + "serde", ] [[package]] @@ -697,9 +652,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.40" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce10c23ad2ea25ceca0093bd3192229da4c5b3c0f2de499c1ecac0d98d452177" +checksum = "c4b9172132a62451e56142bff9afc91c8e4a4500aa5b847da36815b63bfda916" dependencies = [ "wasm-bindgen", ] @@ -1065,6 +1020,18 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee6f12f7ed0e7ad2e55200da37dbabc2cadeb942355c5b629aa3771f5ac5636" +dependencies = [ + "fnv", + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_derive" version = "1.0.114" @@ -1078,9 +1045,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.55" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2c5d7e739bc07a3e73381a39d61fdb5f671c60c1df26a130690665803d8226" +checksum = "3433e879a558dde8b5e8feb2a04899cf34fdde1fafb894687e52105fc1162ac3" dependencies = [ "itoa", "ryu", @@ -1409,19 +1376,21 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasm-bindgen" -version = "0.2.63" +version = "0.2.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2dc4aa152834bc334f506c1a06b866416a8b6697d5c9f75b9a689c8486def0" +checksum = "6a634620115e4a229108b71bde263bb4220c483b3f07f5ba514ee8d15064c4c2" dependencies = [ "cfg-if", + "serde", + "serde_json", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.63" +version = "0.2.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded84f06e0ed21499f6184df0e0cb3494727b0c5da89534e0fcc55c51d812101" +checksum = "3e53963b583d18a5aa3aaae4b4c1cb535218246131ba22a71f05b518098571df" dependencies = [ "bumpalo", "lazy_static", @@ -1446,9 +1415,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.63" +version = "0.2.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "838e423688dac18d73e31edce74ddfac468e37b1506ad163ffaf0a46f703ffe3" +checksum = "3fcfd5ef6eec85623b4c6e844293d4516470d8f19cd72d0d12246017eb9060b8" dependencies = [ "quote 1.0.7", "wasm-bindgen-macro-support", @@ -1456,9 +1425,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.63" +version = "0.2.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3156052d8ec77142051a533cdd686cba889537b213f948cd1d20869926e68e92" +checksum = "9adff9ee0e94b926ca81b57f57f86d5545cdcb1d259e21ec9bdd95b901754c75" dependencies = [ "proc-macro2 1.0.18", "quote 1.0.7", @@ -1469,9 +1438,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.63" +version = "0.2.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9ba19973a58daf4db6f352eda73dc0e289493cd29fb2632eb172085b6521acd" +checksum = "7f7b90ea6c632dd06fd765d44542e234d5e63d9bb917ecd64d79778a13bd79ae" [[package]] name = "web-sys" diff --git a/Cargo.toml b/Cargo.toml index 1bfc1b7d..33f5c59f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,4 +6,5 @@ members = [ "auto-grader", "bindings/c", "bindings/java", + "bindings/js", ] diff --git a/aris/Cargo.toml b/aris/Cargo.toml index 8da3ae1f..e14c30b1 100644 --- a/aris/Cargo.toml +++ b/aris/Cargo.toml @@ -14,9 +14,10 @@ sha2 = "0.8.1" varisat = "0.2.1" xml-rs = "0.8.0" itertools = "0.9.0" -frunk = "0.2.2" +frunk_core = { version = "0.2.2", features = ["serde"] } strum = "0.18.0" strum_macros = "0.18.0" +serde = { version = "^1.0", features = ["derive"] } [build-dependencies] version_check = "0.9" diff --git a/aris/src/expression.rs b/aris/src/expression.rs index 1388ea64..4a2902ea 100644 --- a/aris/src/expression.rs +++ b/aris/src/expression.rs @@ -62,34 +62,38 @@ assert_eq!(does_it_have_any_ands(&expr2), true); assert_eq!(does_it_have_any_ands(&expr3), false); ``` */ + use super::*; + use std::collections::{HashSet, HashMap}; use std::collections::BTreeSet; use std::mem; use std::ops::Not; use itertools::Itertools; +use serde::Deserialize; +use serde::Serialize; /// Symbol for unary operations -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize)] #[repr(C)] pub enum USymbol { Not } /// Symbol for binary operations -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize)] #[repr(C)] pub enum BSymbol { Implies, Plus, Mult } /// Symbol for associative binary operations -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize)] #[repr(C)] pub enum ASymbol { And, Or, Bicon, Equiv } /// Symbol for quantifiers -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize)] #[repr(C)] pub enum QSymbol { Forall, Exists } /// aris::expression::Expr is the core AST (Abstract Syntax Tree) type for representing logical expressions. /// For most of the recursive cases, it uses symbols so that code can work on the shape of e.g. a binary operation without worrying about which binary operation it is. -#[derive(Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)] +#[derive(Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize)] #[repr(C)] pub enum Expr { Contradiction, diff --git a/aris/src/lib.rs b/aris/src/lib.rs index 92757d50..372db107 100644 --- a/aris/src/lib.rs +++ b/aris/src/lib.rs @@ -1,4 +1,4 @@ -#[macro_use] extern crate frunk; +#[macro_use] extern crate frunk_core; #[macro_use] extern crate nom; #[macro_use] extern crate lazy_static; diff --git a/aris/src/proofs.rs b/aris/src/proofs.rs index fe8bfba4..4e6048a5 100644 --- a/aris/src/proofs.rs +++ b/aris/src/proofs.rs @@ -27,7 +27,7 @@ The test running apparatus expects you to return the proof, a list of line refer ## Parsing XML into a PooledProof ``` -#[macro_use] extern crate frunk; +#[macro_use] extern crate frunk_core; use aris::expression::Expr; use aris::proofs::xml_interop::proof_from_xml; let data = &include_bytes!("../../example-proofs/propositional_logic_arguments_for_proofs_ii_problem_10.bram")[..]; @@ -54,8 +54,8 @@ ASCII art proof: Code that builds the proof generically and then instantiates it: ``` -#[macro_use] extern crate frunk; -use frunk::Coproduct; +#[macro_use] extern crate frunk_core; +use frunk_core::coproduct::Coproduct; use aris::expression::Expr; use aris::proofs::{Proof, Justification, pooledproof::PooledProof}; use aris::rules::RuleM; @@ -85,8 +85,8 @@ let concrete_proof = contraposition_demo::
();
# Mutating existing lines of a proof
```
-#[macro_use] extern crate frunk;
-use frunk::Coproduct;
+#[macro_use] extern crate frunk_core;
+use frunk_core::coproduct::Coproduct;
use aris::expression::Expr;
use aris::parser::parse_unwrap as p;
use aris::proofs::{Proof, Justification, pooledproof::PooledProof};
@@ -115,7 +115,7 @@ The subproof pointer in `with_mut_subproof`, if returned directly, could be inva
This is prevented by the fact that the lifetime parameter of the subproof reference cannot occur in A:
```compile_fail,E0495
-#[macro_use] extern crate frunk;
+#[macro_use] extern crate frunk_core;
use aris::proofs::{Proof, pooledproof::PooledProof};
use aris::expression::Expr;
fn should_fail_with_lifetime_error() {
@@ -129,12 +129,16 @@ This is a similar trick to the rank-2 type of `runST` in Haskell used to prevent
*/
use super::*;
-use frunk::coproduct::*;
+
use std::collections::HashSet;
use std::fmt::{Display, Formatter};
use std::hash::Hash;
use std::ops::Range;
+use frunk_core::coproduct::*;
+use serde::Deserialize;
+use serde::Serialize;
+
#[cfg(test)]
mod proof_tests;
@@ -262,7 +266,7 @@ pub trait Proof: Sized {
ret
}
fn transitive_dependencies(&self, line: PJRef , deps: &mut HashSet where PJRef : Debug, P::SubproofReference:
}
pub fn from_proof(p: P) -> Self {
fn aux , current_sub: Option where PJRef : Debug, P::SubproofReference:
ret
}
pub fn add_line(&mut self, i: usize, is_premise: bool, subproof_level: usize) {
- use frunk::Coproduct::{Inl, Inr};
+ use frunk_core::coproduct::Coproduct::{Inl, Inr};
println!("add_line {:?} {:?} {:?}", i, is_premise, subproof_level);
let const_true = Expr::Tautology;
let line: Option : Debug, P::SubproofReference: Debug {
diff --git a/aris/src/proofs/treeproof.rs b/aris/src/proofs/treeproof.rs
index 6a13e097..13f9026a 100644
--- a/aris/src/proofs/treeproof.rs
+++ b/aris/src/proofs/treeproof.rs
@@ -1,5 +1,5 @@
use super::*;
-use frunk::coproduct::{Coproduct, CNil};
+use frunk_core::coproduct::{Coproduct, CNil};
//use std::rc::{Rc, Weak};
#[derive(Clone, PartialEq, Eq, Hash)]
diff --git a/aris/src/proofs/treeproof_tests.rs b/aris/src/proofs/treeproof_tests.rs
index 8e1a064f..ae67bbef 100644
--- a/aris/src/proofs/treeproof_tests.rs
+++ b/aris/src/proofs/treeproof_tests.rs
@@ -3,7 +3,7 @@ use super::treeproof::*;
#[test]
fn demo_prettyprinting() {
- use frunk::Coproduct::Inl;
+ use frunk_core::coproduct::Coproduct::Inl;
use parser::parse_unwrap as p;
let proof1 = TreeProof(TreeSubproof {
premises: vec![((),p("A")), ((),p("B"))],
diff --git a/aris/src/proofs/xml_interop.rs b/aris/src/proofs/xml_interop.rs
index a3f338b7..da15a7cb 100644
--- a/aris/src/proofs/xml_interop.rs
+++ b/aris/src/proofs/xml_interop.rs
@@ -174,7 +174,7 @@ pub fn xml_from_proof_and_metadata);
impl