mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-25 22:34:26 +00:00
Estimated hours taken: 18 Branches: main Move the univ, maybe, pair and unit types from std_util into their own modules. std_util still contains the general purpose higher-order programming constructs. library/std_util.m: Move univ, maybe, pair and unit (plus any other related types and procedures) into their own modules. library/maybe.m: New module. This contains the maybe and maybe_error types and the associated procedures. library/pair.m: New module. This contains the pair type and associated procedures. library/unit.m: New module. This contains the types unit/0 and unit/1. library/univ.m: New module. This contains the univ type and associated procedures. library/library.m: Add the new modules. library/private_builtin.m: Update the declaration of the type_ctor_info struct for univ. runtime/mercury.h: Update the declaration for the type_ctor_info struct for univ. runtime/mercury_mcpp.h: runtime/mercury_hlc_types.h: Update the definition of MR_Univ. runtime/mercury_init.h: Fix a comment: ML_type_name is now exported from type_desc.m. compiler/mlds_to_il.m: Update the the name of the module that defines univs (which are handled specially by the il code generator.) library/*.m: compiler/*.m: browser/*.m: mdbcomp/*.m: profiler/*.m: deep_profiler/*.m: Conform to the above changes. Import the new modules where they are needed; don't import std_util where it isn't needed. Fix formatting in lots of modules. Delete duplicate module imports. tests/*: Update the test suite to confrom to the above changes.
77 lines
1.0 KiB
Mathematica
77 lines
1.0 KiB
Mathematica
:- module dependency2.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
:- pred main(io__state::di, io__state::uo) is cc_multi.
|
|
|
|
:- implementation.
|
|
:- import_module bool, int, list, require, pair.
|
|
:- pragma promise_pure(main/2).
|
|
main -->
|
|
{ impure turn_on_origin_debug },
|
|
{ test(L) },
|
|
io__write(L),
|
|
io__write_string(".\n").
|
|
|
|
:- pred test(list(int)::out) is cc_multi.
|
|
|
|
test(L) :-
|
|
p(U),
|
|
( U = 1 ->
|
|
A = 1
|
|
;
|
|
A = U
|
|
),
|
|
q(V),
|
|
(
|
|
V = no,
|
|
r(A, [3, 4], BX),
|
|
BX = B - _
|
|
;
|
|
V = yes,
|
|
B = 4
|
|
),
|
|
AB = {A, B},
|
|
(
|
|
A = 2,
|
|
C = 5,
|
|
D = []
|
|
;
|
|
C = 6,
|
|
AB = {Aprime, Bprime},
|
|
D = [Aprime, Bprime]
|
|
),
|
|
L = [A, B, C | D].
|
|
|
|
:- pred p(int::out) is det.
|
|
|
|
p(1).
|
|
|
|
:- pred q(bool::out) is det.
|
|
|
|
q(no).
|
|
|
|
:- pred r(int::in, list(T)::in, pair(T)::out) is det.
|
|
|
|
r(A, L, BX) :-
|
|
(
|
|
A = 1,
|
|
L = [E1, E2 | _]
|
|
->
|
|
BX = E1 - E2
|
|
;
|
|
error("r: bad input")
|
|
).
|
|
|
|
:- impure pred turn_on_origin_debug is det.
|
|
|
|
:- pragma foreign_proc("C",
|
|
turn_on_origin_debug,
|
|
[will_not_call_mercury],
|
|
"
|
|
extern int MR_DD_debug_origin;
|
|
|
|
MR_DD_debug_origin = 1;
|
|
").
|