[rabbitmq-discuss] trying to figure out erlando
Matthew Sackman
matthew at rabbitmq.com
Mon May 23 15:05:28 BST 2011
On Mon, May 23, 2011 at 08:59:00AM -0500, Jon Brisbin wrote:
> Sorry to keep bugging you, but the result I get from something similar is:
>
> r: #Fun<error_t.0.94248885>
Oh right, yeah, just like with state_t, you'll actually need to run it.
> Here's what I'm doing:
>
> ErrorT = error_t:new(identity_m),
> M = do([ErrorT ||
> {ok, Channel} <- amqp_connection:open_channel(AMQP),
> {ok, Response} <- return(Publish(Channel)),
> ok <- amqp_channel:close(Channel),
> Response
> ]),
R = error_t:run(M),
> io:format("r: ~p~n", [R]),
> {reply, R, State}
Just like state_t, error_t actually results in the value of the monad
being a fun. Thus you need to run it. state_t has exec, eval and run,
depending on whether you want the transformed state, value or both back,
but error_t just needs run, as its not doing as much.
Of course, you can have multiple transforms. Consider the difference
between:
M = state_t:new(error_t:new(identity_m))
versus
M = error_t:new(state_t:new(identity_m))
!
Matthew
More information about the rabbitmq-discuss
mailing list