[m-users.] Import only notations from a module?
Anders Lundstedt <[email protected]> Sat, 13 Jul 2024 13:53:14 +0200
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <CANGMbaae8dk0zULesW-bENrpRYvEnytW=R1Urx9A4-piY+ynJw@mail.gmail.com> |
Dear all,
I like using ‘use_module’ instead of ‘import_module’ since this forces
me to properly qualify names. However, some notations would be nice to
have—in particular, list notations.
I would be fine with having to redefine notations, as for example in
the following non-compiling attempt (which does compile if one imports
the list module and removes my attempt at redefining the notations).
Code:
:- module list_notations.
:- interface.
:- use_module list.
:- func '[]' = list.list(T).
:- func '[|]'(T, list.list(T)) = list.list(T).
:- func replace_everything(T, list.list(T)) = list.list(T).
:- implementation.
[] = list.'[]'.
[HD | TL] = list.'[|]'(HD, TL).
replace_everything(A, L) = RES :- (
if L = [_ | TL] then
RES = [A | replace_everything(A, TL)]
else
RES = []
).
Compilation error message:
list_notations.m:018: In clause for `replace_everything(in, in) = out':
list_notations.m:018: in argument 1 of call to function
list_notations.m:018: `list_notations.[|]'/2:
list_notations.m:018: mode error: variable `V_7' has instantiatedness `free',
list_notations.m:018: expected instantiatedness was `ground'.
Best,
Anders Lundstedt
_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users