Files
mercury/extras/posix/hello.m
Thomas Conway 415a83c73d Rename Mmake as Mmakefile to avoid problems on antiquated platforms.
Estimated hours taken: 0.25


extras/posix/{MMake,MMakefile}:
	Rename Mmake as Mmakefile to avoid problems on antiquated platforms.
	Use MLOBJS rather than MLLIBS.

extras/posix/*.m:
	Use __ rather than : as the module qualifier.
	Make the flag arrays static const, rather than just static.

extras/posix/text.m:
	Add some doccumentation to the interface of text.m.
1999-10-18 00:50:27 +00:00

39 lines
637 B
Mathematica

:- module hello.
:- interface.
:- import_module io.
:- pred main(io__state, io__state).
:- mode main(di, uo) is det.
:- implementation.
:- import_module posix, posix__open, posix__write, text.
:- import_module list, string.
main -->
open("/dev/tty", [wronly], Res0),
(
{ Res0 = ok(Fd) },
{ Str = "hello world.\n" },
{ length(Str, Len) },
write(Fd, Len, text(Str), Res1),
(
{ Res1 = ok(NWritten) },
( { NWritten \= Len } ->
% We didn't write all of it!
write("failed to write it all\n")
;
[]
)
;
{ Res1 = error(Err) },
write(Err), nl
)
;
{ Res0 = error(Err) },
write(Err), nl
).