Is it not possible just to put another domonad block in the true branch of
the if? Alternately, it should be possible to do it with an explicit bind
operation.


On Thu, Jul 11, 2013 at 2:11 PM, JvJ <kfjwhee...@gmail.com> wrote:

> I'm trying to use a domonad block with the state monad, and I'm running
> into trouble chaining together multiple monadic instructions.
>
> Take this for example:
>
> ;; This block of code fetches the value from :a in the state,
> ;; and then associates a new value for :b if :a is set.
> (domonad state-m
>  [a (fetch-val :a)
>  _ (if a
>    (update-state #(assoc % :b 2))
>    (m-result nil))
>  ]
>  nil)
>
> My question is, what if I wanted to run two update functions, like
> (update-state #(assoc % :b 2)) and (update-state #(assoc % :c 3)),
> but within the if statement?
>
> (p.s.  I realize that assoc is variadic, and could easily deal with this,
> however I'm using
> it as a simple example of a more general case)
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to