Skip to content

refactor print #1466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alex-s168 opened this issue May 2, 2025 · 0 comments
Open

refactor print #1466

alex-s168 opened this issue May 2, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request stdlib

Comments

@alex-s168
Copy link
Collaborator

interface Sink<t> {
  fn .consume-many(s: self, v: Iterator<t>): self;
};

fn .consume(s: st+Sink<t>, v: t): st = (
  s.consume-many(single(v))
);

interface Write<t> {
  fn .write(s: self, o: Sink<t>): o;
};

type FileSink = FileSink { o: IO::File };
type FileSink implements Sink<U8>;

let .into(f: IO::File, out: Type<FileSink>) = (
  FileSink { f }
);

let .consume-many(s: FileSink, v: U8): FileSink = (
  # fwrite here
);

# SEPERATE FROM Into<String>!!!
interface ToString {
  let .to-tring(v: self): String;
};

let print(v: Write<U8>): Nil;
let print(v: ToString): Nil;
let println(v: Write<U8>): Nil;
let println(v: ToString): Nil;

let eprint(v: Write<U8>): Nil;
let eprint(v: ToString): Nil;
let eprintln(v: Write<U8>): Nil;
let eprintln(v: ToString): Nil;
@alex-s168 alex-s168 added enhancement New feature or request stdlib labels May 2, 2025
@alex-s168 alex-s168 self-assigned this May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stdlib
Projects
Status: No status
Development

No branches or pull requests

1 participant