Re: [elm-discuss] Bug report (Undefined is not a function!)

2017-03-29 Thread Peter Damoc
If you want a SSCCE, here it is:
https://ellie-app.com/M5sydznVwXa1/0

This is what you might be doing (the equivalent, of course).

On Wed, Mar 29, 2017 at 9:32 AM, Mark Hamburg  wrote:

> I've now seen something like this a few times. The last time I tried to
> build an SSCCE, the bug went away when I looked more closely so I expect to
> get nasty messages from the bug submission system if I try to report it as
> is, but I figured I would see whether anyone else has seen anything like
> this in an effort to narrow in.
>
> This Elm code
>
> operationHandlers : List (Operation.Op Msg -> Maybe Updater)
> operationHandlers =
> [ handleAccountOperation
> ]
>
> handleAccountOperation : Operation.Op Msg -> Maybe Updater
> handleAccountOperation op =
> case Debug.log "handleAccountOperation" op of
> Operation.Account accountID accountOp ->
> applyAccountOperation accountOp
> |> Maybe.map (updateAccount accountID)
> _ ->
> Nothing
>
>
> produces this JavaScript
>
> var _adobe$adlproj$App_SessionData$operationHandlers = {
> ctor: '::',
> _0: *_adobe$adlproj$App_SessionData$handleAccountOperation*,
> _1: {ctor: '[]'}
> };
> var _adobe$adlproj$App_SessionData$handleAccountOperation = function (op)
> {
> var _p5 = A2(_elm_lang$core$Debug$log, 'handleAccountOperation', op);
> if (_p5.ctor === 'Account') {
> return A2(
> _elm_lang$core$Maybe$map,
> _adobe$adlproj$App_SessionData$updateAccount(_p5._0),
> _adobe$adlproj$App_SessionData$applyAccountOperation(_p5._1));
> } else {
> return _elm_lang$core$Maybe$Nothing;
> }
> };
>
>
> Note the problem in bold: At the point where we construct the list, we
> have not initialized the variable being stored in the list. When we then
> try to call the function at the head of the list, we get informed that it
> isn't a function. Boom.
>
> Reversing order does not fix this (and should not be required to fix this).
>
> Mark
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Bug report (Undefined is not a function!)

2017-03-29 Thread Mark Hamburg
I've now seen something like this a few times. The last time I tried to
build an SSCCE, the bug went away when I looked more closely so I expect to
get nasty messages from the bug submission system if I try to report it as
is, but I figured I would see whether anyone else has seen anything like
this in an effort to narrow in.

This Elm code

operationHandlers : List (Operation.Op Msg -> Maybe Updater)
operationHandlers =
[ handleAccountOperation
]

handleAccountOperation : Operation.Op Msg -> Maybe Updater
handleAccountOperation op =
case Debug.log "handleAccountOperation" op of
Operation.Account accountID accountOp ->
applyAccountOperation accountOp
|> Maybe.map (updateAccount accountID)
_ ->
Nothing


produces this JavaScript

var _adobe$adlproj$App_SessionData$operationHandlers = {
ctor: '::',
_0: *_adobe$adlproj$App_SessionData$handleAccountOperation*,
_1: {ctor: '[]'}
};
var _adobe$adlproj$App_SessionData$handleAccountOperation = function (op) {
var _p5 = A2(_elm_lang$core$Debug$log, 'handleAccountOperation', op);
if (_p5.ctor === 'Account') {
return A2(
_elm_lang$core$Maybe$map,
_adobe$adlproj$App_SessionData$updateAccount(_p5._0),
_adobe$adlproj$App_SessionData$applyAccountOperation(_p5._1));
} else {
return _elm_lang$core$Maybe$Nothing;
}
};


Note the problem in bold: At the point where we construct the list, we have
not initialized the variable being stored in the list. When we then try to
call the function at the head of the list, we get informed that it isn't a
function. Boom.

Reversing order does not fix this (and should not be required to fix this).

Mark

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.