mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
samples/Mmakefile:
Add the beer program to list of targets.
samples/*.m:
Convert (C->T;E) to (if C then T else E).
Delete trailing whitespace.
Use predmode syntax instead of separate pred and mode
declarations.
samples/interpreter.m:
Fix up one predicate that had some clauses that used
DCGs and others that used state variables.
Don't use the name 'IO' for something that isn't the I/O state.
samples/diff/*.m:
samples/c_interface/c_calls_mercury/mercury_main.m:
samples/c_interface/short_example.m:
Delete trailing whitespace.
28 lines
596 B
Mathematica
28 lines
596 B
Mathematica
% This is a simple example of using the C interface to call the C function
|
|
% (or macro) puts().
|
|
|
|
% This source file is hereby placed in the public domain. -fjh (the author).
|
|
|
|
:- module short_example.
|
|
:- interface.
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- pred puts(string::in, io::di, io::uo) is det.
|
|
|
|
:- pragma foreign_decl("C", "#include <stdio.h>").
|
|
|
|
:- pragma foreign_proc("C",
|
|
puts(S::in, Old_IO::di, New_IO::uo),
|
|
[promise_pure, will_not_call_mercury],
|
|
"
|
|
puts(S);
|
|
New_IO = Old_IO;
|
|
").
|
|
|
|
main(!IO) :-
|
|
puts("Hello, world\n", !IO).
|