mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-17 23:05:21 +00:00
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.
39 lines
637 B
Mathematica
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
|
|
).
|
|
|