[mercury-users] inst of list in non-empty branch
Ian MacLarty
maclarty at csse.unimelb.edu.au
Fri Mar 30 12:36:17 AEST 2007
On Thu, Mar 29, 2007 at 02:35:10PM -0400, doug.auclair at logicaltypes.com wrote:
> Dear Ralph (and all), you and I wrote:
>
> >> print_kids(Element, Kids@[_|_], !IO) :-
> >> format("The child element%s of ", [s(singular_plural(Kids))], !IO),
> >> print(Element, !IO),
> >> is_are(Kids, !IO),
> >> print(Kids, !IO),
> >> nl(!IO).
>
> >The mode for format/4 is pred(in, in, di, uo), so while the compiler
> >knows that Kids has an inst matching non_empty_list before the call to
> >format, it only knows it has inst ground afterwards.
>
> Okay. I think, however, that the mode for Kids is being set to just 'in'
> anyway, because when I reduce the clause to:
>
> print_kids(_, Kids@[_|_], !_IO) :-
> TheS = singular_plural(Kids).
>
I think that:
print_kids(_, Kids, !IO) :-
Kids = [_ | _],
TheS = singular_plural(Kids).
will do the trick.
Ian.
--------------------------------------------------------------------------
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