Skip to content

Commit

Permalink
revert commits that changed names and broke hvm.log
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorTaelin committed Feb 7, 2024
1 parent 795a9c8 commit 926c62e
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 3 additions & 3 deletions examples/sort/bitonic/main.hvm
Original file line number Diff line number Diff line change
@@ -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
Expand Down
48 changes: 24 additions & 24 deletions examples/sort/radix/main.hvm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/language/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ impl std::fmt::Display for Term {
fn lst_sugar(term: &Term) -> Option<String> {
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(", ");
}
text.push_str(&format!("{}", args[0]));
go(&args[1], text, false)?;
return Some(());
}
if name == "Data.List.nil" && args.is_empty() {
if name == "List.nil" && args.is_empty() {
return Some(());
}
}
Expand All @@ -112,14 +112,14 @@ impl std::fmt::Display for Term {
fn str_sugar(term: &Term) -> Option<String> {
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(());
}
}
Expand Down Expand Up @@ -483,9 +483,9 @@ pub fn parse_str_sugar(state: HOPA::State) -> HOPA::Answer<Option<Box<Term>>> {
}
}
}
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))
Expand Down Expand Up @@ -513,9 +513,9 @@ pub fn parse_lst_sugar(state: HOPA::State) -> HOPA::Answer<Option<Box<Term>>> {
}),
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))
Expand All @@ -537,7 +537,7 @@ pub fn parse_if_sugar(state: HOPA::State) -> HOPA::Answer<Option<Box<Term>>> {
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,
);
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/base/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn show_ptr(x: Ptr) -> String {
CTR => "Ctr",
FUN => "Fun",
OP2 => "Op2",
U60 => "Data.U60",
U60 => "U60",
F60 => "F60",
_ => "?",
};
Expand Down
58 changes: 29 additions & 29 deletions src/runtime/base/precomp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 926c62e

Please sign in to comment.