Removed foreign macros

Converted the function integration to use template
metaprogramming instead of macros.
This commit is contained in:
2023-09-22 23:17:54 +01:00
parent 7396078304
commit ba0b155ebd
45 changed files with 854 additions and 1126 deletions

View File

@@ -1,31 +1,38 @@
import system::(io, directfs, async)
import std::proc::*
import std::(to_string, to_uint)
import std::(to_string, to_uint, inspect)
const folder_view := \path.\next. do{
cps println $ "Contents of " ++ path;
cps entries = async::block_on $ directfs::readdir path;
cps println $ "Contents of " ++ directfs::os_print path;
cps entries = async::block_on $ directfs::read_dir path;
cps list::enumerate entries
|> list::map (pass \id. pass \name.\is_dir. (
println $ to_string id ++ ": " ++ name ++ if is_dir then "/" else ""
))
|> list::map (pass \id. pass \name.\is_dir.
println $ to_string id ++ ": " ++ directfs::os_print name ++ if is_dir then "/" else ""
)
|> list::chain;
cps print "select an entry, or .. to move up: ";
cps choice = readln;
let output = if choice == "..\n"
then directfs::pop_path path
if (choice == "..\n") then do {
let parent_path = directfs::pop_path path
|> option::unwrap
|> tuple::pick 0 2
else (
to_uint choice
|> (list::get entries)
|> option::unwrap
|> (directfs::join_paths path)
);
next output
|> tuple::pick 0 2;
next parent_path
} else do {
cps subname, is_dir = to_uint choice
|> (list::get entries)
|> option::unwrap;
let subpath = directfs::join_paths path subname;
if is_dir then next subpath
else do {
cps file = async::block_on $ directfs::read_file subpath;
cps contents = async::block_on $ io::read_string file;
cps println contents;
next path
}
}
}
const main := loop_over (path = "/home/lbfalvy/Code/orchid/examples") {
const main := loop_over (path = directfs::cwd) {
cps path = folder_view path;
}