Skip to content

Instantly share code, notes, and snippets.

@lagenorhynque
Last active June 16, 2026 04:53
Show Gist options
  • Select an option

  • Save lagenorhynque/0eec1d12bfeb92f1d8faeb334287a4df to your computer and use it in GitHub Desktop.

Select an option

Save lagenorhynque/0eec1d12bfeb92f1d8faeb334287a4df to your computer and use it in GitHub Desktop.
🐬's first Flix example code
use Sys.Process
// The main entry point.
def main(): Unit \ {Process, Abort, IO} =
println("Hello World!");
let n = 5;
println("The square of ${n} is ${square(n)}.");
runProcess()
|> Result.getOrAbort
|> x -> println("Process output:\n${x}")
def square(x: Int32): Int32 =
x * x
def runProcess(): Result[IoError, String] \ {Process, IO} =
region rc {
forM (
ph <- Process.exec("ls", Nil);
out <- Process.stdout(ph);
buf = Array.repeat(rc, 1024, 0i8);
_ <- Readable.read(buf, out)
) yield buf |> Array.toVector |> String.fromBytes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment