I am a (not for a while but...) Haskeller but not used to Monads in 
Erlang... I have already made use of the maybe_m monad implementation for 
validating an API JSON request, that's fine, but for some reason my sign-in 
form validation code just meets with a compile error and I can't see why. 
It's late. I should stop!!

Here is the full set of code, then the error...

-module(smsengine_web_controller, [Req]).
-compile({parse_transform, do}).
-compile(export_all).

%% @doc The public web controller does not need any authorisation checks.
before_filters(DefaultFilters, _RequestContext) -> 
    utils:no_auth(DefaultFilters).

%% @doc Home page redirect to the template.
index('GET', []) -> ok.

signin('POST', []) ->
U = Req:post_param("u"),
P = Req:post_param("p"),

do([list_m ||
validate_email(U),
validate_password(P)
]),

{render_other,
[{controller, "web"}, {action, "index"}],
[]}. %% TODO: session start etc


validate_email([]) ->
list_m:return(100);
% list_m:return({email_text, "Please supply a valid email address"});

validate_email(_) ->
list_m:fail([]). %% other validation checks will go here


validate_password([]) ->
list_m:return({password_text, "Please enter your password"});

validate_password(_) ->
list_m:fail([]). %% other validation checks here

And the error:

[error] Error in controller error undef 
[{list_m,return,"d",[]},{smsengine_web_controller,'-signin/3-fun-1-',3,[{file,"/Users/seancharles/Documents/bitbucket/smsengine/src/controller/smsengine_web_controller.erl"},{line,33}]},{smsengine_web_controller,signin,3,[{file,"/Users/seancharles/Documents/bitbucket/smsengine/src/controller/smsengine_web_controller.erl"},{line,32}]},{boss_web_controller,call_controller_action,3,[{file,"src/boss/boss_web_controller.erl"},{line,363}]},{boss_web_controller,apply_action,4,[{file,"src/boss/boss_web_controller.erl"},{line,355}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,334}]},{boss_web_controller_handle_request,process_dynamic_request,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,242}]},{boss_web_controller_handle_request,process_request,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,228}]}]

My intent was to run the list monad over all of the various validation and 
credentials checking functions such that, if all is well I have an empty 
list i.e. the user can redirect to the landing page for their account or, 
if there is at least one error in the list, that I re-display the sign-in 
page and the template shows the errors as and where needed.

It seems to be telling me that the function list_m:return is not defined or 
have I got it wrong??

Thanks and goodnight for now.
:)
Sean

-- 
You received this message because you are subscribed to the Google Groups 
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/chicagoboss/96e18854-37ee-4099-a145-27cdfce19614%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to