Add conditionals stratements to domonad forms

Description

I implemented a patch that would allow us to do conditionals on domonad macros

Example:

(domonad monad-m
[a (action 1)
:if (= a 3)
:then [
result (action c)
]
:else [
result (action d)
]]
result)

Conditional blocks can be nested.

One gotcha one has to be aware of is: you may use bindings from a conditional branch in the m-result sexp as long as that branch gets called, given that one doesn't know for sure which branch is going to be called, you should set the same bindings on both branches.

The patch code is on: github.com/roman/algo.monads

I didn't do a pull request given that you need to this first.

NOTE: I've added this feature in some other projects I've been working on (parser combinators) and is working perfectly so far, there is tests in the patch but I wanted to give you that safe net as well.

Environment

The extension was developed in Mac OS X Lion

Attachments

1

Activity

Show:

Konrad HinsenFebruary 5, 2014 at 11:22 AM

Román GonzálezJanuary 10, 2012 at 6:28 AM

Adding support for monadic conditionals on the domonad macro

Completed

Details

Assignee

Reporter

Patch

Code

Priority

Created January 6, 2012 at 10:28 PM
Updated February 5, 2014 at 11:22 AM
Resolved February 5, 2014 at 11:22 AM