Commit f42f902e authored by Michael Hanus 's avatar Michael Hanus
Browse files

PAKCS 1.14.0: type Success is now a type synonym for Bool

parent 40686528
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
# The major version numbers: # The major version numbers:
MAJORVERSION=1 MAJORVERSION=1
# The minor version number: # The minor version number:
MINORVERSION=13 MINORVERSION=14
# The revision version number: # The revision version number:
REVISIONVERSION=1 REVISIONVERSION=0
# The build version number: # The build version number:
BUILDVERSION=1 BUILDVERSION=1
# Complete version: # Complete version:
......
PAKCS: Release Notes PAKCS: Release Notes
==================== ====================
Release notes for PAKCS Version 1.13.1 (September 6, 2015) Release notes for PAKCS Version 1.14.0 (October 12, 2015)
---------------------------------------------------------- ---------------------------------------------------------
Changes to version 1.13.0:
* Type `Success` is now a type synonym for `Bool` and
`success` is defined as `True` in the prelude.
Release notes for PAKCS Version 1.13.1 (October 2, 2015)
--------------------------------------------------------
Changes to version 1.13.0: Changes to version 1.13.0:
......
...@@ -659,7 +659,7 @@ getConstructors([],Cs) :- ...@@ -659,7 +659,7 @@ getConstructors([],Cs) :-
(includePrelude (includePrelude
-> Cs=[partcall/3,'$stream'/1] % all standard constructors defined in prelude -> Cs=[partcall/3,'$stream'/1] % all standard constructors defined in prelude
; Cs=[partcall/3,'Prelude.True'/0,'Prelude.False'/0, ; Cs=[partcall/3,'Prelude.True'/0,'Prelude.False'/0,
'Prelude.success'/0,[]/0,'.'/2|TupleCons]). []/0,'.'/2|TupleCons]).
getConstructors(['Type'(_,_,_,DataCons)|Types],AllCons) :- getConstructors(['Type'(_,_,_,DataCons)|Types],AllCons) :-
getDataCons(DataCons,DCs), getDataCons(DataCons,DCs),
getConstructors(Types,TCs), getConstructors(Types,TCs),
...@@ -1446,7 +1446,7 @@ genDerefCalls(_,[],[],LastGoal,LastGoal). ...@@ -1446,7 +1446,7 @@ genDerefCalls(_,[],[],LastGoal,LastGoal).
% derefRoot for primitive types and derefAll for other types % derefRoot for primitive types and derefAll for other types
type2derefPred('TCons'(Name,_),derefRoot) :- type2derefPred('TCons'(Name,_),derefRoot) :-
member(Name,["Prelude.Int","Prelude.Float","Prelude.Char","Prelude.Bool", member(Name,["Prelude.Int","Prelude.Float","Prelude.Char","Prelude.Bool",
"Prelude.Success","Prelude.Ordering", "Prelude.Ordering",
"IO.Handle","IO.IOMode","IO.SeekMode", "IO.Handle","IO.IOMode","IO.SeekMode",
"PlProfileData.ProfileSelection","Ports.Port","Socket.Socket"]), !. "PlProfileData.ProfileSelection","Ports.Port","Socket.Socket"]), !.
type2derefPred('FuncType'(_,_),derefRoot) :- type2derefPred('FuncType'(_,_),derefRoot) :-
...@@ -1647,18 +1647,16 @@ genVariableShareHnfClause(HNF,Suffix) :- ...@@ -1647,18 +1647,16 @@ genVariableShareHnfClause(HNF,Suffix) :-
appendAtom(propagateShare,Suffix,PropShare), appendAtom(propagateShare,Suffix,PropShare),
PropShare_HV_R =.. [PropShare,HV,R], PropShare_HV_R =.. [PropShare,HV,R],
HnfLHS =.. [HNF,Share_M,R,E0,E], HnfLHS =.. [HNF,Share_M,R,E0,E],
ShareGoal = (PropShare_HV_R, update_mutable('$eval'(R),M)),
(printConsFailure(no) (printConsFailure(no)
-> NoSharingCheck = functor(HV,'Prelude.success',0) -> ShareHNF = ShareGoal
; NoSharingCheck = ; ShareHNF = % no sharing for FAIL:
(functor(HV,'Prelude.success',0);functor(HV,'FAIL',_))), ((nonvar(HV), functor(HV,'FAIL',_)) -> R=HV ; ShareGoal)),
writeClause((HnfLHS :- !, get_mutable(V,M), writeClause((HnfLHS :- !, get_mutable(V,M),
(V='$eval'(Expr) (V='$eval'(Expr)
-> R=Expr, E0=E -> R=Expr, E0=E
; hnf(V,HV,E0,E1), ; hnf(V,HV,E0,E1),
((nonvar(HV),NoSharingCheck) ShareHNF,
-> R=HV % no sharing for constraints
; PropShare_HV_R,
update_mutable('$eval'(R),M)),
E1=E))). E1=E))).
genFunctionShareHnfClause(HNF,Suffix) :- genFunctionShareHnfClause(HNF,Suffix) :-
...@@ -1673,11 +1671,6 @@ genFunctionShareHnfClause(HNF,Suffix) :- ...@@ -1673,11 +1671,6 @@ genFunctionShareHnfClause(HNF,Suffix) :-
E1=E))). E1=E))).
% generate hnf clause for a function: % generate hnf clause for a function:
genHnfClause(_,('Prelude.success'/0,_)) :- !. % success is treated as a constructor
genHnfClause(HNF,(FName/0,'Prelude.success')) :- !,
% if somebody defines FName as (External Prelude.success)
HnfLHS =.. [HNF,FName,'Prelude.success',E,E],
writeClause((HnfLHS :- !)).
genHnfClause(HNF,(FName/FArity,PredName)) :- genHnfClause(HNF,(FName/FArity,PredName)) :-
length(Args,FArity), length(Args,FArity),
LHS =.. [FName|Args], LHS =.. [FName|Args],
...@@ -1713,7 +1706,7 @@ transConstrEq(Suffix) :- ...@@ -1713,7 +1706,7 @@ transConstrEq(Suffix) :-
hnf(A,HA,E0,E1), hnf(B,HB,E1,E2), hnf(A,HA,E0,E1), hnf(B,HB,E1,E2),
ConstrEqHnf_HA_HB_R_E2_E, ConstrEqHnf_HA_HB_R_E2_E,
traceExit('Prelude.=:='(A,B), traceExit('Prelude.=:='(A,B),
'Prelude.success', 'Prelude.True',
E,Skip))) E,Skip)))
; writeClause((ConstrEq_A_B_R_E0_E :- hnf(A,HA,E0,E1),hnf(B,HB,E1,E2), ; writeClause((ConstrEq_A_B_R_E0_E :- hnf(A,HA,E0,E1),hnf(B,HB,E1,E2),
ConstrEqHnf_HA_HB_R_E2_E))), ConstrEqHnf_HA_HB_R_E2_E))),
...@@ -1725,7 +1718,7 @@ transConstrEq(Suffix) :- ...@@ -1725,7 +1718,7 @@ transConstrEq(Suffix) :-
BindTryNf_X_H_R_E0_E =.. [BindTryNf,X,H,R,E0,E], BindTryNf_X_H_R_E0_E =.. [BindTryNf,X,H,R,E0,E],
writeClause((ConstrEqHnf_X_H_R_E0_E :- var(X),!,BindTryNf_X_H_R_E0_E)), writeClause((ConstrEqHnf_X_H_R_E0_E :- var(X),!,BindTryNf_X_H_R_E0_E)),
writeClause((ConstrEqHnf_H_X_R_E0_E :- var(X),!,BindTryNf_X_H_R_E0_E)), writeClause((ConstrEqHnf_H_X_R_E0_E :- var(X),!,BindTryNf_X_H_R_E0_E)),
ConstrEqHnf_T1_T2_E0_E =.. [ConstrEqHnf,T1,T2,'Prelude.success',E0,E], ConstrEqHnf_T1_T2_E0_E =.. [ConstrEqHnf,T1,T2,'Prelude.True',E0,E],
ConstrEqHnf_A_B_R_E0_E =.. [ConstrEqHnf,A,B,R,E0,E], ConstrEqHnf_A_B_R_E0_E =.. [ConstrEqHnf,A,B,R,E0,E],
(printConsFailure(no) (printConsFailure(no)
-> writeClause((ConstrEqHnf_T1_T2_E0_E :- number(T1),!,T1=T2,E0=E)) -> writeClause((ConstrEqHnf_T1_T2_E0_E :- number(T1),!,T1=T2,E0=E))
...@@ -1736,7 +1729,7 @@ transConstrEq(Suffix) :- ...@@ -1736,7 +1729,7 @@ transConstrEq(Suffix) :-
'FAIL'(Src),E,E], 'FAIL'(Src),E,E],
writeClause((ConstrEqHnf_X_FAIL_E_E :- !)), writeClause((ConstrEqHnf_X_FAIL_E_E :- !)),
writeClause((ConstrEqHnf_A_B_R_E0_E :- number(A), !, writeClause((ConstrEqHnf_A_B_R_E0_E :- number(A), !,
(A=B -> R='Prelude.success', E0=E (A=B -> R='Prelude.True', E0=E
; prim_failure(partcall(2,'Prelude.=:=',[]),[A,B],R,E0,E))))), ; prim_failure(partcall(2,'Prelude.=:=',[]),[A,B],R,E0,E))))),
appendAtom(genConstrEqHnfBody,Suffix,GenConstrEqHnfBody), appendAtom(genConstrEqHnfBody,Suffix,GenConstrEqHnfBody),
GenConstrEqHnfBody_1_NA =.. [GenConstrEqHnfBody,1,NA,A,B,EqBody], GenConstrEqHnfBody_1_NA =.. [GenConstrEqHnfBody,1,NA,A,B,EqBody],
...@@ -1750,7 +1743,7 @@ transConstrEq(Suffix) :- ...@@ -1750,7 +1743,7 @@ transConstrEq(Suffix) :-
prim_failure(partcall(2,'Prelude.=:=',[]),[A,B],R,E0,E)))), prim_failure(partcall(2,'Prelude.=:=',[]),[A,B],R,E0,E)))),
nl, nl,
GenConstrEqHnfBody_N_NA_Succ =.. GenConstrEqHnfBody_N_NA_Succ =..
[GenConstrEqHnfBody,N,NA,_,_,'Prelude.success'], [GenConstrEqHnfBody,N,NA,_,_,'Prelude.True'],
writeClause((GenConstrEqHnfBody_N_NA_Succ :- N>NA,!)), writeClause((GenConstrEqHnfBody_N_NA_Succ :- N>NA,!)),
appendAtom('Prelude.=:=',Suffix,Eq), appendAtom('Prelude.=:=',Suffix,Eq),
Eq_ArgA_ArgB =.. [Eq,ArgA,ArgB], Eq_ArgA_ArgB =.. [Eq,ArgA,ArgB],
...@@ -1780,19 +1773,19 @@ transConstrEq(Suffix) :- ...@@ -1780,19 +1773,19 @@ transConstrEq(Suffix) :-
appendAtom(occursNot,Suffix,OccursNot), appendAtom(occursNot,Suffix,OccursNot),
OccursNot_X_T =.. [OccursNot,X,T], OccursNot_X_T =.. [OccursNot,X,T],
writeClause((BindDirect_X_T_R_E0_E :- var(T), !, X=T, writeClause((BindDirect_X_T_R_E0_E :- var(T), !, X=T,
R='Prelude.success', E0=E)), R='Prelude.True', E0=E)),
(printConsFailure(no) (printConsFailure(no)
-> writeClause((BindDirect_X_T_R_E0_E :- -> writeClause((BindDirect_X_T_R_E0_E :-
OccursNot_X_T, X=T, R='Prelude.success', E0=E)) OccursNot_X_T, X=T, R='Prelude.True', E0=E))
; BindDirect_X_FAIL_E_E =.. ; BindDirect_X_FAIL_E_E =..
[BindDirect,X,'FAIL'(Src),'FAIL'(Src),E,E], [BindDirect,X,'FAIL'(Src),'FAIL'(Src),E,E],
writeClause((BindDirect_X_FAIL_E_E :- !)), writeClause((BindDirect_X_FAIL_E_E :- !)),
writeClause((BindDirect_X_T_R_E0_E :- writeClause((BindDirect_X_T_R_E0_E :-
OccursNot_X_T, !, X=T, R='Prelude.success', E0=E)), OccursNot_X_T, !, X=T, R='Prelude.True', E0=E)),
writeClause((BindDirect_X_T_R_E0_E :- writeClause((BindDirect_X_T_R_E0_E :-
prim_failure(partcall(2,'Prelude.=:=',[]),[X,T],R,E0,E)))), prim_failure(partcall(2,'Prelude.=:=',[]),[X,T],R,E0,E)))),
nl, nl,
Bind_X_T_E0_E =.. [Bind,X,T,'Prelude.success',E0,E], Bind_X_T_E0_E =.. [Bind,X,T,'Prelude.True',E0,E],
writeClause((Bind_X_T_E0_E :- var(T), !, X=T, E0=E)), writeClause((Bind_X_T_E0_E :- var(T), !, X=T, E0=E)),
writeClause((Bind_X_T_E0_E :- number(T), !, X=T, E0=E)), writeClause((Bind_X_T_E0_E :- number(T), !, X=T, E0=E)),
(printConsFailure(no) -> true (printConsFailure(no) -> true
...@@ -1821,7 +1814,7 @@ transConstrEq(Suffix) :- ...@@ -1821,7 +1814,7 @@ transConstrEq(Suffix) :-
OccursNot_A_ArgB, OccursNot_A_ArgB,
N1 is N+1, OccursNotArgs_N1_NA_A_B)), N1 is N+1, OccursNotArgs_N1_NA_A_B)),
nl, nl,
BindArgs_N_NA_A_B_E0_E =.. [BindArgs,N,NA,A,B,'Prelude.success',E0,E], BindArgs_N_NA_A_B_E0_E =.. [BindArgs,N,NA,A,B,'Prelude.True',E0,E],
BindArgs_N_NA_A_B_R_E0_E =.. [BindArgs,N,NA,A,B,R,E0,E], BindArgs_N_NA_A_B_R_E0_E =.. [BindArgs,N,NA,A,B,R,E0,E],
Bind_ArgA_HArgB_R_E1_E2 =.. [Bind,ArgA,HArgB,R,E1,E2], Bind_ArgA_HArgB_R_E1_E2 =.. [Bind,ArgA,HArgB,R,E1,E2],
Bind_ArgA_HArgB_R0_E1_E2 =.. [Bind,ArgA,HArgB,R0,E1,E2], Bind_ArgA_HArgB_R0_E1_E2 =.. [Bind,ArgA,HArgB,R0,E1,E2],
...@@ -2203,8 +2196,6 @@ transExp(FName,_Aux,Patterns,Vars,Cut,Exp) :- ...@@ -2203,8 +2196,6 @@ transExp(FName,_Aux,Patterns,Vars,Cut,Exp) :-
TPCall =.. [TP|TArgsH], TPCall =.. [TP|TArgsH],
writeClauseWithInitGoals(LHS,CutUShares,TPCall) )). writeClauseWithInitGoals(LHS,CutUShares,TPCall) )).
localFunCall(_,'Comb'('FuncCall',"Prelude.success",_)) :-
!. % since we implement "success" as a constructor, thus we don't need hnf for it
localFunCall(DefFuncName,'Comb'('FuncCall',FName,_)) :- localFunCall(DefFuncName,'Comb'('FuncCall',FName,_)) :-
atom_codes(DefFuncName,DefFuncNameS), atom_codes(DefFuncName,DefFuncNameS),
fromSameModule(DefFuncNameS,FName), !. fromSameModule(DefFuncNameS,FName), !.
...@@ -2217,8 +2208,6 @@ fromSameModule(F1,F2) :- ...@@ -2217,8 +2208,6 @@ fromSameModule(F1,F2) :-
isConstructorRooted('Lit'(_)). isConstructorRooted('Lit'(_)).
isConstructorRooted('Comb'('ConsCall',_,_)). isConstructorRooted('Comb'('ConsCall',_,_)).
% we implement "success" as a constructor of type "Success":
isConstructorRooted('Comb'('FuncCall',"Prelude.success",[])).
isConstructorRooted('Free'(_,Exp)) :- % since we ignore Constr in the code: isConstructorRooted('Free'(_,Exp)) :- % since we ignore Constr in the code:
isConstructorRooted(Exp). isConstructorRooted(Exp).
......
...@@ -14,8 +14,8 @@ warnSuspendedConstraints(ShowAll,R) :- ...@@ -14,8 +14,8 @@ warnSuspendedConstraints(ShowAll,R) :-
find_chr_constraint(C), !, find_chr_constraint(C), !,
write(user_error,'WARNING: residual CHR constraints:'), write(user_error,'WARNING: residual CHR constraints:'),
writeSuspendedCHRConstraints(ShowAll), writeSuspendedCHRConstraints(ShowAll),
R='Prelude.success'. R='Prelude.True'.
warnSuspendedConstraints(_,'Prelude.success'). warnSuspendedConstraints(_,'Prelude.True').
writeSuspendedCHRConstraints(ShowAll) :- writeSuspendedCHRConstraints(ShowAll) :-
find_chr_constraint(C), write(user_error,' '), write(user_error,C), find_chr_constraint(C), write(user_error,' '), write(user_error,C),
......
...@@ -19,9 +19,9 @@ clpb_card(Ns,Bs,B) :- =(B,card(Ns,Bs)). ...@@ -19,9 +19,9 @@ clpb_card(Ns,Bs,B) :- =(B,card(Ns,Bs)).
clpb_exists(V,B,R) :- =(V^B,R). clpb_exists(V,B,R) :- =(V^B,R).
clpb_sat(B,C) :- sat(B), C='Prelude.success'. clpb_sat(B,C) :- sat(B), C='Prelude.True'.
clpb_check(B,R) :- taut(B,R). clpb_check(B,R) :- taut(B,R).
clpb_labeling(Bs,C) :- labeling(Bs), C='Prelude.success'. clpb_labeling(Bs,C) :- labeling(Bs), C='Prelude.True'.
...@@ -9,25 +9,25 @@ ...@@ -9,25 +9,25 @@
prim_FD_domain(L,A,B,R) :- prim_FD_domain(L,A,B,R) :-
(prolog(sicstus) -> domain(L,A,B) ; ins(L,'..'(A,B))), (prolog(sicstus) -> domain(L,A,B) ; ins(L,'..'(A,B))),
R='Prelude.success'. R='Prelude.True'.
prim_FD_sum(Vs,RelCall,V,R) :- prim_FD_sum(Vs,RelCall,V,R) :-
checkSICStusAndWarn('CLPFD.sum'), checkSICStusAndWarn('CLPFD.sum'),
RelCall=partcall(2,FD_Rel,[]), RelCall=partcall(2,FD_Rel,[]),
translateFD_Rel(FD_Rel,Rel), translateFD_Rel(FD_Rel,Rel),
sum(Vs,Rel,V), R='Prelude.success'. sum(Vs,Rel,V), R='Prelude.True'.
prim_FD_scalar_product(Cs,Vs,RelCall,V,R) :- prim_FD_scalar_product(Cs,Vs,RelCall,V,R) :-
checkSICStusAndWarn('CLPFD.scalar_product'), checkSICStusAndWarn('CLPFD.scalar_product'),
RelCall=partcall(2,FD_Rel,[]), RelCall=partcall(2,FD_Rel,[]),
translateFD_Rel(FD_Rel,Rel), translateFD_Rel(FD_Rel,Rel),
scalar_product(Cs,Vs,Rel,V), R='Prelude.success'. scalar_product(Cs,Vs,Rel,V), R='Prelude.True'.
prim_FD_count(Val,Vs,RelCall,C,R) :- prim_FD_count(Val,Vs,RelCall,C,R) :-
checkSICStusAndWarn('CLPFD.count'), checkSICStusAndWarn('CLPFD.count'),
RelCall=partcall(2,FD_Rel,[]), RelCall=partcall(2,FD_Rel,[]),
translateFD_Rel(FD_Rel,Rel), translateFD_Rel(FD_Rel,Rel),
count(Val,Vs,Rel,C), R='Prelude.success'. count(Val,Vs,Rel,C), R='Prelude.True'.
translateFD_Rel('CLPFD.=#',#=) :- !. translateFD_Rel('CLPFD.=#',#=) :- !.
translateFD_Rel('CLPFD./=#',#\=) :- !. translateFD_Rel('CLPFD./=#',#\=) :- !.
...@@ -38,16 +38,16 @@ translateFD_Rel('CLPFD.>=#',#>=) :- !. ...@@ -38,16 +38,16 @@ translateFD_Rel('CLPFD.>=#',#>=) :- !.
translateFD_Rel(FD_Rel,_) :- writeErr('ERROR: Illegal FD constraint: '), translateFD_Rel(FD_Rel,_) :- writeErr('ERROR: Illegal FD constraint: '),
writeErr(FD_Rel), nlErr, !, fail. writeErr(FD_Rel), nlErr, !, fail.
prim_FD_all_different(L,R) :- all_different(L), R='Prelude.success'. prim_FD_all_different(L,R) :- all_different(L), R='Prelude.True'.
prim_FD_indomain(Var,R) :- prim_FD_indomain(Var,R) :-
(prolog(sicstus) -> indomain(Var) ; label([Var])), (prolog(sicstus) -> indomain(Var) ; label([Var])),
R='Prelude.success'. R='Prelude.True'.
prim_FD_labeling(Options,L,R) :- prim_FD_labeling(Options,L,R) :-
map2M(user:translateLabelingOption,Options,PlOptions), map2M(user:translateLabelingOption,Options,PlOptions),
labeling(PlOptions,L), labeling(PlOptions,L),
R='Prelude.success'. R='Prelude.True'.
translateLabelingOption('CLPFD.LeftMost',leftmost). translateLabelingOption('CLPFD.LeftMost',leftmost).
translateLabelingOption('CLPFD.FirstFail',ff). translateLabelingOption('CLPFD.FirstFail',ff).
...@@ -72,22 +72,22 @@ prim_FD_minus(Y,X,R) :- #=(R,X-Y). ...@@ -72,22 +72,22 @@ prim_FD_minus(Y,X,R) :- #=(R,X-Y).
prim_FD_times(Y,X,R) :- #=(R,X*Y). prim_FD_times(Y,X,R) :- #=(R,X*Y).
prim_FD_equal(Y,X,'Prelude.success') :- #=(X,Y). prim_FD_equal(Y,X,'Prelude.True') :- #=(X,Y).
prim_FD_notequal(Y,X,'Prelude.success') :- #\=(X,Y). prim_FD_notequal(Y,X,'Prelude.True') :- #\=(X,Y).
prim_FD_le(Y,X,'Prelude.success') :- #<(X,Y). prim_FD_le(Y,X,'Prelude.True') :- #<(X,Y).
prim_FD_leq(Y,X,'Prelude.success') :- #=<(X,Y). prim_FD_leq(Y,X,'Prelude.True') :- #=<(X,Y).
prim_FD_ge(Y,X,'Prelude.success') :- #>(X,Y). prim_FD_ge(Y,X,'Prelude.True') :- #>(X,Y).
prim_FD_geq(Y,X,'Prelude.success') :- #>=(X,Y). prim_FD_geq(Y,X,'Prelude.True') :- #>=(X,Y).
prim_FD_solve_reify(Constraint,R) :- prim_FD_solve_reify(Constraint,R) :-
translateConstraint(Constraint,PrologConstraint), translateConstraint(Constraint,PrologConstraint),
call(PrologConstraint), call(PrologConstraint),
R='Prelude.success'. R='Prelude.True'.
translateConstraint(V,V) :- var(V), !. translateConstraint(V,V) :- var(V), !.
translateConstraint(X,X) :- integer(X), !. translateConstraint(X,X) :- integer(X), !.
......
...@@ -15,13 +15,13 @@ prim_CLPR_times(Y,X,R) :- {R = X*Y}. ...@@ -15,13 +15,13 @@ prim_CLPR_times(Y,X,R) :- {R = X*Y}.
prim_CLPR_div(Y,X,R) :- {R = X/Y}. prim_CLPR_div(Y,X,R) :- {R = X/Y}.
prim_CLPR_le(Y,X,'Prelude.success') :- {X < Y}. prim_CLPR_le(Y,X,'Prelude.True') :- {X < Y}.
prim_CLPR_ge(Y,X,'Prelude.success') :- {X > Y}. prim_CLPR_ge(Y,X,'Prelude.True') :- {X > Y}.
prim_CLPR_leq(Y,X,'Prelude.success') :- {X =< Y}. prim_CLPR_leq(Y,X,'Prelude.True') :- {X =< Y}.
prim_CLPR_geq(Y,X,'Prelude.success') :- {X >= Y}. prim_CLPR_geq(Y,X,'Prelude.True') :- {X >= Y}.
% transform an integer into a float: % transform an integer into a float:
prim_CLPR_i2f(X,R) :- R is X*1.0. prim_CLPR_i2f(X,R) :- R is X*1.0.
...@@ -33,7 +33,7 @@ prim_minimumFor(Guard,Fun,X,E0,E) :- ...@@ -33,7 +33,7 @@ prim_minimumFor(Guard,Fun,X,E0,E) :-
?- block exec_minimum(?,?,?,-,?). ?- block exec_minimum(?,?,?,-,?).
exec_minimum(Guard,Fun,X,E,E3) :- exec_minimum(Guard,Fun,X,E,E3) :-
prim_apply(Guard,X,'Prelude.success',E,E1), prim_apply(Guard,X,'Prelude.True',E,E1),
prim_apply(Fun,X,Z,E1,E2), prim_apply(Fun,X,Z,E1,E2),
minimize(Z), E2=E3. minimize(Z), E2=E3.
...@@ -44,6 +44,6 @@ prim_maximumFor(Guard,Fun,X,E0,E) :- ...@@ -44,6 +44,6 @@ prim_maximumFor(Guard,Fun,X,E0,E) :-
?- block exec_maximum(?,?,?,-,?). ?- block exec_maximum(?,?,?,-,?).
exec_maximum(Guard,Fun,X,E,E3) :- exec_maximum(Guard,Fun,X,E,E3) :-
prim_apply(Guard,X,'Prelude.success',E,E1), prim_apply(Guard,X,'Prelude.True',E,E1),
prim_apply(Fun,X,Z,E1,E2), prim_apply(Fun,X,Z,E1,E2),
maximize(Z), E2=E3. maximize(Z), E2=E3.
...@@ -58,7 +58,7 @@ prim_getDynamicKnowledge(IsKnownAtTime) :- ...@@ -58,7 +58,7 @@ prim_getDynamicKnowledge(IsKnownAtTime) :-
-> makeShare(IsKnownAtTime,Result) -> makeShare(IsKnownAtTime,Result)
; Result = IsKnownAtTime). ; Result = IsKnownAtTime).
prim_isKnownAtTime(DT,'Dynamic.Dynamic'(P),'Prelude.success') :- prim_isKnownAtTime(DT,'Dynamic.Dynamic'(P),'Prelude.True') :-
P =.. [Pred,_,_,_|Args], P =.. [Pred,_,_,_|Args],
NP =.. [Pred,Start,Stop|Args], NP =.. [Pred,Start,Stop|Args],
call(user:NP), call(user:NP),
...@@ -309,7 +309,6 @@ translateDynFactArg('Left','Prelude.Left') :- !. ...@@ -309,7 +309,6 @@ translateDynFactArg('Left','Prelude.Left') :- !.
translateDynFactArg('Right','Prelude.Right') :- !. translateDynFactArg('Right','Prelude.Right') :- !.
translateDynFactArg('Nothing','Prelude.Nothing') :- !. translateDynFactArg('Nothing','Prelude.Nothing') :- !.
translateDynFactArg('Just','Prelude.Just') :- !. translateDynFactArg('Just','Prelude.Just') :- !.
translateDynFactArg('success','Prelude.success') :- !.
translateDynFactArg('LT','Prelude.LT') :- !. translateDynFactArg('LT','Prelude.LT') :- !.
translateDynFactArg('GT','Prelude.GT') :- !. translateDynFactArg('GT','Prelude.GT') :- !.
translateDynFactArg('EQ','Prelude.EQ') :- !. translateDynFactArg('EQ','Prelude.EQ') :- !.
......
...@@ -148,7 +148,7 @@ prim_openPort(_,S,_) :- ...@@ -148,7 +148,7 @@ prim_openPort(_,S,_) :-
nonvar(S), !, nonvar(S), !,
writeErr('ERROR: openPort: stream is not a free variable'), nlErr, writeErr('ERROR: openPort: stream is not a free variable'), nlErr,
fail. fail.
prim_openPort('Ports.internalPort'([],0,0,S),S,'Prelude.success'). prim_openPort('Ports.internalPort'([],0,0,S),S,'Prelude.True').
prim_openPortOnSocket(NewSocketNr,NewPortNr,Result) :- prim_openPortOnSocket(NewSocketNr,NewPortNr,Result) :-
...@@ -370,12 +370,12 @@ prim_sendPort(RMsg,RPort,R,E0,E) :- ...@@ -370,12 +370,12 @@ prim_sendPort(RMsg,RPort,R,E0,E) :-
prim_sendPortExec(Msg,Port,R,E0,E). prim_sendPortExec(Msg,Port,R,E0,E).
prim_sendPortExec(Msg,'Ports.internalPort'(_,0,_,Stream), prim_sendPortExec(Msg,'Ports.internalPort'(_,0,_,Stream),
'Prelude.success',E0,E) :- 'Prelude.True',E0,E) :-
% send to internal port % send to internal port
!, !,
add2Stream(Stream,Msg), E0=E. add2Stream(Stream,Msg), E0=E.
prim_sendPortExec('Ports.SP_Put'(Str),'Ports.internalPort'(_,-1,_,WIn), prim_sendPortExec('Ports.SP_Put'(Str),'Ports.internalPort'(_,-1,_,WIn),
'Prelude.success',E0,E) :- 'Prelude.True',E0,E) :-
% send to stream port % send to stream port
!, !,
user:waitUntilGround(Str,E0,E), % wait for string to become bound user:waitUntilGround(Str,E0,E), % wait for string to become bound
...@@ -384,7 +384,7 @@ prim_sendPortExec('Ports.SP_Put'(Str),'Ports.internalPort'(_,-1,_,WIn), ...@@ -384,7 +384,7 @@ prim_sendPortExec('Ports.SP_Put'(Str),'Ports.internalPort'(_,-1,_,WIn),
writeChars(user_error,Str), writeChars(user_error,Str),
nlErr)). nlErr)).
prim_sendPortExec('Ports.SP_GetLine'(Str),'Ports.internalPort'(WOut,-1,_,_), prim_sendPortExec('Ports.SP_GetLine'(Str),'Ports.internalPort'(WOut,-1,_,_),
'Prelude.success',E0,E) :- 'Prelude.True',E0,E) :-
% send to stream port % send to stream port
!, !,
readStreamLine(WOut,WOLine), readStreamLine(WOut,WOLine),
...@@ -394,7 +394,7 @@ prim_sendPortExec('Ports.SP_GetLine'(Str),'Ports.internalPort'(WOut,-1,_,_), ...@@ -394,7 +394,7 @@ prim_sendPortExec('Ports.SP_GetLine'(Str),'Ports.internalPort'(WOut,-1,_,_),
nlErr)), nlErr)),
user:constrEq(SPOutLine,Str,_,E0,E). % unify SP_Get-Arg with read line user:constrEq(SPOutLine,Str,_,E0,E). % unify SP_Get-Arg with read line
prim_sendPortExec('Ports.SP_GetChar'(Chr),'Ports.internalPort'(WOut,-1,_,_), prim_sendPortExec('Ports.SP_GetChar'(Chr),'Ports.internalPort'(WOut,-1,_,_),
'Prelude.success',E0,E) :- 'Prelude.True',E0,E) :-
% send to stream port % send to stream port
!, !,
get_code(WOut,NC), char_int(NC,C), get_code(WOut,NC), char_int(NC,C),
...@@ -403,7 +403,7 @@ prim_sendPortExec('Ports.SP_GetChar'(Chr),'Ports.internalPort'(WOut,-1,_,_), ...@@ -403,7 +403,7 @@ prim_sendPortExec('Ports.SP_GetChar'(Chr),'Ports.internalPort'(WOut,-1,_,_),
nlErr)), nlErr)),
user:constrEq(C,Chr,_,E0,E). % unify SP_GetChar-Arg with read character user:constrEq(C,Chr,_,E0,E). % unify SP_GetChar-Arg with read character
prim_sendPortExec('Ports.SP_EOF'(Bool),'Ports.internalPort'(WOut,-1,_,_), prim_sendPortExec('Ports.SP_EOF'(Bool),'Ports.internalPort'(WOut,-1,_,_),
'Prelude.success',E0,E) :- 'Prelude.True',E0,E) :-
% send to stream port % send to stream port
!, !,
(atEndOfStream(WOut) -> EOF='Prelude.True' ; EOF='Prelude.False'), (atEndOfStream(WOut) -> EOF='Prelude.True' ; EOF='Prelude.False'),
...@@ -412,17 +412,17 @@ prim_sendPortExec('Ports.SP_EOF'(Bool),'Ports.internalPort'(WOut,-1,_,_), ...@@ -412,17 +412,17 @@ prim_sendPortExec('Ports.SP_EOF'(Bool),'Ports.internalPort'(WOut,-1,_,_),
nlErr)), nlErr)),
user:constrEq(Bool,EOF,_,E0,E). % unify SP_EOF-Arg with current value user:constrEq(Bool,EOF,_,E0,E). % unify SP_EOF-Arg with current value
prim_sendPortExec('Ports.SP_Close','Ports.internalPort'(WOut,-1,_,WIn), prim_sendPortExec('Ports.SP_Close','Ports.internalPort'(WOut,-1,_,WIn),
'Prelude.success',E0,E) :- 'Prelude.True',E0,E) :-
% send to stream port % send to stream port
!, !,
close(WIn), close(WOut), % close input and output streams close(WIn), close(WOut), % close input and output streams
E0=E. E0=E.
prim_sendPortExec(Msg,'Ports.internalPort'(_,-1,_,_),'Prelude.success',E0,E) :- prim_sendPortExec(Msg,'Ports.internalPort'(_,-1,_,_),'Prelude.True',E0,E) :-
% send to stream port % send to stream port
!, !,
writeErr('ERROR: wrong message received by stream port: '), writeErr('ERROR: wrong message received by stream port: '),
writeErr(Msg), nlErr, E0=E. writeErr(Msg), nlErr, E0=E.
prim_sendPortExec(Msg,'Ports.internalPort'(Host,SNr,PNr,_),'Prelude.success',E0,E) :- prim_sendPortExec(Msg,'Ports.internalPort'(Host,SNr,PNr,_),'Prelude.True',E0,E) :-
% send to external port % send to external port
% catch connection errors: % catch connection errors: