From 6ea2bed8eb04a3489c701a5925660676bd7f5c4c Mon Sep 17 00:00:00 2001 From: Juho Rautioaho Date: Sat, 27 Oct 2018 20:14:56 +0900 Subject: [PATCH 1/5] change wording of an example problem statement in docs --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4c31aa4..dcb4ebb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -768,7 +768,7 @@ distinct strongly-connected components (SCCs), e.g., the one involving `0` versus the one involving `4`. **Problem statement:** Suppose that we wish to explore this graph, to -build a list (or `Vec`) of all of the nodes that it contains. +build a list (or `Vec`) with all of the edges that it contains. **Desired solution program:** Consider the simple (naive) recursive exploration logic, defined From 2e41b4051e8278958ea8c0061b052dc6f9a98d05 Mon Sep 17 00:00:00 2001 From: Juho Rautioaho Date: Sat, 27 Oct 2018 20:21:11 +0900 Subject: [PATCH 2/5] change wording of an example - remove ambiguous use of 'editor' --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index dcb4ebb..fa5b26c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -334,18 +334,18 @@ let check = thunk![ if get!(den2) == 0 { None } else { Some(get!(div)) } ]; # } ``` -After allocating `num`, `den` and `check`, the editor changes `den` +After allocating `num`, `den` and `check`, the programmer changes `den` and observes `check`, inducing the following change propagation behavior. In sum, _whether_ `div` runs is based on _demand_ from the Editor (of the output of `check`), _and_ the value of input cell `den`, via the condition in `check`: -1. When the editor demands thunk `check` the first time, Adapton +1. When the thunk `check` is demanded for first time, Adapton executes the condition, and cell `den` holds `2`, which is non-zero. Hence, the `else` branch executes `get!(div)`, which demands the output of the division, `21`. -2. After this first observation of `check`, the editor changes cell +2. After this first observation of `check`, the programmer changes cell `den` to `0`, and re-demands the output of thunk `check`. In response, Adapton's change propagation algorithm first re-executes the condition (not the division), and the condition branches to the From 89723f3e570ab5c50bf2968e25811c07ae21df66 Mon Sep 17 00:00:00 2001 From: Anton Kochkov Date: Sun, 29 Sep 2019 18:26:01 +0800 Subject: [PATCH 3/5] Rust 2018 edition upgrade --- src/catalog/bitstring.rs | 12 ++-- src/catalog/collections.rs | 80 ++++++++++++------------- src/catalog/trie.rs | 68 ++++++++++----------- src/engine.rs | 120 ++++++++++++++++++------------------- src/macros.rs | 8 +-- src/parse_val.rs | 8 +-- src/reflect.rs | 10 ++-- 7 files changed, 153 insertions(+), 153 deletions(-) diff --git a/src/catalog/bitstring.rs b/src/catalog/bitstring.rs index c2d4771..b4f7375 100644 --- a/src/catalog/bitstring.rs +++ b/src/catalog/bitstring.rs @@ -7,12 +7,12 @@ pub struct BS { } pub trait BitString { - fn pow(i64, i64) -> i64; - fn flip(i64, i64) -> i64; - fn is_set(i64, i64) -> bool; - fn prepend(i64, BS) -> BS; - fn length(BS) -> i64; - fn shift_left(BS, i64) -> BS; + fn pow(_: i64, _: i64) -> i64; + fn flip(_: i64, _: i64) -> i64; + fn is_set(_: i64, _: i64) -> bool; + fn prepend(_: i64, _: BS) -> BS; + fn length(_: BS) -> i64; + fn shift_left(_: BS, _: i64) -> BS; const MAX_LEN: i64; } diff --git a/src/catalog/collections.rs b/src/catalog/collections.rs index 2d2ac17..d0eef85 100644 --- a/src/catalog/collections.rs +++ b/src/catalog/collections.rs @@ -3,11 +3,11 @@ use std::hash::{Hash,Hasher}; use std::collections::hash_map::DefaultHasher; use std::rc::Rc; -use macros::* ; -use adapton::engine::* ; +use crate::macros::* ; +use crate::adapton::engine::* ; pub mod trie { - pub use catalog::trie::*; + pub use crate::catalog::trie::*; } #[derive(Clone,Copy,Hash,Eq,PartialEq,Debug)] @@ -36,11 +36,11 @@ pub trait ListIntro : Debug+Clone+Hash+PartialEq+Eq+'static { /// Introduce an empty list fn nil () -> Self ; /// Introduce a Cons cell - fn cons (X, Self) -> Self ; + fn cons (_: X, _: Self) -> Self ; /// Introduce a Name "cons" cell - fn name (Name, Self) -> Self ; + fn name (_: Name, _: Self) -> Self ; /// Introduce a list with an articulation that holds a list - fn art (Art) -> Self ; + fn art (_: Art) -> Self ; /// Creates a singleton list. Derived from `cons` and `nil` introduction forms. fn singleton (hd:X) -> Self { @@ -84,7 +84,7 @@ pub trait ListElim : Debug+Clone+Hash+PartialEq+Eq { /// Eliminates the `art` case internally, by forcing the art and /// eliminating the resulting list with the given handler functions; /// forces multiple `art` cases, if need be. - fn elim (&Self, NilF, ConsF, NameF) -> Res + fn elim (_: &Self, _: NilF, _: ConsF, _: NameF) -> Res where NilF:FnOnce( &Self) -> Res , ConsF:FnOnce(&X, &Self) -> Res , NameF:FnOnce(&Name, &Self) -> Res ; @@ -93,7 +93,7 @@ pub trait ListElim : Debug+Clone+Hash+PartialEq+Eq { /// argument. This variant is needed due to the move semantics of /// Rust. The argument is moved into the body of the activated /// handler function when it is applied. - fn elim_arg (Self, Arg, NilF, ConsF, NameF) -> Res + fn elim_arg (_: Self, _: Arg, _: NilF, _: ConsF, _: NameF) -> Res where NilF:FnOnce( Self, Arg) -> Res , ConsF:FnOnce(X, Self, Arg) -> Res , NameF:FnOnce(Name, Self, Arg) -> Res ; @@ -314,13 +314,13 @@ pub fn list_append+ListElim>(l1:L, l2:L) -> L { pub trait RoseIntro : Debug+Clone+Hash+PartialEq+Eq { type List: ListElim; /// Introduce a leaf with exactly zero children - fn leaf (Leaf) -> Self; + fn leaf (_: Leaf) -> Self; /// Introduce a branch with zero or more subtrees - fn branch (Branch, Self::List) -> Self; + fn branch (_: Branch, _: Self::List) -> Self; /// Introduce a Named subtree - fn name (Name, Self) -> Self ; + fn name (_: Name, _: Self) -> Self ; /// Introduce a list with an articulation that holds a list - fn art (Art) -> Self ; + fn art (_: Art) -> Self ; } /// Rose Trees: A tree with arbitrary branching at each node. @@ -330,7 +330,7 @@ pub trait RoseIntro : Debug+Clone+Hash+PartialEq+Eq { pub trait RoseElim : Debug+Clone+Hash+PartialEq+Eq { type Children: ListElim; fn elim - (Self, Arg, LeafFn, BranchFn, NameFn) -> Res + (_: Self, _: Arg, _: LeafFn, _: BranchFn, _: NameFn) -> Res where LeafFn: FnOnce(Leaf, Arg) -> Res , BranchFn:FnOnce(Branch, Self::Children, Arg) -> Res , NameFn: FnOnce(Name, Self, Arg) -> Res @@ -341,12 +341,12 @@ pub trait RoseElim : Debug+Clone+Hash+PartialEq+Eq { /// Pugh and Teiltelbaum's POPL 1989 paper, and its "Chunky List" /// representation (*Incremental Computation via Function Caching*). pub trait Level : Debug+Hash+PartialEq+Eq+Clone+'static { - fn new(&X) -> Self ; + fn new(_: &X) -> Self ; fn bits () -> Self ; fn zero () -> Self ; - fn inc (&Self) -> Self ; - fn add (&Self, &Self) -> Self ; - fn lte (&Self, &Self) -> bool ; + fn inc (_: &Self) -> Self ; + fn add (_: &Self, _: &Self) -> Self ; + fn lte (_: &Self, _: &Self) -> bool ; fn max_val () -> Self ; fn max (a:&Self, b:&Self) -> Self { if Self::lte(a, b) { b.clone() } else { a.clone() } @@ -359,19 +359,19 @@ pub trait Level : Debug+Hash+PartialEq+Eq+Clone+'static { /// further, the binary cases `name` and `bin` carry levels of type `Lev`, which helps establish and maintain balance. pub trait TreeIntro : Debug+Hash+PartialEq+Eq+Clone+'static { fn nil () -> Self ; - fn leaf (Leaf) -> Self ; - fn bin (Lev, Self, Self) -> Self ; + fn leaf (_: Leaf) -> Self ; + fn bin (_: Lev, _: Self, _: Self) -> Self ; // requisite "adaptonic" constructors: `name` and `art`: - fn name (Name, Lev, Self, Self) -> Self ; - fn art (Art) -> Self ; + fn name (_: Name, _: Lev, _: Self, _: Self) -> Self ; + fn art (_: Art) -> Self ; } pub trait TreeElim : Debug+Hash+PartialEq+Eq+Clone+'static { - fn lev_of_tree(&Self) -> Lev ; + fn lev_of_tree(_: &Self) -> Lev ; fn elim - (Self, NilC, LeafC, BinC, NameC) -> Res + (_: Self, _: NilC, _: LeafC, _: BinC, _: NameC) -> Res where NilC : FnOnce() -> Res , LeafC : FnOnce(Leaf) -> Res , BinC : FnOnce(Lev, Self, Self) -> Res @@ -379,7 +379,7 @@ pub trait TreeElim : Debug+Hash+PartialEq+Eq+Clone+'static { ; fn elim_ref - (&Self, NilC, LeafC, BinC, NameC) -> Res + (_: &Self, _: NilC, _: LeafC, _: BinC, _: NameC) -> Res where NilC : FnOnce() -> Res , LeafC : FnOnce(&Leaf) -> Res , BinC : FnOnce(&Lev, &Self, &Self) -> Res @@ -387,7 +387,7 @@ pub trait TreeElim : Debug+Hash+PartialEq+Eq+Clone+'static { ; fn elim_arg - (Self, Arg, NilC, LeafC, BinC, NameC) -> Res + (_: Self, _: Arg, _: NilC, _: LeafC, _: BinC, _: NameC) -> Res where NilC : FnOnce(Arg) -> Res , LeafC : FnOnce(Leaf, Arg) -> Res , BinC : FnOnce(Lev, Self, Self, Arg) -> Res @@ -395,7 +395,7 @@ pub trait TreeElim : Debug+Hash+PartialEq+Eq+Clone+'static { ; fn full_move - (Self, Arg, NilC, LeafC, BinC, NameC, ArtC) -> Res + (_: Self, _: Arg, _: NilC, _: LeafC, _: BinC, _: NameC, _: ArtC) -> Res where NilC : FnOnce(Arg) -> Res , LeafC : FnOnce(Leaf, Arg) -> Res , BinC : FnOnce(Lev, Self, Self, Arg) -> Res @@ -436,11 +436,11 @@ pub trait MapElim : Debug+Hash+PartialEq+Eq+Clone+'static { - fn find(&Self, d:&Dom) -> Option; - fn remove (Self, d:&Dom) -> (Self, Option); - fn fold(Self, Res, Rc) -> Res where + fn find(_: &Self, d:&Dom) -> Option; + fn remove (_: Self, d:&Dom) -> (Self, Option); + fn fold(_: Self, _: Res, _: Rc) -> Res where F:Fn(Dom, Cod, Res) -> Res; - fn append(Self, other:Self) -> Self; + fn append(_: Self, other:Self) -> Self; } pub fn map_empty>() -> M { M::empty() } @@ -452,11 +452,11 @@ pub trait SetIntro : Debug+Hash+PartialEq+Eq+Clone+'static { fn empty () -> Self; - fn add (Self, e:Elm) -> Self; - fn remove (Self, e:&Elm) -> Self; - fn union (Self, Self) -> Self; - fn inter (Self, Self) -> Self; - fn diff (Self, Self) -> Self; + fn add (_: Self, e:Elm) -> Self; + fn remove (_: Self, e:&Elm) -> Self; + fn union (_: Self, _: Self) -> Self; + fn inter (_: Self, _: Self) -> Self; + fn diff (_: Self, _: Self) -> Self; } impl+MapElim> SetIntro for Map { @@ -486,7 +486,7 @@ pub trait SetElim : Debug+Hash+PartialEq+Eq+Clone+'static { fn is_mem (set:&Self, e:&Elm) -> bool; - fn fold(set:Self, Res, F) -> Res where + fn fold(set:Self, _: Res, _: F) -> Res where F:Fn(Elm, Res) -> Res; } @@ -754,7 +754,7 @@ pub fn filter_list_of_tree , L:ListIntro+ListElim+'static , T:TreeElim+'static > - (tree:T, pred:Box bool>) -> L + (tree:T, pred:Box bool>) -> L { let nil = L::nil(); tree_fold_seq @@ -775,7 +775,7 @@ pub fn filter_tree_of_tree , Te:TreeElim+'static , Ti:TreeIntro+TreeElim+'static > - (tree:Te, pred:Box bool>) -> Ti + (tree:Te, pred:Box bool>) -> Ti { tree_fold_up (tree, @@ -797,7 +797,7 @@ pub fn monoid_of_tree < Lev:Level, X:Debug+Eq+Hash+Clone+'static , Te:TreeElim+'static > - (tree:Te, id_elm:X, bin_op:Rc X>) -> X + (tree:Te, id_elm:X, bin_op:Rc X>) -> X { let bin_op2 = bin_op.clone(); tree_fold_up @@ -1067,7 +1067,7 @@ pub fn test_mergesort2 () { ||prune_tree_of_tree::<_,_,_,Tree<_>>(t)); println!("input tree: {:?}", eager_tree_of_tree::<_,_,_,Tree<_>>(t.clone())); let s = ns(name_of_str("mergesort"), - ||mergesort_list_of_tree2::<_,_,_,List<_>>(t, (Some(name_of_usize(666))))); + ||mergesort_list_of_tree2::<_,_,_,List<_>>(t, Some(name_of_usize(666)))); let o = vec_of_list(s, None); println!("output vec: {:?}", o); o diff --git a/src/catalog/trie.rs b/src/catalog/trie.rs index 5a8596f..8f13be8 100644 --- a/src/catalog/trie.rs +++ b/src/catalog/trie.rs @@ -4,10 +4,10 @@ use std::collections::hash_map::DefaultHasher; use std::rc::Rc; use std::cmp::min; -use adapton::catalog::collections::{ListIntro, ListElim, list_fold}; -use adapton::catalog::bitstring::*; -use adapton::engine::*; -use macros::*; +use crate::adapton::catalog::collections::{ListIntro, ListElim, list_fold}; +use crate::adapton::catalog::bitstring::*; +use crate::adapton::engine::*; +use crate::macros::*; /// Probablistically Balanced Trie /// Rough implementation of probabilistic tries from OOPSLA 2015 paper. @@ -32,7 +32,7 @@ pub struct Meta { } pub trait MetaT { - fn hash_seeded(&self, u64); + fn hash_seeded(&self, _: u64); } impl MetaT for Meta { @@ -86,39 +86,39 @@ impl MetaT for Meta { // impl Eq for Trie {} pub trait TrieIntro: Debug + Hash + PartialEq + Eq + Clone + 'static { - fn nil(BS) -> Self; - fn leaf(BS, X) -> Self; - fn bin(BS, Self, Self) -> Self; - fn root(Meta, Self) -> Self; + fn nil(_: BS) -> Self; + fn leaf(_: BS, _: X) -> Self; + fn bin(_: BS, _: Self, _: Self) -> Self; + fn root(_: Meta, _: Self) -> Self; // requisite "adaptonic" constructors: `name` and `art`: - fn name(Name, Self) -> Self; - fn art(Art) -> Self; + fn name(_: Name, _: Self) -> Self; + fn art(_: Art) -> Self; - fn empty(Meta) -> Self; - fn singleton(Meta, Name, X) -> Self; - fn extend(Name, Self, X) -> Self; + fn empty(_: Meta) -> Self; + fn singleton(_: Meta, _: Name, _: X) -> Self; + fn extend(_: Name, _: Self, _: X) -> Self; } pub trait TrieElim: Debug + Hash + PartialEq + Eq + Clone + 'static { - fn find(&Self, &X, i64) -> Option; - fn is_empty(&Self) -> bool; - fn split_atomic(Self) -> Self; + fn find(_: &Self, _: &X, _: i64) -> Option; + fn is_empty(_: &Self) -> bool; + fn split_atomic(_: Self) -> Self; - fn elim(Self, NilC, LeafC, BinC, RootC, NameC) -> Res + fn elim(_: Self, _: NilC, _: LeafC, _: BinC, _: RootC, _: NameC) -> Res where NilC: FnOnce(BS) -> Res, LeafC: FnOnce(BS, X) -> Res, BinC: FnOnce(BS, Self, Self) -> Res, RootC: FnOnce(Meta, Self) -> Res, NameC: FnOnce(Name, Self) -> Res; - fn elim_arg(Self, - Arg, - NilC, - LeafC, - BinC, - RootC, - NameC) + fn elim_arg(_: Self, + _: Arg, + _: NilC, + _: LeafC, + _: BinC, + _: RootC, + _: NameC) -> Res where NilC: FnOnce(BS, Arg) -> Res, LeafC: FnOnce(BS, X, Arg) -> Res, @@ -126,12 +126,12 @@ pub trait TrieElim: Debug + Hash + PartialEq + Eq + Clone + 'static { RootC: FnOnce(Meta, Self, Arg) -> Res, NameC: FnOnce(Name, Self, Arg) -> Res; - fn elim_ref(&Self, - NilC, - LeafC, - BinC, - RootC, - NameC) + fn elim_ref(_: &Self, + _: NilC, + _: LeafC, + _: BinC, + _: RootC, + _: NameC) -> Res where NilC: FnOnce(&BS) -> Res, LeafC: FnOnce(&BS, &X) -> Res, @@ -420,7 +420,7 @@ impl TrieElim for Trie pub trait SetIntro: Debug + Hash + PartialEq + Eq + Clone + 'static { fn empty() -> Self; - fn add(Self, e: X) -> Self; + fn add(_: Self, e: X) -> Self; // fn remove(Self, e: &X) -> Self; // fn union(Self, Self) -> Self; // fn inter(Self, Self) -> Self; @@ -428,8 +428,8 @@ pub trait SetIntro: Debug + Hash + PartialEq + Eq + Clone + 'static { } pub trait SetElim: Debug + Hash + PartialEq + Eq + Clone + 'static { - fn mem(&Self, &X) -> bool; - fn fold(Self, Res, Rc) -> Res where F: Fn(X, Res) -> Res; + fn mem(_: &Self, _: &X) -> bool; + fn fold(_: Self, _: Res, _: Rc) -> Res where F: Fn(X, Res) -> Res; } impl + TrieElim> SetIntro for Set { diff --git a/src/engine.rs b/src/engine.rs index 2bb00f4..d6c9f8b 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -25,8 +25,8 @@ use std::mem::transmute; use std::rc::Rc; use std::fmt::Write; -use macros::{ProgPt}; -use reflect; +use crate::macros::{ProgPt}; +use crate::reflect; thread_local!(static GLOBALS: RefCell = RefCell::new(Globals{engine:Engine::Naive})); thread_local!(static UNIT_NAME: Name = Name{ hash:0, symbol: Rc::new(NameSym::Unit) }); @@ -65,12 +65,12 @@ fn my_hash(obj: T) -> u64 /// walking their values, recursively. pub mod reflect_dcg { - use reflect::*; - pub use parse_val; + use crate::reflect::*; + pub use crate::parse_val; use std::fmt::{Write}; use super::{TraceSt,TRACES,GLOBALS,Engine}; - use adapton::engine::Name; + use crate::adapton::engine::Name; /// Begin a debugging extent in the trace, with associated name and message. pub fn debug_begin(n:Option, msg:Option) { @@ -173,7 +173,7 @@ pub mod reflect_dcg { }) } } -use reflect::Reflect; +use crate::reflect::Reflect; //#[macro_export] @@ -388,7 +388,7 @@ pub enum Engine { #[derive(Debug)] pub struct DCG { pub flags : Flags, // public because I dont want to write / design abstract accessors - table : HashMap, Box>, + table : HashMap, Box>, stack : Vec, path : Rc, //cnt : Cnt, @@ -483,19 +483,19 @@ impl Debug for Path { trait GraphNode : Debug + reflect::Reflect { fn res_typeid (self:&Self) -> TypeId ; fn preds_alloc<'r> (self:&Self) -> Vec> ; - fn preds_obs<'r> (self:&Self) -> Vec<(Rc, Option>>)> ; - fn preds_insert<'r>(self:&'r mut Self, Effect, &Rc, Option>>) -> () ; - fn preds_remove<'r>(self:&'r mut Self, &Rc) -> () ; + fn preds_obs<'r> (self:&Self) -> Vec<(Rc, Option>>)> ; + fn preds_insert<'r>(self:&'r mut Self, _: Effect, _: &Rc, _: Option>>) -> () ; + fn preds_remove<'r>(self:&'r mut Self, _: &Rc) -> () ; fn succs_def<'r> (self:&Self) -> bool ; fn succs_mut<'r> (self:&'r mut Self) -> &'r mut Vec ; fn succs<'r> (self:&'r Self) -> &'r Vec ; - fn hash_seeded (self:&Self, u64) -> u64 ; + fn hash_seeded (self:&Self, _: u64) -> u64 ; } #[derive(Debug,Clone)] struct Frame { loc : Rc, // The currently-executing node - succs : Vec<(Succ, Option>>)>, // The currently-executing node's effects (viz., the nodes it demands) + succs : Vec<(Succ, Option>>)>, // The currently-executing node's effects (viz., the nodes it demands) } impl reflect::Reflect for Frame { @@ -512,7 +512,7 @@ struct Succ { dirty : bool, // mutated to dirty when loc changes, or any of its successors change loc : Rc, // Target of the effect, aka, the successor, by this edge effect : Effect, - dep : Rc>, // Abstracted dependency information (e.g., for Observe Effect, the prior observed value) + dep : Rc>, // Abstracted dependency information (e.g., for Observe Effect, the prior observed value) } #[derive(Debug,Clone)] @@ -526,7 +526,7 @@ struct Pred { /// `dep.dirty(...)` permits the dirtying algorithm of the engine to /// check whether the observed value has changed, and whether /// dirtying should continue to the predecessors of `loc` . - dep : Option>>, + dep : Option>>, } impl reflect::Reflect for Succ { @@ -547,7 +547,7 @@ impl reflect::Reflect> for Vec { } } -impl reflect::Reflect> for Vec<(Succ, Option>>)> { +impl reflect::Reflect> for Vec<(Succ, Option>>)> { fn reflect(&self) -> Vec { self.iter().map(|ref x| x.0.reflect()).collect::>() } @@ -610,7 +610,7 @@ enum Node { } impl reflect::Reflect for Node { fn reflect(&self) -> reflect::Node { - use parse_val::parse_val; + use crate::parse_val::parse_val; match *self { Node::Comp(ref n) => { reflect::Node::Comp( @@ -666,7 +666,7 @@ struct MutNode { struct CompNode { preds : Vec, succs : Vec, - producer : Box>, // Producer can be App, where type Arg is hidden. + producer : Box>, // Producer can be App, where type Arg is hidden. res : Option, } @@ -706,20 +706,20 @@ pub enum NameChoice { trait Producer : Debug { // fn produce(self:&Self, st:&mut DCG) -> Res; fn produce(self:&Self) -> Res; - fn copy(self:&Self) -> Box>; - fn eq(self:&Self, other:&Producer) -> bool; + fn copy(self:&Self) -> Box>; + fn eq(self:&Self, other:&dyn Producer) -> bool; fn prog_pt<'r>(self:&'r Self) -> &'r ProgPt; } // Consume a value of type Arg. trait Consumer : Debug { - fn consume(self:&mut Self, Arg); + fn consume(self:&mut Self, _: Arg); fn get_arg(self:&mut Self) -> Arg; } // struct App is hidden by traits Comp and CompWithArg, below. #[derive(Clone)] struct App { prog_pt: ProgPt, - fn_box: Rc Res>>, + fn_box: Rc Res>>, arg: Arg, spurious: Spurious, } @@ -749,7 +749,7 @@ impl Box> { + fn copy(self:&Self) -> Box> { Box::new(App{ prog_pt:self.prog_pt.clone(), fn_box:self.fn_box.clone(), @@ -760,7 +760,7 @@ impl(self:&'r Self) -> &'r ProgPt { & self.prog_pt } - fn eq (&self, other:&Producer) -> bool { + fn eq (&self, other:&dyn Producer) -> bool { if &self.prog_pt == other.prog_pt() { let other = Box::new(other) ; // This is safe if the prog_pt implies unique Arg and Res types. @@ -782,7 +782,7 @@ impl // ----------- Location resolution: -fn lookup_abs<'r>(st:&'r mut DCG, loc:&Rc) -> &'r mut Box { +fn lookup_abs<'r>(st:&'r mut DCG, loc:&Rc) -> &'r mut Box { match st.table.get_mut( loc ) { None => panic!("dangling pointer: {:?}", loc), Some(node) => node.be_node() // This is a weird workaround; TODO-Later: Investigate. @@ -797,7 +797,7 @@ fn get_top_stack_loc(st:&DCG) -> Option> { } } -fn assert_graphnode_res_type (loc:&Loc, node:&Box, top_stack:Option>) { +fn assert_graphnode_res_type (loc:&Loc, node:&Box, top_stack:Option>) { let res_typeid = TypeId::of::(); let node_res_typeid = node.res_typeid(); if node_res_typeid != res_typeid { @@ -839,7 +839,7 @@ impl GraphNode for Node { Node::Pure(_) => unreachable!(), }} - fn preds_obs(self:&Self) -> Vec<(Rc, Option>>)> { + fn preds_obs(self:&Self) -> Vec<(Rc, Option>>)> { match *self { Node::Mut(ref nd) => nd.preds.iter().filter_map( @@ -857,7 +857,7 @@ impl GraphNode for Node { Node::Pure(_) => unreachable!(), }} - fn preds_insert (self:&mut Self, eff:Effect, loc:&Rc, dep:Option>>) -> () { + fn preds_insert (self:&mut Self, eff:Effect, loc:&Rc, dep:Option>>) -> () { match *self { Node::Mut(ref mut nd) => nd.preds.push (Pred{effect:eff,loc:loc.clone(),dep:dep.clone()}), Node::Comp(ref mut nd) => nd.preds.push (Pred{effect:eff,loc:loc.clone(),dep:dep.clone()}), Node::Pure(_) => unreachable!(), @@ -889,18 +889,18 @@ impl GraphNode for Node { } trait ShapeShifter { - fn be_node<'r> (self:&'r mut Self) -> &'r mut Box ; + fn be_node<'r> (self:&'r mut Self) -> &'r mut Box ; } impl ShapeShifter for Box> { - fn be_node<'r>(self:&'r mut Self) -> &'r mut Box { + fn be_node<'r>(self:&'r mut Self) -> &'r mut Box { // TODO-Later: Why is this transmute needed here ?? unsafe { transmute::<_,_>(self) } } } -impl ShapeShifter for Box { - fn be_node<'r>(self:&'r mut Self) -> &'r mut Box { +impl ShapeShifter for Box { + fn be_node<'r>(self:&'r mut Self) -> &'r mut Box { // TODO-Later: Why is this transmute needed here ?? unsafe { transmute::<_,_>(self) } } @@ -944,7 +944,7 @@ fn loc_produce(g:&RefCell, loc:& //st.cnt.stack = if st.cnt.stack > st.stack.len() { st.cnt.stack } else { st.stack.len() } ; let prev_path = st.path.clone () ; st.path = loc.path.clone() ; - let producer : Box> = { + let producer : Box> = { let node : &mut Node = res_node_of_loc( st, loc ) ; match *node { Node::Comp(ref nd) => nd.producer.copy(), @@ -998,7 +998,7 @@ fn clean_comp { for succ in succs.iter() { let dirty = { - let mut st = &mut *g.borrow_mut(); + let st = &mut *g.borrow_mut(); get_succ_mut(st, loc, succ.effect.clone(), &succ.loc).dirty } ; if dirty { @@ -1014,7 +1014,7 @@ fn clean_comp return DCGRes{changed:changed} } else { - let mut st : &mut DCG = &mut *g.borrow_mut(); + let st : &mut DCG = &mut *g.borrow_mut(); //st.cnt.clean += 1 ; get_succ_mut(st, loc, succ.effect.clone(), &succ.loc).dirty = false ; dcg_effect!(reflect::trace::Effect::CleanEdge, Some(loc), succ); @@ -1117,7 +1117,7 @@ struct ForceAbsDep { /// types that we do not instantiate here; we only store an `Abs` here phm:PhantomData<(Arg,T,DiffT,S)>, /// abstract mapping, so we can re-map via `map.1.map(map.0,_)` - map:(Abs, Box>), + map:(Abs, Box>), } impl AbsDiff for ForceAbsDep { @@ -1266,7 +1266,7 @@ fn revoke_succs<'x> (st:&mut DCG, src:&Rc, succs:&Vec) { //let mut succ_idx = 0; for succ in succs.iter() { dcg_effect!(reflect::trace::Effect::Remove, Some(src), succ); - let succ_node : &mut Box = lookup_abs(st, &succ.loc) ; + let succ_node : &mut Box = lookup_abs(st, &succ.loc) ; succ_node.preds_remove(src) } } @@ -1304,7 +1304,7 @@ fn get_succ_mut<'r>(st:&'r mut DCG, src_loc:&Rc, eff:Effect, tgt_loc:&Rc) { - let pred_locs : Vec<(Rc, Option>>)> = lookup_abs( st, loc ).preds_obs() ; + let pred_locs : Vec<(Rc, Option>>)> = lookup_abs( st, loc ).preds_obs() ; for (pred_loc, dep) in pred_locs { let stop : bool = match dep { None => false, @@ -1423,19 +1423,19 @@ trait Adapton : Debug+PartialEq+Eq+Hash+Clone { fn new () -> Self ; /// Creates or re-enters a given namespace; performs the given computation there. - fn ns (g: &RefCell, Name, body:F) -> T where F:FnOnce() -> T; + fn ns (g: &RefCell, _: Name, body:F) -> T where F:FnOnce() -> T; /// Enters a special "namespace" where all name uses are ignored; instead, Adapton uses structural identity. fn structural (g: &RefCell, body:F) -> T where F:FnOnce() -> T; /// Creates immutable, eager articulation. - fn put (self:&mut Self, T) -> AbsArt ; + fn put (self:&mut Self, _: T) -> AbsArt ; /// Creates a mutable articulation. - fn cell (self:&mut Self, Name, T) -> AbsArt ; + fn cell (self:&mut Self, _: Name, _: T) -> AbsArt ; /// Mutates a mutable articulation. - fn set (self:&mut Self, AbsArt, T) ; + fn set (self:&mut Self, _: AbsArt, _: T) ; /// Creates an articulated computation. fn thunk Res >>, + fn_box:Rc Res >>, arg:Arg, spurious:Spurious) -> AbsArt ; /// Demand and observe arts (both thunks and cells) /// /// cycle_out gives an optional return value for cycles; None means no cycles are permitted - fn force (g:&RefCell, &AbsArt, Option) -> T ; + fn force (g:&RefCell, _: &AbsArt, _: Option) -> T ; /// Demand & observe arts, through a mapping function (e.g., for projections) fn force_map - (g:&RefCell, &AbsArt, F) -> S + (g:&RefCell, _: &AbsArt, _: F) -> S where F:Fn(&Art, T) -> S ; @@ -1472,7 +1472,7 @@ trait Adapton : Debug+PartialEq+Eq+Hash+Clone { DiffT:'static+Eq+Debug+Clone+Hash, S:'static+Eq+Debug+Clone+Hash> (g:&RefCell, - absmapfam:Box>, + absmapfam:Box>, arg:Arg, art:&AbsArt) -> S ; } @@ -1628,7 +1628,7 @@ impl Adapton for DCG { (self:&mut DCG, id:NameChoice, prog_pt:ProgPt, - fn_box:Rc Res>>, + fn_box:Rc Res>>, arg:Arg, spurious:Spurious) -> AbsArt { @@ -1675,7 +1675,7 @@ impl Adapton for DCG { dirty:false}; frame.succs.push((succ, None)) }}; - let producer : Box> = + let producer : Box> = Box::new(App{prog_pt:prog_pt, fn_box:fn_box, arg:arg.clone(), @@ -1713,7 +1713,7 @@ impl Adapton for DCG { (false, true, true) }, Some(node) => { - let node: &mut Box = node ; + let node: &mut Box = node ; assert_graphnode_res_type::(&loc, node, top_loc); let res_nd: &mut Box> = unsafe { transmute::<_,_>( node ) } ; match ** res_nd { @@ -1855,7 +1855,7 @@ impl Adapton for DCG { let res = mapf(&Art{art:EnumArt::Loc(loc.clone())}, val.clone()); match st.stack.last_mut() { None => (), Some(frame) => { // `dep` records the mapping function - let dep : Rc> = Rc::new(Box::new(ForceMapDep{ + let dep : Rc> = Rc::new(Box::new(ForceMapDep{ raw:PhantomData, mapf:mapf, res:res.clone()})); @@ -1882,7 +1882,7 @@ impl Adapton for DCG { T:'static+Eq+Debug+Clone+Hash, DiffT:'static+Eq+Debug+Clone+Hash, S:'static+Eq+Debug+Clone+Hash> - (g:&RefCell, absmapfam:Box>, + (g:&RefCell, absmapfam:Box>, arg:Arg, art:&AbsArt) -> S { match *art { @@ -1922,7 +1922,7 @@ impl Adapton for DCG { let res = absmapfam.map(arg.clone(),/*&Art{art:EnumArt::Loc(loc.clone())},*/val.clone()); match st.stack.last_mut() { None => (), Some(frame) => { // `dep` records the mapping function - let dep : Rc> = Rc::new(Box::new(ForceAbsDep{ + let dep : Rc> = Rc::new(Box::new(ForceAbsDep{ phm:PhantomData, map:(absmapfam.abs(arg), absmapfam), @@ -2117,7 +2117,7 @@ enum EnumArt { /// Location in table. Loc(Rc), /// A closure that is 'force-able' - Force(Rc>), + Force(Rc>), } impl Hash for EnumArt { @@ -2157,8 +2157,8 @@ impl Eq for EnumArt { } trait Force { fn force(&self) -> T; - fn copy(self:&Self) -> Box>; - fn eq(self:&Self, other:&Force) -> bool; + fn copy(self:&Self) -> Box>; + fn eq(self:&Self, other:&dyn Force) -> bool; fn id<'r>(self:&'r Self) -> &'r NameChoice; fn prog_pt<'r>(self:&'r Self) -> &'r ProgPt; fn hash_u64(self:&Self) -> u64; @@ -2169,7 +2169,7 @@ trait Force { struct NaiveThunk { id:NameChoice, prog_pt:ProgPt, - fn_box:Rc Res >>, + fn_box:Rc Res >>, arg:Arg, spurious:Spurious } @@ -2181,7 +2181,7 @@ impl fn force(&self) -> T { (*self.fn_box)(self.arg.clone(), self.spurious.clone()) } - fn copy(self:&Self) -> Box> { + fn copy(self:&Self) -> Box> { Box::new(NaiveThunk{id:self.id.clone(), prog_pt:self.prog_pt.clone(), fn_box:self.fn_box.clone(), @@ -2201,7 +2201,7 @@ impl self.arg.hash( &mut hasher ); hasher.finish() } - fn eq (&self, other:&Force) -> bool { + fn eq (&self, other:&dyn Force) -> bool { if &self.id == other.id() && &self.prog_pt == other.prog_pt() { @@ -2427,7 +2427,7 @@ pub fn set (a:&Art, val:T) { pub fn thunk (id:NameChoice, prog_pt:ProgPt, - fn_box:Rc Res >>, + fn_box:Rc Res >>, arg:Arg, spurious:Spurious) -> Art { @@ -2456,7 +2456,7 @@ pub fn thunk - (thunk:Art, map_fn:Rc Res2>) -> Art + (thunk:Art, map_fn:Rc Res2>) -> Art { Art{art:EnumArt::Force( Rc::new(NaiveThunk{ @@ -2552,7 +2552,7 @@ pub fn force_abs T:'static+Eq+Debug+Clone+Hash, DiffT:'static+Eq+Debug+Clone+Hash, S:'static+Eq+Debug+Clone+Hash> - (absmapfam:Box>, arg:Arg, a:Art) -> S + (absmapfam:Box>, arg:Arg, a:Art) -> S { match a.art { EnumArt::Force(ref f) => absmapfam.map(arg, f.force()), diff --git a/src/macros.rs b/src/macros.rs index 6263d31..8fda541 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -862,8 +862,8 @@ macro_rules! let_thunk { #[test] fn test_let_cell_let_thunk_macros() { - use adapton::macros::*; - use adapton::engine::*; + use crate::adapton::macros::*; + use crate::adapton::engine::*; fn demand_graph(a: Art) -> Art { let c : Art = get!(let_thunk!{f = { @@ -910,8 +910,8 @@ macro_rules! let_memo { #[test] fn test_memo_macros() { - use adapton::macros::*; - use adapton::engine::*; + use crate::adapton::macros::*; + use crate::adapton::engine::*; fn demand_graph(a: Art) -> Art { let_memo!{c =(f)= { diff --git a/src/parse_val.rs b/src/parse_val.rs index f042dc6..9b0b7a5 100644 --- a/src/parse_val.rs +++ b/src/parse_val.rs @@ -8,8 +8,8 @@ //! traversal. use std::fmt::Debug; -use adapton::reflect::{Loc,Path,Val,ArtContent,Const}; -use adapton::engine::{Name, name_of_str, name_of_string}; +use crate::adapton::reflect::{Loc,Path,Val,ArtContent,Const}; +use crate::adapton::engine::{Name, name_of_str, name_of_string}; /// _Balanced tokens_: Tokens that must be balanced with a left and /// right instance and well-nested balanced tokens between them. @@ -235,7 +235,7 @@ fn path_of_val ( p:&Val ) -> Path { } fn name_of_val ( n:&Val ) -> Name { - use engine::*; + use crate::engine::*; match *n { Val::Constr( ref cons_name, ref cons_args ) => { @@ -283,7 +283,7 @@ fn name_of_val ( n:&Val ) -> Name { } fn name_option_of_val ( n:&Val ) -> Option { - use engine::*; + use crate::engine::*; match *n { Val::Constr( ref cons_name, ref cons_args ) => { diff --git a/src/reflect.rs b/src/reflect.rs index 8021828..b7dc2b9 100644 --- a/src/reflect.rs +++ b/src/reflect.rs @@ -20,13 +20,13 @@ version of values to "walk" them, finding their articulations, and walking their values, recursively. */ -use engine::Name; -use macros::ProgPt; +use crate::engine::Name; +use crate::macros::ProgPt; use std::fmt::Debug; use std::rc::Rc; use std::collections::HashMap; -pub use engine::reflect_dcg::*; +pub use crate::engine::reflect_dcg::*; /// This trait consists of the ability for a reference to `Self` to /// produce a `T`. Conceptually, that value of type T is the @@ -275,7 +275,7 @@ pub struct DCG { /// Wrapper for `parse_val::parse_val`. Transforms most Rust data /// that derives `Debug` into a reflected `Val`. pub fn reflect_val (v:&V) -> Val { - use parse_val::parse_val; + use crate::parse_val::parse_val; parse_val(v) } @@ -285,7 +285,7 @@ pub fn reflect_val (v:&V) -> Val { /// itself, not changes that the engine makes to it. pub mod trace { use std::fmt; - use engine; + use crate::engine; /// Distinguish fresh allocations from those that reuse an existing location. #[derive(Clone,Debug)] From 917e6ab8eddf979af14b9e15228e2273b0752e4c Mon Sep 17 00:00:00 2001 From: Anton Kochkov Date: Sun, 29 Sep 2019 18:27:04 +0800 Subject: [PATCH 4/5] Enable Rust 2018 --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index a4b0a30..76dd1e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "adapton" version = "0.3.29" +edition = "2018" authors = ["Matthew A. Hammer "] # A short blurb about the package. This is not rendered in any format when @@ -12,6 +13,7 @@ documentation = "https://docs.rs/adapton" homepage = "http://adapton.org" repository = "https://github.com/Adapton/adapton.rust/" + # This points to a file in the repository (relative to this Cargo.toml). The # contents of this file are stored and indexed in the registry. readme = "README.md" From f62b1e7e808fdc0d5b5820025ec245e54adb1e54 Mon Sep 17 00:00:00 2001 From: Anton Kochkov Date: Sun, 29 Sep 2019 18:48:14 +0800 Subject: [PATCH 5/5] dev branch is outdated and behind master So removing the mention from the README --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c6bb73c..1adfb94 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,8 @@ A general-purpose **Incremental Computation** (IC) library for Rust. Versions: --------- -- The [Adapton repo](https://github.com/Adapton/adapton.rust) has the latest, in `dev` and `master` branches. - - branch [dev](https://github.com/Adapton/adapton.rust/tree/dev) contains the **latest development**. - - branch `master` is "stable", e.g., for external libraries. - - Also see the [Adapton crate](https://crates.io/crates/adapton) for periodic "stable" releases. +- The [Adapton repo](https://github.com/Adapton/adapton.rust) has the latest code version in the `master` branch. +- The [Adapton crate](https://crates.io/crates/adapton) for periodic "stable" releases. - See also: A prior [OCaml implementation](https://github.com/plum-umd/adapton.ocaml). Research and Development Community: