Re: [m-users.] Mode and inst confusion in ODBC library
Volker Wysk <[email protected]>
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <[email protected]> |
Am Mittwoch, dem 09.08.2023 um 08:16 +1000 schrieb Julien Fischer: > > On Tue, 8 Aug 2023, Volker Wysk wrote: > > > Hi > > > > In the ODBC extra library, there's this: > > > > -----snip----- > > :- type odbc.transaction(T) == pred(T, odbc.state, odbc.state). > > :- mode odbc.transaction == (pred(out, di, uo) is det). > > > > % ... > > > > :- pred odbc.transaction(data_source::in, user_name::in, password::in, > > transaction(T)::transaction, > > odbc.result(T)::out, io::di, io::uo) is det. > > -----snip----- > > > > The mode of the fourth argument of the predicate is a (higher order) inst, > > not a mode - ?? According to Ralph Becket's Mercury tutorial, the mode of an > > argument is a mapping from the instantiation before the call to after the > > call of the predicate. And it's written "Before >> After" (or defined this > > way). > > From section 9.4 "Higher-order insts and modes" of the reference manual: > > As a convenience, the language allows you to write a higher order mode > using the same syntax as a higher order inst. If HOInst has the form of > a higher order inst, then writing HOInst where a mode is required is the > same as writing ‘in(HOInst)’, which is in turn equivalent to ‘HOInst >> > HOInst’. Therefore, you can omit ‘in()’ around the higher order inst of > an input argument. For example, > > :- mode foldl(in(pred(in, in, out) is det), in, in, out) is det. > > can also be written as > > :- mode foldl(pred(in, in, out) is det, in, in, out) is det. > > though the former may be easier to understand. Thanks. I won't comment on this... Bye Volker _______________________________________________ users mailing list [email protected] https://lists.mercurylang.org/listinfo/users
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6QXGh82Ov3+2nrxp+K4ydFOsHoUFAmTTF14ACgkQ+K4ydFOs HoWGoBAAzn4zp9YKHRs5w5EwjqQoqrV39lUmQcl9XubxI3+PzTGLDTJLM4BwksEc qIOE4OYJc0vQsZYTvmHrGp76z22raEW5cNXR/Tsz+88ljJuMeWSlTAERhtltQLmM 12NKdkdQay/gIh/tQLFDL+jWPNOeDtn/cZld5ZClTevZK8HOG5/9mKBUwo5IWY5D CxO3t9VGUch9KH8CdeQlnDv2uUnWjtia/wGtqhY1wl5YdDyBAKbwqWIANAurk0aF u8QsQtoyzRKjhweB8v21u4FDAeunSvb4xsGjBmWeslvGg33/wpqCaaxCe97wPjhz kPVgHArSbmpUwUl8cnP01+T96Tf4ThfPCh6G+8R7CplLBFvqwJjBmwFSq/vRb9AC 7hf3fWGpG0mtAG+ScDJuvvP7tqkZhlPzgv2xzseJG/vcGhww6fjNkRNKo1muurOX aR/deHrEXHIBljcR3Fknmd4OuKbooiAEL3Dxs3B3ygGjvh213Pdby0fG12XHCHaA +QePNHkEcil2Af4SSu2ldaneRny0uyHBaIjPAtgRLv0YpqqH95LwbUCHWIQP8Y3S Qm9RiiDHdaf3FxpKgKGFkAA9N7Q6RHJUw5vACeo5Rj26s6zZ+LFHT+tBa9iMdjYu OUjOGXE8CJLlTHU021i718Fdh8Rfbm+AIrj1GI0PeurQt0X0wK8= =MIPi -----END PGP SIGNATURE-----