jacobdweightman / allium

The Allium Programming Language
MIT License
2 stars 1 forks source link

Add infrastructure for builtin predicates #15

Closed jacobdweightman closed 2 years ago

jacobdweightman commented 2 years ago

Allium's builtin types (Int and String) are not very useful right now, because there are no predicates that take them as arguments. Because their representations are opaque (they are basically C++ int and std::string, respectively), we will need to provide builtin predicates to work with them. As a starting point, it would be nice to be able to concatenate strings:

pred concat(in String, in String, String)

the idea is that if a concatenated with b is c, then concat(a, b, c). Examples:

concat("a", "b", "ab") succeeds
concat("a", "b", let c) yields (c = "ab")

This issue is primarily about the infrastructure, so don't worry about the non-generality of the predicate. Eventually we will generalize this to also work in this mode:

concat(_, _, in)

Examples:

concat("a", "b", let c) yields (c = "ab")
concat("a", let b, "ab") yields (b = "b")
concat(let a, "b", "ab") yields (a = "a")
concat(let a, let b, "ab") yields (a = "", b = "ab"), (a = "a", b = "b"), (a = "ab", b = "")