I'm defining the semantics of a programming language, and I'd like to use a monad to help me. My specific monad, not that it much matters, is

$ M(\tau) = \mathcal P(\tau \times \mathcal P(\mathit{cnstrnt}) \times \mathit{eventstructure})$.

The idea is that expressions in my language will be given denotations of type $M(\mathit{value})$, and statements will be given denotations of type $M(1)$.

Anyway, I define a 'bind' operator on my monad, with the usual type

$M(\tau) \rightarrow (\tau \rightarrow M(\pi)) \rightarrow M(\pi)$.


What is a good syntax for my 'bind' operator? If I stay very close to functional programming syntax, I get something like this

$e_1 >\!\!>\!= \lambda v\ldotp e_2$

But I'm in math world now, so I have more typographical flexibility. The "$>\!\!>\!= \lambda \_$" sequence appears a lot in my definitions, so I'm wondering if I can optimise it into a single operator, perhaps like this:

$e_1 \triangleright_v e_2$

I almost like this very much. The main problem, I think, is that it's not clear from the notation that $v$ is bound in the right-hand operand.

Can anybody suggest a compact and readable notation along these lines? Or even along different lines? How do you folk write your 'bind' operators when you're not constrained to Haskell syntax?

  • $\begingroup$ I guess I could always try do-notation, e.g. something like $\mathbf{let}~v\leftarrow e_1~\mathbf{in}~e_2$. I think I'll go for something like that in the absence of any other ideas. $\endgroup$ – John Wickerson Jul 2 '14 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.