Rename AList -> Pairs due to popular demand.

This commit is contained in:
KtorZ 2024-05-23 16:45:40 +02:00
parent 8e0f32a577
commit 5ce30b2632
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
6 changed files with 24 additions and 23 deletions

View File

@ -8,6 +8,7 @@
- **aiken-lsp**: hover and goto definition support on list tail. @rvcas - **aiken-lsp**: hover and goto definition support on list tail. @rvcas
- **aiken-lsp**: hover on prop test via expression. @rvcas - **aiken-lsp**: hover on prop test via expression. @rvcas
- **aiken-lang**: a new way to emit logs that don't get erased. @micahkendall - **aiken-lang**: a new way to emit logs that don't get erased. @micahkendall
- **aiken-lang**: new builtin types in the prelude `Pair` and `Pairs`. @KtorZ @Microproofs
### Fixed ### Fixed

View File

@ -23,8 +23,8 @@ pub const BOOL: &str = "Bool";
pub const INT: &str = "Int"; pub const INT: &str = "Int";
pub const DATA: &str = "Data"; pub const DATA: &str = "Data";
pub const LIST: &str = "List"; pub const LIST: &str = "List";
pub const ALIST: &str = "AList";
pub const PAIR: &str = "Pair"; pub const PAIR: &str = "Pair";
pub const PAIRS: &str = "Pairs";
pub const VOID: &str = "Void"; pub const VOID: &str = "Void";
pub const G1_ELEMENT: &str = "G1Element"; pub const G1_ELEMENT: &str = "G1Element";
pub const G2_ELEMENT: &str = "G2Element"; pub const G2_ELEMENT: &str = "G2Element";
@ -523,7 +523,7 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo {
let alist_key = generic_var(id_gen.next()); let alist_key = generic_var(id_gen.next());
let alist_value = generic_var(id_gen.next()); let alist_value = generic_var(id_gen.next());
prelude.types.insert( prelude.types.insert(
ALIST.to_string(), PAIRS.to_string(),
TypeConstructor { TypeConstructor {
location: Span::empty(), location: Span::empty(),
parameters: vec![alist_key.clone(), alist_value.clone()], parameters: vec![alist_key.clone(), alist_value.clone()],
@ -1447,7 +1447,7 @@ pub fn map(k: Rc<Type>, v: Rc<Type>) -> Rc<Type> {
args: vec![pair(k, v)], args: vec![pair(k, v)],
alias: Some( alias: Some(
TypeAliasAnnotation { TypeAliasAnnotation {
alias: ALIST.to_string(), alias: PAIRS.to_string(),
parameters: vec!["k".to_string(), "v".to_string()], parameters: vec!["k".to_string(), "v".to_string()],
annotation: Annotation::Constructor { annotation: Annotation::Constructor {
location: Span::empty(), location: Span::empty(),

View File

@ -885,9 +885,9 @@ fn acceptance_test_7_unzip_tuple() {
#[test] #[test]
fn acceptance_test_7_unzip_pair() { fn acceptance_test_7_unzip_pair() {
let src = r#" let src = r#"
type AList<a,b> = List<Pair<a,b>> type Pairs<a,b> = List<Pair<a,b>>
pub fn unzip(xs: AList<a, b>) -> Pair<List<a>, List<b>> { pub fn unzip(xs: Pairs<a, b>) -> Pair<List<a>, List<b>> {
when xs is { when xs is {
[] -> Pair([], []) [] -> Pair([], [])
[Pair(a, b), ..rest] -> { [Pair(a, b), ..rest] -> {
@ -1573,16 +1573,16 @@ fn acceptance_test_14_list_creation() {
#[test] #[test]
fn acceptance_test_15_zero_arg() { fn acceptance_test_15_zero_arg() {
let src = r#" let src = r#"
pub opaque type AList<key, value> { pub opaque type Pairs<key, value> {
inner: List<Pair<key, value>>, inner: List<Pair<key, value>>,
} }
pub fn new() { pub fn new() {
AList { inner: [] } Pairs { inner: [] }
} }
test new_1() { test new_1() {
new() == AList { inner: [] } new() == Pairs { inner: [] }
} }
"#; "#;
@ -2116,18 +2116,18 @@ fn acceptance_test_22_filter_map() {
#[test] #[test]
fn acceptance_test_23_to_list() { fn acceptance_test_23_to_list() {
let src = r#" let src = r#"
pub type AList<key, value> = pub type Pairs<key, value> =
List<Pair<key, value>> List<Pair<key, value>>
pub opaque type AssocList<key, value> { pub opaque type AssocList<key, value> {
inner: AList<key, value>, inner: Pairs<key, value>,
} }
pub fn new() -> AssocList<key, value> { pub fn new() -> AssocList<key, value> {
AssocList { inner: [] } AssocList { inner: [] }
} }
pub fn to_list(m: AssocList<key, value>) -> AList<key, value> { pub fn to_list(m: AssocList<key, value>) -> Pairs<key, value> {
m.inner m.inner
} }
@ -2139,7 +2139,7 @@ fn acceptance_test_23_to_list() {
AssocList { inner: do_insert(m.inner, k, v) } AssocList { inner: do_insert(m.inner, k, v) }
} }
fn do_insert(elems: AList<key, value>, k: key, v: value) -> AList<key, value> { fn do_insert(elems: Pairs<key, value>, k: key, v: value) -> Pairs<key, value> {
when elems is { when elems is {
[] -> [] ->
[Pair(k, v)] [Pair(k, v)]
@ -2997,18 +2997,18 @@ fn acceptance_test_28_unique_list() {
fn acceptance_test_29_union_pair() { fn acceptance_test_29_union_pair() {
let src = r#" let src = r#"
pub opaque type AssocList<key, value> { pub opaque type AssocList<key, value> {
inner: AList<key, value>, inner: Pairs<key, value>,
} }
pub fn new() -> AssocList<key, value> { pub fn new() -> AssocList<key, value> {
AssocList { inner: [] } AssocList { inner: [] }
} }
pub fn from_list(xs: AList<key, value>) -> AssocList<key, value> { pub fn from_list(xs: Pairs<key, value>) -> AssocList<key, value> {
AssocList { inner: do_from_list(xs) } AssocList { inner: do_from_list(xs) }
} }
fn do_from_list(xs: AList<key, value>) -> AList<key, value> { fn do_from_list(xs: Pairs<key, value>) -> Pairs<key, value> {
when xs is { when xs is {
[] -> [] ->
[] []
@ -3025,7 +3025,7 @@ fn acceptance_test_29_union_pair() {
AssocList { inner: do_insert(m.inner, k, v) } AssocList { inner: do_insert(m.inner, k, v) }
} }
fn do_insert(elems: AList<key, value>, k: key, v: value) -> AList<key, value> { fn do_insert(elems: Pairs<key, value>, k: key, v: value) -> Pairs<key, value> {
when elems is { when elems is {
[] -> [] ->
[Pair(k, v)] [Pair(k, v)]
@ -3046,9 +3046,9 @@ fn acceptance_test_29_union_pair() {
} }
fn do_union( fn do_union(
left: AList<key, value>, left: Pairs<key, value>,
right: AList<key, value>, right: Pairs<key, value>,
) -> AList<key, value> { ) -> Pairs<key, value> {
when left is { when left is {
[] -> [] ->
right right

View File

@ -18,7 +18,7 @@ validator(token_name: ByteArray, utxo_ref: OutputReference) {
mint mint
|> value.from_minted_value |> value.from_minted_value
|> value.tokens(policy_id) |> value.tokens(policy_id)
|> dict.to_list() |> dict.to_pairs()
when rdmr is { when rdmr is {
Mint -> { Mint -> {
expect expect

View File

@ -60,7 +60,7 @@ validator(creator: ByteArray) {
mint mint
|> value.from_minted_value |> value.from_minted_value
|> value.tokens(policy_id) |> value.tokens(policy_id)
|> dict.to_list() |> dict.to_pairs()
when rdmr is { when rdmr is {
Mint(total) -> { Mint(total) -> {

View File

@ -20,7 +20,7 @@ validator(token_name: ByteArray, utxo_ref: OutputReference) {
mint mint
|> value.from_minted_value |> value.from_minted_value
|> value.tokens(policy_id) |> value.tokens(policy_id)
|> dict.to_list() |> dict.to_pairs()
when rdmr is { when rdmr is {
Mint -> { Mint -> {
@ -43,7 +43,7 @@ validator(token_name: ByteArray, policy_id: ByteArray) {
mint mint
|> value.from_minted_value |> value.from_minted_value
|> value.tokens(policy_id) |> value.tokens(policy_id)
|> dict.to_list() |> dict.to_pairs()
amount == -1 && asset_name == token_name amount == -1 && asset_name == token_name
} }