Under Construction
Say hello with user input...
#include "share/HATS/temptory_staload_bucs320.hats"
#define :: stream_vt_cons
#define nil stream_vt_nil
extern fun{} readio : () -> void
extern fun{} readio$err : () -> string
extern fun{} readio$foreach : string -> void
impltmp{} readio() =
case+ !(FILEref_streamize_line(the_stdin<>())) of
| ~nil() => println!(readio$err<>())
| ~x::xs => (readio$foreach(x); free(xs))
implfun main0() = readio<>() where
{
impltmp readio$err<>() = "Oops! No input"
impltmp readio$foreach<>(x) = println!("Hello there ", x, "!")
}
How to Compile you might ask?
tempacc -DATS_MEMALLOC_LIBC -o hello hello.dats
Food for thought
Who owns memory management in ATS?
Let's break that down...
Includes
Here we include a hats file which exposes various modules that we can use.
#include "share/HATS/temptory_staload_bucs320.hats"
For ease
#define
functions similarly to the C keyword. Here it is used just to make the code look nicer :)
#define nil stream_vt_nil
Now for the interesting part...
What does all this mean!?!
extern fun{} readio : () -> void
extern fun{} readio$err : () -> string
extern fun{} readio$foreach : string -> void