[rabbitmq-discuss] trying to figure out erlando
Jon Brisbin
jon at jbrisbin.com
Mon May 23 16:53:53 BST 2011
I keep thinking I can conquer this and, like a neurotic who expects a different result every time after doing the same thing, I have failed utterly! :)
Doing error_t:run(M) gives me: {undef,[{error_t,run,[#Fun<error_t.0.94248885>]}
and doing ErrorT:run(M) gives me: {{badfun,{ok,<0.39.0>}}
I'm afraid I'm going to have to drop this because I'm probably too right brain to make real use of this. I feel like I gave it a good effort, but I'm afraid I'm not smart enough to really wrap my head around what's going on. I'll just have to stick with case statements since I can understand those and the code works.
Ah well. Live and learn!
jb
On May 23, 2011, at 9:05 AM, Matthew Sackman wrote:
> 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
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Thanks!
Jon Brisbin
http://jbrisbin.com
Twitter: @j_brisbin
More information about the rabbitmq-discuss
mailing list