[mercury-users] Manipulating Types and Tuples
Goncalo Jorge Coelho e Silva
l10454 at alunos.uevora.pt
Wed May 7 10:22:52 AEST 2003
Hi,
following Ralph's suggestion back in the
"Re: [mercury-users] Prolog DCGs Pattern
Matching in Mercury" issue, I decided
to try and construct tuples that could
be analised as list terms.
As what happens with "set_value(Address, Value)"
in Ralph's code:
code_gen([Instruction | Program], Heap0, Heap) :-
run_instr(Instruction, Heap0, Heap1),
code_gen(Program, Heap1, Heap).
run_instr(set_value(Address, Value), Heap0, Heap) :-
set_heap(Heap0, Address, Value, Heap).
So, I did this test program:
:- module inter.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module construct.
%:- myType ---> int ; string.
main(IO0,IO) :-
%construct(myType,1,[29|"string"]) = MyTerm,
%List = [1|2|[]],
%construct_tuple(List) = Univ,
print("Tuple/Functor test", IO0, IO1),
nl(IO1, IO).
... that, didn't work. :\
Since all the *strange* instructions dealing with
tuples and types are commented, I shouldn't
have a reason to get this, should I?:
mmc -E inter
mercury_compile: can't open file `construct.int'.
make: *** [run] Error 1
Does this means that the compiler installations
misses something? Bad install?
...and, when I uncomment the line of the
myType declaration, since I don't believe
I have to import module 'type_desc' or
anything to handle type declarations, I also
shouldn't be getting this, would I?
inter.m:010: Error: unrecognized declaration: myType ---> int ; string.
Can you guys tell me what am I
doing wrong here?
...still, about the tuple construction, regarding these
2 functions, on the constructor module:
:- func construct(type_desc__type_desc, int, list(univ)) = univ.
:- mode construct(in, in, in) = out is semidet.
% construct_tuple(Args) = Term
%
% Returns a tuple whose arguments are given by Args.
:- func construct_tuple(list(univ)) = univ.
What's the middle argument in the 1st one? The functor arity?
The 'construc.m' description was not explicit to me.
Thank you so much.
Cheers,
Goncalo
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list