[m-dev.] help with polymorphic modes

Peter Wang novalazy at gmail.com
Wed Sep 3 17:23:32 AEST 2014


On Wed, 3 Sep 2014 03:22:37 +1000, Mark Brown <mark at mercurylang.org> wrote:
> Hi Peter,
> 
> On Tue, Sep 2, 2014 at 3:30 PM, Peter Wang <novalazy at gmail.com> wrote:
> > On Tue, 2 Sep 2014 15:19:44 +1000, Peter Wang <novalazy at gmail.com> wrote:
> >> Hi,
> >>
> >> Just to make sure, this is mode incorrect, yes?
> >>
> >>     :- pred p(pred(T), T).
> >>     :- mode p(pred(in(I =< ground)) is det, in) is det.
> >>
> >>     p(P, X) :- P(X).
> >
> > That doesn't make sense.  Then what about this?
> 
> It doesn't make sense without outputs, but aside from that you are
> right that it is mode incorrect. The constraint arising from `P(X)' is
> that ground matches the inst variable I, which we can't prove because
> all we know about I is that I =< ground.
> 
> Note that, since I comes from the head of the clause, it is already
> bound, so we can't solve the constraint by binding I to ground.

Thanks Mark, that's a big help.

Peter



More information about the developers mailing list