I have a module exporting nat/1
to test/generate natural numbers:
:- module nat.
:- interface.
:- import_module int.
:- pred nat(int).
:- mode nat(in) is det.
:- mode nat(out) is multi.
:- implementation.
:- pragma promise_pure(nat/1).
nat(_::in).
nat(0::out).
nat(X::out) :- nat(Y), X = Y + 1.
and a main module in the same directory to try it out:
:- module main.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is cc_multi.
:- implementation.
:- import_module nat.
main(!IO) :- nat(X), print(X, !IO).
I run mmc --make-int nat.m
which successfully generates the interface files, but then when I run mmc main.m
I get the following error:
/usr/bin/ld: main.o: in function `<predicate 'main'/2 mode 0>':
main.c:(.text+0x45): undefined reference to `<predicate 'nat.nat'/1 mode 1>'
collect2: error: ld returned 1 exit status
I'm using MMC version 20.06.1, on x86_64-pc-linux-gnu
.
Am I missing something obvious? Code improvements are also very welcome.