[m-dev.] is this a solver bug?
Peter Schachte
schachte at cs.mu.OZ.AU
Thu Jul 7 10:49:52 AEST 2005
Hi all,
I'm enclosing a test file that gives a mode error when compiling, but
I don't think there's a mode error, or at least I don't think the
error is what is claimed. It involves impurity, existential types and
automatically-generated solver type cast functions. The code in
question is:
:- pragma promise_pure(delayed/2).
delayed(F, V0) = V :-
impure Ref = 'representation of any dvar/1'(V0),
impure new_reference(unbound([func1(F,Ref)]), DV0),
impure V = 'representation to any dvar/1'(DV0).
The error message I get is:
bug.m:047: In clause for `delayed(in, in) = out':
bug.m:047: in argument 1 of call to function `bug.representation to
any dvar/1/1':
bug.m:047: mode error: variable `DV0' has instantiatedness `free',
bug.m:047: expected instantiatedness was `ground'.
but new_reference/2 always grounds its second argument.
Any suggestions?
--
Peter Schachte The whole aim of practical politics is to keep the
schachte at cs.mu.OZ.AU populace alarmed ... by menacing it with an
www.cs.mu.oz.au/~schachte/ endless series of hobgoblins, all of them
Phone: +61 3 8344 1338 imaginary. -- H.L. Mencken
-------------- next part --------------
%----------------------------------------------------------------------------%
% Copyright (C) 2005 Peter Schachte
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING included in the distribution
%----------------------------------------------------------------------------%
%
% RCS : $Id: delay.m,v 1.8 2005/07/06 08:42:14 schachte Exp $
% Authors : schachte (Peter Schachte)
% Purpose : Allow goals to be delayed until enough arguments are bound
%
:- module bug.
:- interface.
:- solver type dvar(T).
:- some [T1] func delayed((func(T) = T1), dvar(T1)) = dvar(T).
% :- pred delay_goal(dvar(T), dvar(U), pred(T::in, U::out) is semidet).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- implementation.
:- import_module(reference).
:- import_module(list).
:- import_module(std_util).
:- solver type dvar(T) where
representation is dvarrep(T),
initialization is new_delayed_var.
:- type dvarrep(T) == reference(dvarbinding(T)).
:- type dvarbinding(T) --->
( bound(T)
; ref(dvarrep(T))
; unbound(list(suspension(T)))
).
:- type suspension(T) --->
some [T1] func1((func(T) = T1), dvarrep(T1)).
:- pragma promise_pure(delayed/2).
delayed(F, V0) = V :-
impure Ref = 'representation of any dvar/1'(V0),
impure new_reference(unbound([func1(F,Ref)]), DV0),
impure V = 'representation to any dvar/1'(DV0).
:- pragma promise_pure(new_delayed_var/1).
:- pred new_delayed_var(dvar(T)::oa) is det.
new_delayed_var(DV) :-
impure new_reference(unbound([]), DV0),
impure DV = 'representation to any dvar/1'(DV0).
More information about the developers
mailing list