[elm-discuss] Re: Call of init function behaviour

2017-04-10 Thread Max Goldstein
init is not a function. It is a constant value. It will be evaluated 
immediately and, if you've wired things up right, referred to in main. 

If you have a message that triggers a state reset, it's not crazy to reuse the 
init value. But it sounds like it's getting used when you don't want it to be, 
so maybe you're using it somewhere other than main on accident?

If not, then you may have some page reloading issue that's not tied to init 
specifically. 

-- 
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.


Re: [elm-discuss] Re: Help with Jupyter/IPython notebook kernel for Elm

2017-04-10 Thread Austin Bingham
The basic kernel is working at this point, and you can get it here:
https://github.com/abingham/jupyter-elm-kernel

But there's still quite a bit to be done, and some of the design decisions
I made might be short-sighted. Take it for a spin and let me know what you
think. Any feedback, ideas, PRs, etc. would be great.

On Mon, Apr 10, 2017 at 5:48 PM Michael Lamb  wrote:

> Are you still looking for a hand with this, Austin?
>
> I'm not an expert, or anything but I'm really interested in making a good
> Jupyter kernel for Elm to use with nteract. If you haven't seen it, check
> it out: https://nteract.io/
> It mimics Jupyter as a desktop application, so you do not need a server.
>
>
> On Monday, March 27, 2017 at 12:10:33 PM UTC-6, Austin Bingham wrote:
>
> Hi everyone,
>
> I started hacking a bit today on a Jupyter notebook kernel for elm. You
> can see it here:
>
> https://github.com/abingham/jupyter-elm-kernel
> 
>
> It doesn't quite work yet, though, and I think I need help from someone
> who knows javascript/requirejs/web stuff a bit better than me. The proximal
> problem I'm seeing is that when jupyter tries to run the elm-make-generated
> javascript, it thinks that 'Elm' is undefined during (I think) some part of
> the AMD machinery. Jupyter show this as the output for the cell:
>
> Javascript error adding output!
> ReferenceError: Elm is not defined
> See your browser Javascript console for more details.
>
> As far as I can see, Elm *should* be defined, and certainly the generated
> code looks like any other Elm output I've looked at. So I'm a bit stumped.
>
> My approach to the kernel is currently very simple. The kernel is
> implemented in Python, and it receives a blob of Elm source code. I dump
> this to a temp file, use a subprocess to run "elm-make" to make the output,
> read the output, and ship it back to jupyter. As far as I can see, all of
> that is working properly. I run into problems when jupyter tries to execute
> the stuff I return. This design may or may not be optimal in the long run,
> but I want to get the plumbing working first.
>
> So if someone feels up to the challenge, I'd love any help I could get.
> This seems like it should be pretty straightforward, but perhaps I'm being
> naive and/or missing something obvious.
>
> Of course, I'm also happy to discuss other aspects of the kernel (e.g.
> design, compilation technique, etc.), but my priority is to just get
> something into an output cell.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elm-discuss/4VUQuYukGXM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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] Re: Help with Jupyter/IPython notebook kernel for Elm

2017-04-10 Thread Michael Lamb
Are you still looking for a hand with this, Austin? 

I'm not an expert, or anything but I'm really interested in making a good 
Jupyter kernel for Elm to use with nteract. If you haven't seen it, check 
it out: https://nteract.io/
It mimics Jupyter as a desktop application, so you do not need a server.


On Monday, March 27, 2017 at 12:10:33 PM UTC-6, Austin Bingham wrote:
>
> Hi everyone,
>
> I started hacking a bit today on a Jupyter notebook kernel for elm. You 
> can see it here:
>
> https://github.com/abingham/jupyter-elm-kernel 
> 
>
> It doesn't quite work yet, though, and I think I need help from someone 
> who knows javascript/requirejs/web stuff a bit better than me. The proximal 
> problem I'm seeing is that when jupyter tries to run the elm-make-generated 
> javascript, it thinks that 'Elm' is undefined during (I think) some part of 
> the AMD machinery. Jupyter show this as the output for the cell:
>
> Javascript error adding output!
> ReferenceError: Elm is not defined
> See your browser Javascript console for more details.
>
> As far as I can see, Elm *should* be defined, and certainly the generated 
> code looks like any other Elm output I've looked at. So I'm a bit stumped.
>
> My approach to the kernel is currently very simple. The kernel is 
> implemented in Python, and it receives a blob of Elm source code. I dump 
> this to a temp file, use a subprocess to run "elm-make" to make the output, 
> read the output, and ship it back to jupyter. As far as I can see, all of 
> that is working properly. I run into problems when jupyter tries to execute 
> the stuff I return. This design may or may not be optimal in the long run, 
> but I want to get the plumbing working first.
>
> So if someone feels up to the challenge, I'd love any help I could get. 
> This seems like it should be pretty straightforward, but perhaps I'm being 
> naive and/or missing something obvious.
>
> Of course, I'm also happy to discuss other aspects of the kernel (e.g. 
> design, compilation technique, etc.), but my priority is to just get 
> something into an output cell.
>

