1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 01:52:11 +03:00
juvix/tests/positive/MiniC/MultiModules/IO.mjuvix
Paul Cadman cfc11fecc5
Add minic-runtime for linking without libc (#113)
* [minic] Add minic-runtime for linking without libc

The C generated by minic now depends on `minic-runtime.h`. There are two
versions of this, one that depends on libc and one that doesn't (i.e standalone).

The standalone runtime implements the minimal set of functions required for
the tests to compile and run.

The standalone runtime also contains a copy of
https://github.com/wingo/walloc, a small memory allocator that's
indended for use with WASM.

The benefit of using the standalone runtime is that the resulting
binaries are much smaller. For example the Nat example compiles to about
24k WASM binary with libc, the standalone version is 2.8k.

This commit adds a dependency on
https://hackage.haskell.org/package/file-embed for finding the path to
the minic-runtime directory in tests. It does not add any additional
transitive dependencies to the project.
2022-05-19 09:48:23 +02:00

42 lines
505 B
Plaintext

module IO;
import String;
open String;
axiom Action : Type;
compile Action {
ghc ↦ "IO ()";
c ↦ "int";
};
foreign c {
int sequence(int a, int b) {
return a + b;
\}
};
infixl 1 >>;
axiom >> : Action → Action → Action;
compile >> {
ghc ↦ "(>>)";
c ↦ "sequence";
};
axiom put-str : String → Action;
compile put-str {
ghc ↦ "putStr";
c ↦ "putStr";
};
axiom put-str-ln : String → Action;
compile put-str-ln {
ghc ↦ "putStrLn";
c ↦ "putStrLn";
};
end;