[mercury-users] inst of list in non-empty branch

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Mar 30 12:02:08 AEST 2007


On Thu, 29 Mar 2007 doug.auclair at logicaltypes.com wrote:

> This leads me to suspect that the mode for Kids is set to only 'in', even
> in this non-empty-list clause.  ... I have seen the mode system set the
> inst properly for other user-defined discriminated union types, particularly
> when implementing different modes for different clauses (as illustrated in
> the refman, sect 4.4) so it's puzzling why this particular example is being
> uncooperative.
>
> Is there a pragma or assertion where I can assign the inst to Kids? Is
> there some call-out-to-C hackery that would force the inst assignment?

We usually resort to something like:

     :- pred unsafe_cast_to_foo(type::in, type::out(foo)) is det.

     :- pragma foreign_proc("C",
         unsafe_cast_to_foo(A::in, B::out(foo)),
         [will_not_call_mercury, promise_pure, thread_safe],
     "
         B = A;
     ").

Julien.
--------------------------------------------------------------------------
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