use lambda::Language;
pub fn dsl() -> Language {
Language::uniform(vec![
("0", tp!(int)),
("+1", arrow![tp!(int), tp!(int)]),
("-1", arrow![tp!(int), tp!(int)]),
("len", arrow![tp!(str), tp!(int)]),
("empty_str", tp!(str)),
("lower", arrow![tp!(str), tp!(str)]),
("upper", arrow![tp!(str), tp!(str)]),
("concat", arrow![tp!(str), tp!(str), tp!(str)]),
("slice", arrow![tp!(int), tp!(int), tp!(str), tp!(str)]),
("nth", arrow![tp!(int), tp!(list(tp!(str))), tp!(str)]),
(
"map",
arrow![arrow![tp!(0), tp!(1)], tp!(list(tp!(0))), tp!(list(tp!(1)))],
),
("strip", arrow![tp!(str), tp!(str)]),
("split", arrow![tp!(char), tp!(str), tp!(list(tp!(str)))]),
("join", arrow![tp!(str), tp!(list(tp!(str))), tp!(str)]),
("char->str", arrow![tp!(char), tp!(str)]),
("space", tp!(char)),
(".", tp!(char)),
(",", tp!(char)),
("<", tp!(char)),
(">", tp!(char)),
("/", tp!(char)),
("@", tp!(char)),
("-", tp!(char)),
("|", tp!(char)),
])
}
pub fn lisp_prims() -> Vec<(&'static str, &'static str)> {
vec![
("+1", "(λ (x) (+ x 1))"),
("-1", "(λ (x) (- x 1))"),
("len", "string-length"),
("empty_str", "\"\""),
("lower", "string-downcase"),
("upper", "string-upcase"),
("concat", "string-append"),
("slice", "(λ (x y s) (substring s x y))"),
("nth", "(λ (n s) (list-ref s n))"),
("strip", "string-trim"),
("split", "(λ (c s) (string-split s c))"),
("join", "(λ (s ss) (string-join ss s))"),
("char->str", "identity"),
("space", "\" \""),
(".", "\".\""),
(",", "\",\""),
("<", "\"<\""),
(">", "\">\""),
("/", "\"/\""),
("@", "\"@\""),
("-", "\"-\""),
("|", "\"|\""),
]
}