[mercury-users] number of args for bag.init exported to C
Guillaume Yziquel
guillaume.yziquel at gmx.ch
Thu Jun 9 06:23:57 AEST 2011
Le Wednesday 08 Jun 2011 à 11:43:50 (+1000), Paul Bone a écrit :
> On Tue, Jun 07, 2011 at 04:38:49PM +0200, Guillaume Yziquel wrote:
>
> :- pred bag_of_ints_init(bag(int)::out) is det.
> :- pragma foreign_export("C", bag_of_ints_init(out), "no_props").
>
> bag_of_ints_init(Bag) :-
> bag.init(Bag).
>
> Hope this helps.
Yes, it does. I'm now having two problems with the following code:
:- type prop --->
term_definition(term, term) ;
term_typed(term, typ) .
:- pred typecheck(term::in, typ::out, bag(prop)::in) is semidet.
:- pragma foreign_export("C", typecheck(in, out, in), "typecheck").
typecheck(Term, Type, Props) :-
promise_equivalent_solutions [Prop, RemainingProps]
bag.member(Prop, Props, RemainingProps),
promise_equivalent_solutions [Type]
( Prop = term_typed(Term, Type)
; typecheck(Term, Type, RemainingProps)
).
Essentially, this looks up into the bag of props for a proposition that
refers to an explicit type annotation in my custom language.
So, first of all, I'd like to know if there is a more idiomatic way to
find an element in a bag on which to do unification. And if a bag is the
right data structure for that goal.
Secondly, I'm using promise_equivalent_solutions to be able to force the
determinism category of typecheck to semidet in order to export it to C.
I'm under the impression that I'm using this in a suboptimal manner (if
it's not outright wrong).
So what's a clean and idiomatic way to do something like the piece of
code above.
--
Guillaume Yziquel
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list