Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pair / Tuple built-in type? #393

Closed
AzizZayed opened this issue Jul 14, 2024 · 2 comments
Closed

Pair / Tuple built-in type? #393

AzizZayed opened this issue Jul 14, 2024 · 2 comments

Comments

@AzizZayed
Copy link

I see that there are built-in types like Vec, Map and Set. Is there a pair or tuple built-in type? The usage would be like

(sort ITuple (Tuple i64 i64))
(sort SITuple (Tuple String i64))
@yihozhang
Copy link
Collaborator

Not currently! For now you have to write your own tuple datatype:

(datatype PairI64I64 (Pii i64 i64))
(function fst (Pairi64I64) i64)
(rule ((Pii a b)) ((set (fst (Pii a b)) a)))
...

Note that implementing pairs as built-in container types also has its limitations. For example, you cannot have (Pii a b) as part of the query if it's implemented as a built-in container.

@saulshanabrook
Copy link
Member

Note that with user defined generics a pair type could be written more easily and re-used without having to redefine the rewrites for every type of pair: #386

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants