diff --git a/Cargo.toml b/Cargo.toml index f9679d95..10663d35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hvm" -version = "1.0.10" +version = "1.0.11" edition = "2021" description = "A massively parallel functional runtime." repository = "https://github.com/HigherOrderCO/HVM" diff --git a/examples/README.md b/examples/README.md index 35553534..ef375371 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,6 +3,6 @@ HVM Examples This directory contains just a few examples and cool tricks involving the HVM. For more comprehensive examples, please visit the -[Kindex](https://github.com/higherorderco/Kindex) repository, which has tons of +[Kindex](https://github.com/higherorderco/kindex) repository, which has tons of datatypes and algorithms on the [Kind](https://github.com/higherorderco/kind) language, which compiles 1-to-1 to the HVM. diff --git a/examples/sort/bitonic/main.hvm b/examples/sort/bitonic/main.hvm index 15ec9da2..ed89e3ac 100644 --- a/examples/sort/bitonic/main.hvm +++ b/examples/sort/bitonic/main.hvm @@ -1,9 +1,9 @@ // Atomic Swapper (HVM builtin) -//(Data.U60.swap 0 a b) = (Both a b) -//(Data.U60.swap n a b) = (Both b a) +//(U60.swap 0 a b) = (Both a b) +//(U60.swap n a b) = (Both b a) // Swaps distant values in parallel; corresponds to a Red Box -(Warp s (Leaf a) (Leaf b)) = (Data.U60.swap (^ (> a b) s) (Leaf a) (Leaf b)) +(Warp s (Leaf a) (Leaf b)) = (U60.swap (^ (> a b) s) (Leaf a) (Leaf b)) (Warp s (Both a b) (Both c d)) = (Join (Warp s a c) (Warp s b d)) // Rebuilds the warped tree in the original order diff --git a/examples/sort/radix/main.hvm b/examples/sort/radix/main.hvm index 90590165..4ef43577 100644 --- a/examples/sort/radix/main.hvm +++ b/examples/sort/radix/main.hvm @@ -26,30 +26,30 @@ // Radix : U60 -> Map (Radix n) = let r = Used - let r = (Data.U60.swap (& n 1) r Free) - let r = (Data.U60.swap (& n 2) r Free) - let r = (Data.U60.swap (& n 4) r Free) - let r = (Data.U60.swap (& n 8) r Free) - let r = (Data.U60.swap (& n 16) r Free) - let r = (Data.U60.swap (& n 32) r Free) - let r = (Data.U60.swap (& n 64) r Free) - let r = (Data.U60.swap (& n 128) r Free) - let r = (Data.U60.swap (& n 256) r Free) - let r = (Data.U60.swap (& n 512) r Free) - let r = (Data.U60.swap (& n 1024) r Free) - let r = (Data.U60.swap (& n 2048) r Free) - let r = (Data.U60.swap (& n 4096) r Free) - let r = (Data.U60.swap (& n 8192) r Free) - let r = (Data.U60.swap (& n 16384) r Free) - let r = (Data.U60.swap (& n 32768) r Free) - let r = (Data.U60.swap (& n 65536) r Free) - let r = (Data.U60.swap (& n 131072) r Free) - let r = (Data.U60.swap (& n 262144) r Free) - let r = (Data.U60.swap (& n 524288) r Free) - let r = (Data.U60.swap (& n 1048576) r Free) - let r = (Data.U60.swap (& n 2097152) r Free) - let r = (Data.U60.swap (& n 4194304) r Free) - let r = (Data.U60.swap (& n 8388608) r Free) + let r = (U60.swap (& n 1) r Free) + let r = (U60.swap (& n 2) r Free) + let r = (U60.swap (& n 4) r Free) + let r = (U60.swap (& n 8) r Free) + let r = (U60.swap (& n 16) r Free) + let r = (U60.swap (& n 32) r Free) + let r = (U60.swap (& n 64) r Free) + let r = (U60.swap (& n 128) r Free) + let r = (U60.swap (& n 256) r Free) + let r = (U60.swap (& n 512) r Free) + let r = (U60.swap (& n 1024) r Free) + let r = (U60.swap (& n 2048) r Free) + let r = (U60.swap (& n 4096) r Free) + let r = (U60.swap (& n 8192) r Free) + let r = (U60.swap (& n 16384) r Free) + let r = (U60.swap (& n 32768) r Free) + let r = (U60.swap (& n 65536) r Free) + let r = (U60.swap (& n 131072) r Free) + let r = (U60.swap (& n 262144) r Free) + let r = (U60.swap (& n 524288) r Free) + let r = (U60.swap (& n 1048576) r Free) + let r = (U60.swap (& n 2097152) r Free) + let r = (U60.swap (& n 4194304) r Free) + let r = (U60.swap (& n 8388608) r Free) r // Reverse : Arr -> Arr diff --git a/src/language/syntax.rs b/src/language/syntax.rs index f8b8741a..fcfe1101 100644 --- a/src/language/syntax.rs +++ b/src/language/syntax.rs @@ -88,7 +88,7 @@ impl std::fmt::Display for Term { fn lst_sugar(term: &Term) -> Option { fn go(term: &Term, text: &mut String, fst: bool) -> Option<()> { if let Term::Ctr { name, args } = term { - if name == "Data.List.cons" && args.len() == 2 { + if name == "List.cons" && args.len() == 2 { if !fst { text.push_str(", "); } @@ -96,7 +96,7 @@ impl std::fmt::Display for Term { go(&args[1], text, false)?; return Some(()); } - if name == "Data.List.nil" && args.is_empty() { + if name == "List.nil" && args.is_empty() { return Some(()); } } @@ -112,14 +112,14 @@ impl std::fmt::Display for Term { fn str_sugar(term: &Term) -> Option { fn go(term: &Term, text: &mut String) -> Option<()> { if let Term::Ctr { name, args } = term { - if name == "Data.String.cons" && args.len() == 2 { + if name == "String.cons" && args.len() == 2 { if let Term::U6O { numb } = *args[0] { text.push(std::char::from_u32(numb as u32)?); go(&args[1], text)?; return Some(()); } } - if name == "Data.String.nil" && args.is_empty() { + if name == "String.nil" && args.is_empty() { return Some(()); } } @@ -483,9 +483,9 @@ pub fn parse_str_sugar(state: HOPA::State) -> HOPA::Answer>> { } } } - let empty = Term::Ctr { name: "Data.String.nil".to_string(), args: Vec::new() }; + let empty = Term::Ctr { name: "String.nil".to_string(), args: Vec::new() }; let list = Box::new(chars.iter().rfold(empty, |t, h| Term::Ctr { - name: "Data.String.cons".to_string(), + name: "String.cons".to_string(), args: vec![Box::new(Term::U6O { numb: *h as u64 }), Box::new(t)], })); Ok((state, list)) @@ -513,9 +513,9 @@ pub fn parse_lst_sugar(state: HOPA::State) -> HOPA::Answer>> { }), state, )?; - let empty = Term::Ctr { name: "Data.List.nil".to_string(), args: Vec::new() }; + let empty = Term::Ctr { name: "List.nil".to_string(), args: Vec::new() }; let list = Box::new(elems.iter().rfold(empty, |t, h| Term::Ctr { - name: "Data.List.cons".to_string(), + name: "List.cons".to_string(), args: vec![h.clone(), Box::new(t)], })); Ok((state, list)) @@ -537,7 +537,7 @@ pub fn parse_if_sugar(state: HOPA::State) -> HOPA::Answer>> { let (state, _) = HOPA::force_there_take_exact("{", state)?; let (state, if_f) = parse_term(state)?; let (state, _) = HOPA::force_there_take_exact("}", state)?; - Ok((state, Box::new(Term::Ctr { name: "Data.U60.if".to_string(), args: vec![cond, if_t, if_f] }))) + Ok((state, Box::new(Term::Ctr { name: "U60.if".to_string(), args: vec![cond, if_t, if_f] }))) }), state, ); diff --git a/src/runtime/base/debug.rs b/src/runtime/base/debug.rs index 3fac1ab6..1d5d8187 100644 --- a/src/runtime/base/debug.rs +++ b/src/runtime/base/debug.rs @@ -24,7 +24,7 @@ pub fn show_ptr(x: Ptr) -> String { CTR => "Ctr", FUN => "Fun", OP2 => "Op2", - U60 => "Data.U60", + U60 => "U60", F60 => "F60", _ => "?", }; diff --git a/src/runtime/base/precomp.rs b/src/runtime/base/precomp.rs index 3b66ae14..862045ba 100644 --- a/src/runtime/base/precomp.rs +++ b/src/runtime/base/precomp.rs @@ -51,13 +51,13 @@ pub const HVM_LOAD : u64 = 29; pub const PRECOMP : &[Precomp] = &[ Precomp { id: STRING_NIL, - name: "Data.String.nil", + name: "String.nil", smap: &[false; 0], funs: None, }, Precomp { id: STRING_CONS, - name: "Data.String.cons", + name: "String.cons", smap: &[false; 2], funs: None, }, @@ -69,121 +69,121 @@ pub const PRECOMP : &[Precomp] = &[ }, Precomp { id: KIND_TERM_CT0, - name: "Apps.Kind.Term.ct0", + name: "Kind.Term.ct0", smap: &[false; 2], funs: None, }, Precomp { id: KIND_TERM_CT1, - name: "Apps.Kind.Term.ct1", + name: "Kind.Term.ct1", smap: &[false; 3], funs: None, }, Precomp { id: KIND_TERM_CT2, - name: "Apps.Kind.Term.ct2", + name: "Kind.Term.ct2", smap: &[false; 4], funs: None, }, Precomp { id: KIND_TERM_CT3, - name: "Apps.Kind.Term.ct3", + name: "Kind.Term.ct3", smap: &[false; 5], funs: None, }, Precomp { id: KIND_TERM_CT4, - name: "Apps.Kind.Term.ct4", + name: "Kind.Term.ct4", smap: &[false; 6], funs: None, }, Precomp { id: KIND_TERM_CT5, - name: "Apps.Kind.Term.ct5", + name: "Kind.Term.ct5", smap: &[false; 7], funs: None, }, Precomp { id: KIND_TERM_CT6, - name: "Apps.Kind.Term.ct6", + name: "Kind.Term.ct6", smap: &[false; 8], funs: None, }, Precomp { id: KIND_TERM_CT7, - name: "Apps.Kind.Term.ct7", + name: "Kind.Term.ct7", smap: &[false; 9], funs: None, }, Precomp { id: KIND_TERM_CT8, - name: "Apps.Kind.Term.ct8", + name: "Kind.Term.ct8", smap: &[false; 10], funs: None, }, Precomp { id: KIND_TERM_CT9, - name: "Apps.Kind.Term.ct9", + name: "Kind.Term.ct9", smap: &[false; 11], funs: None, }, Precomp { id: KIND_TERM_CTA, - name: "Apps.Kind.Term.ctA", + name: "Kind.Term.ctA", smap: &[false; 12], funs: None, }, Precomp { id: KIND_TERM_CTB, - name: "Apps.Kind.Term.ctB", + name: "Kind.Term.ctB", smap: &[false; 13], funs: None, }, Precomp { id: KIND_TERM_CTC, - name: "Apps.Kind.Term.ctC", + name: "Kind.Term.ctC", smap: &[false; 14], funs: None, }, Precomp { id: KIND_TERM_CTD, - name: "Apps.Kind.Term.ctD", + name: "Kind.Term.ctD", smap: &[false; 15], funs: None, }, Precomp { id: KIND_TERM_CTE, - name: "Apps.Kind.Term.ctE", + name: "Kind.Term.ctE", smap: &[false; 16], funs: None, }, Precomp { id: KIND_TERM_CTF, - name: "Apps.Kind.Term.ctF", + name: "Kind.Term.ctF", smap: &[false; 17], funs: None, }, Precomp { id: KIND_TERM_CTG, - name: "Apps.Kind.Term.ctG", + name: "Kind.Term.ctG", smap: &[false; 18], funs: None, }, Precomp { id: KIND_TERM_U60, - name: "Apps.Kind.Term.u60", + name: "Kind.Term.u60", smap: &[false; 2], funs: None, }, Precomp { id: KIND_TERM_F60, - name: "Apps.Kind.Term.f60", + name: "Kind.Term.f60", smap: &[false; 2], funs: None, }, Precomp { id: U60_IF, - name: "Data.U60.if", + name: "U60.if", smap: &[true, false, false], funs: Some(PrecompFuns { visit: u60_if_visit, @@ -192,7 +192,7 @@ pub const PRECOMP : &[Precomp] = &[ }, Precomp { id: U60_SWAP, - name: "Data.U60.swap", + name: "U60.swap", smap: &[true, false, false], funs: Some(PrecompFuns { visit: u60_swap_visit, @@ -201,7 +201,7 @@ pub const PRECOMP : &[Precomp] = &[ }, Precomp { id: HVM_LOG, - name: "Apps.HVM.log", + name: "HVM.log", smap: &[false; 2], funs: Some(PrecompFuns { visit: hvm_log_visit, @@ -210,7 +210,7 @@ pub const PRECOMP : &[Precomp] = &[ }, Precomp { id: HVM_QUERY, - name: "Apps.HVM.query", + name: "HVM.query", smap: &[false; 1], funs: Some(PrecompFuns { visit: hvm_query_visit, @@ -219,7 +219,7 @@ pub const PRECOMP : &[Precomp] = &[ }, Precomp { id: HVM_PRINT, - name: "Apps.HVM.print", + name: "HVM.print", smap: &[false; 2], funs: Some(PrecompFuns { visit: hvm_print_visit, @@ -228,7 +228,7 @@ pub const PRECOMP : &[Precomp] = &[ }, Precomp { id: HVM_SLEEP, - name: "Apps.HVM.sleep", + name: "HVM.sleep", smap: &[false; 2], funs: Some(PrecompFuns { visit: hvm_sleep_visit, @@ -237,7 +237,7 @@ pub const PRECOMP : &[Precomp] = &[ }, Precomp { id: HVM_STORE, - name: "Apps.HVM.store", + name: "HVM.store", smap: &[false; 3], funs: Some(PrecompFuns { visit: hvm_store_visit, @@ -246,7 +246,7 @@ pub const PRECOMP : &[Precomp] = &[ }, Precomp { id: HVM_LOAD, - name: "Apps.HVM.load", + name: "HVM.load", smap: &[false; 2], funs: Some(PrecompFuns { visit: hvm_load_visit,