<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Literally cutting and pasting and compile I get:<div><br></div><div><div>tests.m:028: In clause for function `f_ln'/1:</div><div>tests.m:028:   error: undefined predicate `is'/2.</div><div><br></div><div>Which is not your error, have you pasted the right code?</div><div><br></div><div><br></div><div><br><blockquote type="cite"><div>On 22 Dec 2022, at 11:52, Mark Clements <mark.clements@ki.se> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><div class="elementToProof" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span class="ContentPasted0 elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">Dear Mercury users,<br></span></div><div class="elementToProof" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span class="ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);"><br></span></div><div class="elementToProof" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span class="ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">Is there any way to write a function that takes a predicate and returns a transformed predicate without (a) naming a new predicate or (b) using a lambda? In practice, I would like to move the lambda to a function. However, the following code gives an error: "Cannot unify two terms of type `(pred float)'". Can I assume that this is outside of Mercury's mode system?</span></div><div class="elementToProof" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span class="ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);"><br></span></div><div class="elementToProof" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span class="ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">Sincerely, Mark.</span></div><div class="elementToProof" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span class="ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);"><br></span></div><div class="elementToProof" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span class="ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">-----</span></div><div class="elementToProof" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span class="ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);"><br></span></div><div class="elementToProof" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span class="ContentPasted0 ContentPasted1" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">:- module tests.<div class="FluidPluginCopy"><br class="ContentPasted1"></div><div class="FluidPluginCopy ContentPasted1">:- interface.</div><div class="FluidPluginCopy ContentPasted1">:- import_module io.</div><div class="FluidPluginCopy ContentPasted1">:- pred main(io::di, io::uo) is det.</div><div class="FluidPluginCopy"><br class="ContentPasted1"></div><div class="FluidPluginCopy ContentPasted1">:- implementation.</div><div class="FluidPluginCopy ContentPasted1">:- import_module float, ranges, solutions.</div><div class="FluidPluginCopy ContentPasted1">:- use_module math.</div><div class="FluidPluginCopy"><br class="ContentPasted1"></div><div class="FluidPluginCopy ContentPasted1">main(!IO) :-</div><div class="FluidPluginCopy ContentPasted1">    test1(!IO), % OK</div><div class="FluidPluginCopy ContentPasted1">    test2(!IO). % Does not compile</div><div class="FluidPluginCopy"><br class="ContentPasted1"></div><div class="FluidPluginCopy ContentPasted1">:- pred test1(io::di, io::uo) is det.</div><div class="FluidPluginCopy ContentPasted1">test1(!IO) :-<span class="Apple-converted-space"> </span></div><div class="FluidPluginCopy ContentPasted1">    Data = (pred(Y::out) is nondet :- nondet_member(I,range(1,5)), Y = float(I)), % some data<br></div><div class="FluidPluginCopy ContentPasted1">    LnData = (pred(Y::out) is nondet :- Data(X), Y = math.ln(X)), % a transformation<br></div><div class="FluidPluginCopy ContentPasted1">    aggregate(LnData, print_line, !IO).</div><div class="FluidPluginCopy"><br class="ContentPasted1"></div><div class="FluidPluginCopy ContentPasted1">:- pred test2(io::di, io::uo) is det.</div><div class="FluidPluginCopy ContentPasted1">test2(!IO) :-<span class="Apple-converted-space"> </span></div><div class="FluidPluginCopy ContentPasted1">    Data = (pred(Y::out) is nondet :- nondet_member(I,range(1,5)), Y = float(I)), % some data<br></div><div class="FluidPluginCopy ContentPasted1">    LnData = f_ln(Data), %% This transformation does not compile:(<br></div><div class="FluidPluginCopy ContentPasted1">    aggregate(LnData, print_line, !IO).</div><div class="FluidPluginCopy"><br class="ContentPasted1"></div><div class="FluidPluginCopy ContentPasted1">:- func f_ln(pred(float)::(pred(out) is nondet)) = (pred(float)::(pred(out) is nondet)).</div><div class="FluidPluginCopy ContentPasted1">f_ln(Pred) = (pred(Y::out) is nondet :- Pred(X), Y is math.ln(X)).</div><br></span></div><div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: 400; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Times; -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 14px; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;"><span class="s1" style="font-kerning: none;"></span><br></div><div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: 400; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Times; -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 14px; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;"><span class="s1" style="font-kerning: none;"></span><br></div><div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: 400; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Times; -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;"><span class="s1" style="font-kerning: none;"><i>När du skickar e-post till Karolinska Institutet (KI) innebär detta att KI kommer att behandla dina personuppgifter.<span class="Apple-converted-space"> </span></i><a href="https://ki.se/medarbetare/integritetsskyddspolicy"><span class="s2" style="text-decoration: underline; font-kerning: none; color: rgb(0, 0, 238); -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 238);">Här finns information om hur KI behandlar personuppgifter</span></a>.<span class="Apple-converted-space"> </span></span></div><div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: 400; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Times; -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 14px; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;"><span class="s1" style="font-kerning: none;"></span><br></div><div style="margin: 0px; font-style: normal; font-variant-caps: normal; font-weight: 400; font-stretch: normal; font-size: 12px; line-height: normal; font-family: Times; -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;"><span class="s1" style="font-kerning: none;"><i>Sending email to Karolinska Institutet (KI) will result in KI processing your personal data.</i><span class="Apple-converted-space"> </span><a href="https://ki.se/en/staff/data-protection-policy"><span class="s2" style="text-decoration: underline; font-kerning: none; color: rgb(0, 0, 238); -webkit-text-stroke-width: 0px; -webkit-text-stroke-color: rgb(0, 0, 238);">You can read more about KI’s processing of personal data here</span></a>.<span class="Apple-converted-space"> </span></span></div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">users mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><a href="mailto:users@lists.mercurylang.org" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">users@lists.mercurylang.org</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><a href="https://lists.mercurylang.org/listinfo/users" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">https://lists.mercurylang.org/listinfo/users</a></div></blockquote></div><br></div></body></html>