-- 
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] Call of init function behaviour

2017-04-10 Thread Oliver Dunkl
When will the init function call? 

I have a strange (for me) behaviour in my flow. I have a backend call
in which some entity will be saved. I have a page redirect logic e.g.:

type alias Model
  { page : Int
  }

view model =
  case model.page of
0 -> viewA
1 -> viewB
  ...

In my 'update' function I will set this pages:

init : (Model, Cmd Action)
init =
  let model = Model 0
  in (model, Cmd.batch [])

update action model =
  case action of
ActionA -> model ! [ saveEntity ]
SaveE (Err _) -> model ! []
SaveE (Ok _) -> { model | page = 1 } ! []

I have a button which triggers ActionA and this sends a backend-call. So
sometimes it works as expected and sometimes the whole page will be
reloaded after SaveE (Ok _) and the init function will be called and my 
model is
initialized with the starting values.

The backend gets some values and saves the entity in the db. This
works fine with a curl-call.

So my question is, is there a trigger which reloads the page and calls
the init function? And has someone an idea why the init function will 
called in the 
middle of a flow?

My problem is it seems that this happens randomly and I have currently
no idea where the problem comes from.

thx
\= odi

-- 
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] Randomly call init function

2017-04-10 Thread Oliver Dunkl
I have a strange (for me) behaviour in my flow. I have a backend call
in which some entity will be saved. I have a page redirect logic e.g.:

type alias Model
  { page : Int
  }

view model =
  case model.page of
0 -> viewA
1 -> viewB
  ...

In my 'update' function I will set this pages:

update action model =
  case action of
ActionA -> { model | page = 0 } ! [ saveEntity ]
SaveE (Err _) -> model ! []
SaveE (Ok _) -> { model | page = 1 } ! []

I have a button which triggers ActionA and this shows the viewB. So
sometimes it works as expected and sometimes the whole page will be
reloaded and the init function will be called and my model is
initialized with the starting values.

The backend gets some values and saves the entity in the db. This
works fine with a curl-call.

So my question is, is there a trigger which reloads the page and calls
the init function?

My problem is it seems that this happens randomly and I have currently
no idea where the problem comes from.

thx
\= odi

-- 
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.


Re: [elm-discuss] Elm kernel for Jupyter

2017-04-10 Thread Zachary Kessin
Very cool, could be quite useful for teaching elm

Zach
ᐧ

On Mon, Apr 10, 2017 at 11:27 AM, Austin Bingham 
wrote:

> I'm happy to announce that the Elm kernel for Jupyter is ready for use (by
> the adventurous, at least). You can get it here:
>
> https://github.com/abingham/jupyter-elm-kernel
>
> There's still a fair amount of work to do on it, but it's at the point
> where I think it'll benefit greatly from feedback. Ideas, complaints,
> thought, and PRs are definitely encouraged!
>
> Also, I'd like to give special thanks to Noah Hall for helping get the
> project to where it is.
>
> Austin
>
> --
> 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.
>



-- 
Zach Kessin
Teaching Web Developers to test code to find more bugs in less time
Skype: zachkessin
+972 54 234 3956 / +44 203 734 9790 / +1 617 778 7213

-- 
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] Elm kernel for Jupyter

2017-04-10 Thread Austin Bingham
I'm happy to announce that the Elm kernel for Jupyter is ready for use (by 
the adventurous, at least). You can get it here:

https://github.com/abingham/jupyter-elm-kernel

There's still a fair amount of work to do on it, but it's at the point 
where I think it'll benefit greatly from feedback. Ideas, complaints, 
thought, and PRs are definitely encouraged!

Also, I'd like to give special thanks to Noah Hall for helping get the 
project to where it is. 

Austin

-- 
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.