*To*: cl-isabelle-users at lists.cam.ac.uk*Subject*: Re: [isabelle] Why is Monad_Syntax.bind right and not left associative?*From*: Tobias Nipkow <nipkow at in.tum.de>*Date*: Mon, 29 Jul 2019 18:28:13 +0200*In-reply-to*: <577a11a0-ed58-193a-7f62-7e156f0a4712@gmail.com>*References*: <577a11a0-ed58-193a-7f62-7e156f0a4712@gmail.com>*User-agent*: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

Dear Martin,

Tobias On 26/07/2019 14:12, Martin Desharnais wrote:

Dear Isabelle users, I recently discovered the `HOL-Library.Monad_Syntax` theory with its (>>=) and do-notation. While defining an inductive predicate using multiple bind operations, I encountered the following error message.Unresolved adhoc overloading of constant bindI minimized the my code until I noticed that the error only occurs with two or more binds and can be resolved by adding parenthesis on the left operands. theory Scratch imports Main "HOL-Library.Monad_Syntax" begin context fixes f :: "nat ⇒ 'a ⇒ 'a option" and x :: "'a" begin declare [[show_variants]] term "Some x >>= f 0" (* "Option.bind (Some x) (f 0)" :: "'a option" *) term "Some x >>= f 0 >>= f 1" (* Unresolved adhoc overloading of constant bind *) term "((Some x) >>= f 0) >>= f 1" (* "Option.bind (Option.bind (Some x) (f 0)) (f 1)" *) end end I checked the source code of `Monad_Syntax` and noticed that it is declared as `infixr ">>=" 54`. I was quite surprised because such a choice requires one to add extra parenthesis in what seem to be common cases and the traditional Haskell (>>=) operator itself is left associative. What is the reasoning for the Isabelle (>>=) to be right and not left associative? What are situations where it makes more sense? Best regards, Martin Desharnais

**Attachment:
smime.p7s**

**References**:**[isabelle] Why is Monad_Syntax.bind right and not left associative?***From:*Martin Desharnais

- Previous by Date: Re: [isabelle] Requirement 'fontconfig'
- Next by Date: Re: [isabelle] Slow startup if AFP in ROOTS
- Previous by Thread: Re: [isabelle] Why is Monad_Syntax.bind right and not left associative?
- Next by Thread: [isabelle] Things identified via `rewrites` not treated as identical
- Cl-isabelle-users July 2019 archives indexes sorted by: [ thread ] [ subject ] [ author ] [ date ]
- Cl-isabelle-users list archive Table of Contents
- More information about the Cl-isabelle-users mailing list