[m-users.] When is nondeterminism appropriate?

Dirk Ziegemeyer dirk at ziegemeyer.de
Wed Feb 17 21:04:41 AEDT 2021


Hello Philip,

as alternative to using state variables, you can also define a monadic bind-function using a builtin left-associative operator like >> to 'hide' the intermediate results. You can see an example in this post from the mailing list:
http://lists.mercurylang.org/archives/users/2019-July/008628.html

State variables are a bit more verbose, but also more flexible and probably also more efficient in cases with more than one input argument. The monadic approach forces you to box multiple input arguments together while the state variable approach can leave them unboxed.

Dirk

> Am 17.02.2021 um 03:44 schrieb Volker Wysk <post at volker-wysk.de>:
> 
> Am Dienstag, den 16.02.2021, 20:14 -0500 schrieb Philip White:
>> Yeah, this sounds right. Maybe I'm just wishing that Mercury had some
>> form of do-notation or syntactic convenience for monads and
>> applicatives. I've been brainstorming about how do-notation would even
>> work in a logic programming language, but I'm running into a wall. I
>> haven't been able to find any literature on the subject either.
> 
> Mercury DOES have something like do-notation: state variables. See Ralph
> Becket's Mercury tutorial, chapter 1.1.



More information about the users mailing list