Re: [elm-discuss] Feature proposal: Html.none

2016-08-31 Thread Nick H
Evan pointed out on Elm Dev that this is functionality is already available:

none = text ""

but I don't think that solution is very obvious, and agree that adding none
to the library would be nice.

On Wed, Aug 31, 2016 at 4:02 PM, Mark Hamburg  wrote:

> Html.none would produce a virtual DOM node but that node would not produce
> anything in the actual DOM. It's usage is an alternative to list
> concatenation and empty divs. For example:
>
> div []
> [ headerView model,
> , model.error |> Maybe.map errorBoxView |> Maybe.withDefault Html.none
> , bodyView model
> ]
>
> Now, when diffing the virtual DOM, the header, optional error box, and
> body are always at the same indices within the div but we haven't cluttered
> the real DOM with empty nodes.
>
> 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.
>

-- 
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] Feature proposal: Html.none

2016-08-31 Thread Mark Hamburg
Html.none would produce a virtual DOM node but that node would not produce 
anything in the actual DOM. It's usage is an alternative to list concatenation 
and empty divs. For example:

div []
[ headerView model,
, model.error |> Maybe.map errorBoxView |> Maybe.withDefault Html.none
, bodyView model
]

Now, when diffing the virtual DOM, the header, optional error box, and body are 
always at the same indices within the div but we haven't cluttered the real DOM 
with empty nodes.

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.


Re: [elm-discuss] Re: Design of Large Elm apps

2016-08-31 Thread Mark Hamburg
I re-read your message, Erik, and my reply and realized that I hadn't
answered all of the questions. The routing I've been working with handles
both commands created by the client side and handled by the service side
and commands created by the client and handled by "normal" external means.
This gets addressed through the type declaration:

type ClientCommand msg
= Batch (List (ClientCommand msg))
| PlatformCmd (Platform.Cmd msg)
| APIFromClient (APICommand msg)


The key point here is in having the platform and API commands split out so
that they can be mapped differently. From the client standpoint, if you can
make a Cmd, then you can call ClientCommand.fromCmd and turn it into a
ClientCommand which can then be batched with API commands. At the point
where the "client" meets the "service" in the model, these get turned back
into Platform.Cmd's (through Task.succeed to set up the delivery of the the
APICommand value to the service).

If I could figure out how to do this with tasks, that might well be simpler
and easier to plug in. I may need to take a pass at that again.

Mark

P.S. I don't really like the words "client" and "service" but they seemed
better at least than "client" and "server" since the latter would suggest
code running on another machine which while this separation enables that
possibility is not something that is happening here. I thought about
"viewModel" and "dataModel" but that seemed to have a certain amount of
verbal noise in saying "model" everywhere.

On Sun, Aug 28, 2016 at 7:52 PM, Erik Lott  wrote:

> Mark, tell me about this code:
>
> type APICommand msg
> = AddForum (Error -> msg) (ForumID -> msg) String
> | DeleteForum (Error -> msg) (() -> msg) ForumID
> | PostMessage (Error -> msg) (() -> msg) ForumID String
>
>
> type APISubscription msg
> = ForumList (List (ForumID, String) -> msg)
> | MessageList (Array.Array String -> msg) ForumID
>
>
> Conceptually, I appreciate what you're trying to do here (create a simple
> system driven by domain messages - AddForum, DeleteForum, etc) , but the
> actual implementation worries me. I'm wondering why you're not simply
> creating an API module instead:
>
> module API exposing(addForum, deleteForum, postMessage)
>
> addForum: String -> Task Http.Error Forum
> // code here...
>
> deleteForum: String -> Task Http.Error Never
> // code here
>
> etc
>
>
> I know that you mentioned that you have some additional complexity (task
> queue, websockets,etc), but I haven't actually seen anything that would
> cause me to abandon the built-in command/subscriptions system. What if you
> need to do something in the page that is not necessarily domain related,
> but requires a task/command - e.g. generate a random number? Are these
> types of situations factored into your design?
>
>
>
>
> On Saturday, August 27, 2016 at 6:14:41 PM UTC-4, Mark Hamburg wrote:
>
>> I'm working on some example code. I'm varying between a moderately
>> fleshed out example of the plumbing but with little backing it up and a
>> fully worked but trivial to the point of not being interesting example. The
>> general model, however, works as follows:
>>
>> • We have a service model and a client model. The idea is that after
>> agreeing on an API, these can then undergo independent development.
>> Furthermore, we should be able to do things like mock the service rapidly
>> and then fill it in with a version that talks to the web service or
>> whatever is needed. Similarly, we could mock the client side quickly if we
>> just wanted to test the service APIs.
>>
>> • The API is represented by a union type: APICommand clientMsg. A
>> typical entry would be something like:
>>
>> | PostMessage (Error -> clientMsg) (() -> clientMsg) ForumId String
>>
>>
>>
>> • APICommand clientMsg is wrapped up inside a ClientCommand clientMsg type
>> that provides standard Cmd-style functionality (batch, map). It also
>> provides a way to embed non-API commands of type Cmd clientMsg. I would
>> have liked to just use a different type of message within Cmd to do this
>> rather than reconstructing map and batch — trivial though they may be —
>> but mapping for platform commands is built around tagging results as they
>> come back and we need to adjust the tagging functions on API commands
>> before they get to the service.
>>
>> • The update function for the client has the signature:
>>
>> clientMsg -> clientModel -> (clientModel, ClientCommand clientMsg)
>>
>> This gets applied at the "root" level when processing messages destined
>> for the client. On the way back, it can turn the client commands into
>> platform commands of type Cmd (RootMsg serviceMsg clientMsg) where the
>> RootMsg type provides for messages bound for the client, messages bound
>> for the service, and API commands bound for the service.
>>
>> • The service processes both its own messages and API commands (in
>> separate update functions in my latest code). Service updates 

[elm-discuss] Re: Elm-mdl implementations - suggest projects that can be added to reference list

2016-08-31 Thread Dmytro Gladkyi
Yes, it is now public on bitbucket:

https://bitbucket.org/gladimdim/offtieweb/src

On Wednesday, August 31, 2016 at 2:58:40 PM UTC+3, Håkon Rossebø wrote:
>
> Is the source available for this project? It would be nice to share 
> implementations with others.
>
> Håkon
>
> lørdag 20. august 2016 17.52.29 UTC+2 skrev Dmytro Gladkyi følgende:
>>
>> You can press on a blue Card (anywhere) and it will navigate back to 
>> list. I'll add button for this anyway.
>
>

-- 
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] conditional json parsing

2016-08-31 Thread Thomas Coopman
Thanks, I should have seen that.

On Wed, 31 Aug 2016 at 20:10 Nick H  wrote:

> Maybe use *andThen*
> ?
> Looks like that would let you decode part of the event, identify its type,
> and then branch to different decoders for different event types.
>
> On Wed, Aug 31, 2016 at 11:07 AM, Thomas Coopman  > wrote:
>
>> I'm struggling with parsing json data that contains different kinds of
>> data.
>>
>> My json structure looks like this:
>>
>> [{event: A, data: {id: 1, name: 'foo'}}, event: B, data: {id: 1, address:
>> 'bar'}}]
>>
>> I want to parse this structure to
>>
>> type Event = EA A | EB B
>>
>> type alias A = {id : Int, name: String}
>>
>> type alias B = {id: Int, address: String}
>>
>> decodeEvents : Json.Decode.Decoder List Event
>>
>> So I want to write *decodeEvents*.
>>
>> My question is, how can I do this? I want to write some if/case structure
>> that checks the event name to parse the correct event.
>> I was thinking of using *oneOf* on the data, but the data can have the
>> same structure for different events.
>>
>> --
>> 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.
>>
>
> --
> 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.
>

-- 
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] Help needed using canvas to render text in WebGL - stuck with how to use the virtual dom

2016-08-31 Thread roovo
Excellent - thanks for the info and link looks most cool indeed :) - 
just had a play - looking forward to being able to write something as 
capable at what you've got there (and as well organised code-wise).

One of my colleagues at work suggested the same approach (as why would you 
put text in webgl when you've got a perfectly capable text rendering engine 
in the browser)... It is still a (the) fallback solution - so I may be 
having a further delve into your code (thanks again).  However I'm wanting 
to put labels next to webgl renderings that stick with the things they 
label and scale with them in a responsive, dynamic way.  It is probably 
possible using an overlay but I managed to persuade myself that it would be 
more straight forward if I could do it all in webgl - hence the current 
course of action plus it felt like it should be possible - and it feels 
like I've got it working apart from this issue of handling the canvas 
elements that are needed so I don't kill the browser.


On Wednesday, August 31, 2016 at 7:07:06 PM UTC+1, Nick H wrote:
>
> My into-the-heavens project is using HTML divs to overlay text on a WebGL 
> canvas (link to relevant code 
> 
> ).
>
> This has worked fine for my needs, but my needs are pretty boring. Maybe 
> you want to do something cool & crazy with the canvas text?
>
> On Wed, Aug 31, 2016 at 10:53 AM, Nick H  > wrote:
>
>> Why do you want to render text using a canvas texture instead of the DOM? 
>> It seems like making a pure Elm function that places text in a div would 
>> give you the same results and would still integrate fine with elm-webgl.
>>
>> As for your specific question, I suspect the answer is no, but I don't 
>> know enough about the vdom implementation to say for sure.
>>
>> On Wed, Aug 31, 2016 at 10:26 AM, roovo > > wrote:
>>
>>> Hi
>>>
>>> I've recently been learning/hacking/having fun with elm and webgl and 
>>> have been experimenting with rendering text using canvas textures.  It 
>>> seems that this is not possible using elm-graphics as it renders text using 
>>> the DOM and not canvas, so I have slapped together a proof of concept 
>>> (currently hard-coded for my use-case) which uses a native component to 
>>> create a canvas and provide it as a texture fit for use in webgl - see the 
>>> gist at:
>>>
>>> https://gist.github.com/roovo/edff73230cb454a206e796f6e3fa71b0
>>>
>>> This does work - yay - nice looking text and easy to use :)
>>>
>>> However, it's obviously a bad idea to create these canvas elements in 
>>> the way that I am (directly on the DOM) as I am not using the virtual dom 
>>> so on each animation frame I'll just be adding more until something goes 
>>> pop.
>>>
>>> This is where I could do with some advice Is it possible to create 
>>> these in a way that they will be managed by the virtual dom - i.e. so it 
>>> won't create multiple canvases containing the same text, so ones that I'm 
>>> not using anymore will be removed from the dom, and so that they will be 
>>> available for use in the current render cycle (not sure if my terminology 
>>> is correct here) by webgl.  I need it to be available in the current cycle 
>>> so I can find out how big it is so I can create an appropriately sized 
>>> surface to render it on.
>>>
>>> I do hope that this makes sense - I'm new to both elm and webgl so 
>>> apologies if I'm not using the best wordage...
>>>
>>> Many thanks
>>>
>>> -- 
>>> 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...@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.


Re: [elm-discuss] Help needed using canvas to render text in WebGL - stuck with how to use the virtual dom

2016-08-31 Thread roovo
Hey Nick (and thanks)

the reason I'm using canvas is that I don't believe that you can pass a 
regular DOM element to web-gl for use as a texture - however this is my 
first foray into webgl so I am on a (pretty steep) learning curve and it 
may be that I have just not found out that you can yet

Also, on the v-dom stuff - I'm still hoping - need to do some heavy digging 
into the code to see what I think may work



On Wednesday, August 31, 2016 at 6:53:10 PM UTC+1, Nick H wrote:
>
> Why do you want to render text using a canvas texture instead of the DOM? 
> It seems like making a pure Elm function that places text in a div would 
> give you the same results and would still integrate fine with elm-webgl.
>
> As for your specific question, I suspect the answer is no, but I don't 
> know enough about the vdom implementation to say for sure.
>
> On Wed, Aug 31, 2016 at 10:26 AM, roovo  > wrote:
>
>> Hi
>>
>> I've recently been learning/hacking/having fun with elm and webgl and 
>> have been experimenting with rendering text using canvas textures.  It 
>> seems that this is not possible using elm-graphics as it renders text using 
>> the DOM and not canvas, so I have slapped together a proof of concept 
>> (currently hard-coded for my use-case) which uses a native component to 
>> create a canvas and provide it as a texture fit for use in webgl - see the 
>> gist at:
>>
>> https://gist.github.com/roovo/edff73230cb454a206e796f6e3fa71b0
>>
>> This does work - yay - nice looking text and easy to use :)
>>
>> However, it's obviously a bad idea to create these canvas elements in the 
>> way that I am (directly on the DOM) as I am not using the virtual dom so on 
>> each animation frame I'll just be adding more until something goes pop.
>>
>> This is where I could do with some advice Is it possible to create 
>> these in a way that they will be managed by the virtual dom - i.e. so it 
>> won't create multiple canvases containing the same text, so ones that I'm 
>> not using anymore will be removed from the dom, and so that they will be 
>> available for use in the current render cycle (not sure if my terminology 
>> is correct here) by webgl.  I need it to be available in the current cycle 
>> so I can find out how big it is so I can create an appropriately sized 
>> surface to render it on.
>>
>> I do hope that this makes sense - I'm new to both elm and webgl so 
>> apologies if I'm not using the best wordage...
>>
>> Many thanks
>>
>> -- 
>> 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...@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] conditional json parsing

2016-08-31 Thread Thomas Coopman
I'm struggling with parsing json data that contains different kinds of data.

My json structure looks like this:

[{event: A, data: {id: 1, name: 'foo'}}, event: B, data: {id: 1, address: 
'bar'}}]

I want to parse this structure to

type Event = EA A | EB B

type alias A = {id : Int, name: String}

type alias B = {id: Int, address: String}

decodeEvents : Json.Decode.Decoder List Event

So I want to write *decodeEvents*.

My question is, how can I do this? I want to write some if/case structure 
that checks the event name to parse the correct event.
I was thinking of using *oneOf* on the data, but the data can have the same 
structure for different events.

-- 
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] Help needed using canvas to render text in WebGL - stuck with how to use the virtual dom

2016-08-31 Thread roovo
Hi

I've recently been learning/hacking/having fun with elm and webgl and have 
been experimenting with rendering text using canvas textures.  It seems 
that this is not possible using elm-graphics as it renders text using the 
DOM and not canvas, so I have slapped together a proof of concept 
(currently hard-coded for my use-case) which uses a native component to 
create a canvas and provide it as a texture fit for use in webgl - see the 
gist at:

https://gist.github.com/roovo/edff73230cb454a206e796f6e3fa71b0

This does work - yay - nice looking text and easy to use :)

However, it's obviously a bad idea to create these canvas elements in the 
way that I am (directly on the DOM) as I am not using the virtual dom so on 
each animation frame I'll just be adding more until something goes pop.

This is where I could do with some advice Is it possible to create 
these in a way that they will be managed by the virtual dom - i.e. so it 
won't create multiple canvases containing the same text, so ones that I'm 
not using anymore will be removed from the dom, and so that they will be 
available for use in the current render cycle (not sure if my terminology 
is correct here) by webgl.  I need it to be available in the current cycle 
so I can find out how big it is so I can create an appropriately sized 
surface to render it on.

I do hope that this makes sense - I'm new to both elm and webgl so 
apologies if I'm not using the best wordage...

Many thanks

-- 
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: Performance issue with AnimationFrame based game

2016-08-31 Thread OvermindDL1
Chrome, Windows 10 (I'm at work, this is not my main OS).  Every time I 
tried to profile the tab would get slower and slower over a period of just 
a few seconds until the tab itself died.



On Wednesday, August 31, 2016 at 8:49:01 AM UTC-6, Alex Spurling wrote:
>
> Thanks, that is good to know! I wonder what exactly caused it to blow up. 
> I've done profiling on both Chrome and Firefox and never had it blow up. 
> What browser and OS are you using?
>
> Alex
>
> On Wednesday, 31 August 2016 15:27:22 UTC+1, OvermindDL1 wrote:
>>
>> Well if it helps I hooked up a profiler to the page and ran it, it 
>> exploded and died due to memory allocations.  Unsure where since it died...
>>
>>
>> On Tuesday, August 30, 2016 at 5:23:51 PM UTC-6, Alex Spurling wrote:
>>>
>>> I've made a little canvas drawing app in Elm which unfortunately suffers 
>>> from some weird performance behaviour. Here it is in action:
>>>
>>> https://alexspurling.github.io/quickdraw/
>>>
>>> The design of the game is like this:
>>>
>>> update msg model =
>>>   case msg of
>>> CanvasMsg ->
>>>   --Update the model with the latest mouse position, drawing state, 
>>> zoom level etc
>>> AnimationFrame time ->
>>>   --Calculate the line to draw on the canvas (if any)
>>>   --Dispatch the commands needed to draw a line or resize the canvas
>>>
>>> The idea of this design is that it minimises the number of canvas update 
>>> commands needed (we don't need to update the canvas more than 60 times a 
>>> second).
>>>
>>> If you try to draw on the canvas, you should notice a steady 60fps while 
>>> drawing. The performance issue hits when you try to zoom out. The zooming 
>>> action works well enough, but if you then try to draw on the canvas, often 
>>> the framerate will drop to 10fps or so. However - and this is the bit I 
>>> cannot understand - if you simply wait 60 seconds or so and try to draw 
>>> again, fps will be back up to 60.
>>>
>>> I've just uploaded a new build that reproduces the problem a little more 
>>> easily, instead of zooming, simply press and hold the "down" arrow key. 
>>> While holding down, try to draw on the screen and you should notice a drop 
>>> in frame rate. Now, let go of "down" and keep drawing. You should notice 
>>> that the framerate still stays low. (If you don't notice the drop, try 
>>> zooming out with the mouse wheel and try again).
>>>
>>> If you take a look at the code (
>>> https://github.com/alexspurling/quickdraw/), holding the "down" key 
>>> performs this update:
>>>
>>> TestMsg ->
>>>   let
>>>   _ = Debug.log "Test msg" 0
>>>   _ = loop 100
>>>   in
>>> model ! []
>>>
>>> loop : Int -> Bool
>>> loop val =
>>>   if val == 0 then
>>> True
>>>   else
>>> loop (val - 1)
>>>
>>> Each call to this event triggers a CPU heavy loop. I would expect 
>>> framerate to suffer while Elm handles this update. But why do I still get 
>>> low framerate long after these events have all been processed?
>>>
>>

-- 
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: Performance issue with AnimationFrame based game

2016-08-31 Thread Alex Spurling
Thanks, that is good to know! I wonder what exactly caused it to blow up. 
I've done profiling on both Chrome and Firefox and never had it blow up. 
What browser and OS are you using?

Alex

On Wednesday, 31 August 2016 15:27:22 UTC+1, OvermindDL1 wrote:
>
> Well if it helps I hooked up a profiler to the page and ran it, it 
> exploded and died due to memory allocations.  Unsure where since it died...
>
>
> On Tuesday, August 30, 2016 at 5:23:51 PM UTC-6, Alex Spurling wrote:
>>
>> I've made a little canvas drawing app in Elm which unfortunately suffers 
>> from some weird performance behaviour. Here it is in action:
>>
>> https://alexspurling.github.io/quickdraw/
>>
>> The design of the game is like this:
>>
>> update msg model =
>>   case msg of
>> CanvasMsg ->
>>   --Update the model with the latest mouse position, drawing state, 
>> zoom level etc
>> AnimationFrame time ->
>>   --Calculate the line to draw on the canvas (if any)
>>   --Dispatch the commands needed to draw a line or resize the canvas
>>
>> The idea of this design is that it minimises the number of canvas update 
>> commands needed (we don't need to update the canvas more than 60 times a 
>> second).
>>
>> If you try to draw on the canvas, you should notice a steady 60fps while 
>> drawing. The performance issue hits when you try to zoom out. The zooming 
>> action works well enough, but if you then try to draw on the canvas, often 
>> the framerate will drop to 10fps or so. However - and this is the bit I 
>> cannot understand - if you simply wait 60 seconds or so and try to draw 
>> again, fps will be back up to 60.
>>
>> I've just uploaded a new build that reproduces the problem a little more 
>> easily, instead of zooming, simply press and hold the "down" arrow key. 
>> While holding down, try to draw on the screen and you should notice a drop 
>> in frame rate. Now, let go of "down" and keep drawing. You should notice 
>> that the framerate still stays low. (If you don't notice the drop, try 
>> zooming out with the mouse wheel and try again).
>>
>> If you take a look at the code (
>> https://github.com/alexspurling/quickdraw/), holding the "down" key 
>> performs this update:
>>
>> TestMsg ->
>>   let
>>   _ = Debug.log "Test msg" 0
>>   _ = loop 100
>>   in
>> model ! []
>>
>> loop : Int -> Bool
>> loop val =
>>   if val == 0 then
>> True
>>   else
>> loop (val - 1)
>>
>> Each call to this event triggers a CPU heavy loop. I would expect 
>> framerate to suffer while Elm handles this update. But why do I still get 
>> low framerate long after these events have all been processed?
>>
>

-- 
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: Performance issue with AnimationFrame based game

2016-08-31 Thread OvermindDL1
Well if it helps I hooked up a profiler to the page and ran it, it exploded 
and died due to memory allocations.  Unsure where since it died...


On Tuesday, August 30, 2016 at 5:23:51 PM UTC-6, Alex Spurling wrote:
>
> I've made a little canvas drawing app in Elm which unfortunately suffers 
> from some weird performance behaviour. Here it is in action:
>
> https://alexspurling.github.io/quickdraw/
>
> The design of the game is like this:
>
> update msg model =
>   case msg of
> CanvasMsg ->
>   --Update the model with the latest mouse position, drawing state, 
> zoom level etc
> AnimationFrame time ->
>   --Calculate the line to draw on the canvas (if any)
>   --Dispatch the commands needed to draw a line or resize the canvas
>
> The idea of this design is that it minimises the number of canvas update 
> commands needed (we don't need to update the canvas more than 60 times a 
> second).
>
> If you try to draw on the canvas, you should notice a steady 60fps while 
> drawing. The performance issue hits when you try to zoom out. The zooming 
> action works well enough, but if you then try to draw on the canvas, often 
> the framerate will drop to 10fps or so. However - and this is the bit I 
> cannot understand - if you simply wait 60 seconds or so and try to draw 
> again, fps will be back up to 60.
>
> I've just uploaded a new build that reproduces the problem a little more 
> easily, instead of zooming, simply press and hold the "down" arrow key. 
> While holding down, try to draw on the screen and you should notice a drop 
> in frame rate. Now, let go of "down" and keep drawing. You should notice 
> that the framerate still stays low. (If you don't notice the drop, try 
> zooming out with the mouse wheel and try again).
>
> If you take a look at the code (https://github.com/alexspurling/quickdraw/), 
> holding the "down" key performs this update:
>
> TestMsg ->
>   let
>   _ = Debug.log "Test msg" 0
>   _ = loop 100
>   in
> model ! []
>
> loop : Int -> Bool
> loop val =
>   if val == 0 then
> True
>   else
> loop (val - 1)
>
> Each call to this event triggers a CPU heavy loop. I would expect 
> framerate to suffer while Elm handles this update. But why do I still get 
> low framerate long after these events have all been processed?
>

-- 
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 and contenteditable

2016-08-31 Thread Damir Batinović
I had to use contenteditable in my project. The true way to handling cursor 
position was to hard (I don't remeber what it was but I thing it involves 
window.selection) so I went with a  dirty hack. Added another field to my 
model (tmpInput), saving input events into that field until Blur event was 
fired. Upon blur event tmpInput is copied to real input. So model and view 
are out of sync until blur happens. It's not nice but there where no 
problems with implementation so far.

Dana utorak, 30. kolovoza 2016. u 17:18:37 UTC+2, korisnik Vincent Jousse 
napisao je:
>
> I didn't but it's a very good idea :-)
>
> Do you see a way to overcome the cursor position problem with that 
> approach?
>
> Le mardi 30 août 2016 17:16:21 UTC+2, Peter Damoc a écrit :
>>
>> It makes perfect sense. 
>>
>> Have you thought about putting contenteditable on each individual span? 
>> This should allow for single word editing and for individual double 
>> clicks. 
>>
>>
>> On Tue, Aug 30, 2016 at 5:43 PM, Vincent Jousse  wrote:
>>
>>> I mainly need double click events. I'm doing a transcription editor: I'm 
>>> using a Speech To Text tool to generate words with their timestamps.
>>>
>>> I'm putting the words in a contenteditable div so that people can 
>>> correct the transcription, and each word is surrounded by a span containing 
>>> the timestamp info in some data- attribute.
>>> When people double click on the span, I want the audio player to play 
>>> the file starting at this timestamp. And when the audio is playing, I want 
>>> the «current word» to be highlighted in the contenteditable div.
>>>
>>> Does it make sense?
>>>
>>> Le mardi 30 août 2016 16:36:10 UTC+2, Peter Damoc a écrit :

 Well, it was a naive approach. ^_^ 

 As for events inside the contenteditable div, I have no idea but what 
 kind of events do you want to handle in this kind of a scenario?



 On Tue, Aug 30, 2016 at 5:11 PM, Vincent Jousse  
 wrote:

> Thanks, but I would not say that it's "working" as it seems that the 
> cursor position is reset after each event, causing the text to be written 
> from right to left :-)
>
> It's seems related to this issue: 
> https://github.com/elm-lang/virtual-dom/issues/23
>
> And with this approach (storing a string), how could I trigger events 
> on the HTML inside the contenteditable div?
>
>
 -- 
 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...@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] Re: Elm-mdl implementations - suggest projects that can be added to reference list

2016-08-31 Thread Håkon Rossebø
Is the source available for this project? It would be nice to share 
implementations with others.

Håkon

lørdag 20. august 2016 17.52.29 UTC+2 skrev Dmytro Gladkyi følgende:
>
> You can press on a blue Card (anywhere) and it will navigate back to list. 
> I'll add button for this anyway.

-- 
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] Unrelated modules having ports with the same name

2016-08-31 Thread James Wilson
There is as I understand it nothing wrong with compiling multiple modules with 
a main function using one command. It's very useful if you want many separate 
Elm widgtts that share the same runtime and library code. As I understand you 
can do:


Foo.hs:

module Foo
main = HTML.App.Program...

Bar.hs:

module Bar
main = HTML.App.Program...

elm-make Foo.elm Bar.elm --output combined.JS

And combined.JS will expose Elm.Foo and Elm.Bar, which can separately be 
instantiated but share the same runtime and things.

All of this to say, I would assume that ports should be scoped by the main 
module that imports them and that this is a bug.

-- 
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] Unrelated modules having ports with the same name

2016-08-31 Thread b123400
Thanks for the reply.

I want to try out Elm as embedded element(s) instead of full page app, but 
due to the original DOM structure and CSS layout, I cannot put everything 
inside a single element. Then I thought it would be a good idea to create 
two separated modules, and "pipe" then through ports. I think this should 
be allowed?

Nick H於 2016年8月23日星期二 UTC+8下午10時54分07秒寫道:
>
> This is the intended behavior. The strange thing about what you are trying 
> to do is that ModuleA and ModuleB both have a function called main. Are you 
> intending them to be a part of the same program? Programs should only have 
> one "main" function.
>
> If ModuleA and ModuleB are supposed to be different programs, then you 
> should not be compiling them in the same elm-make command. I am kind of 
> surprised that the compiler lets you do this.
>
>
>
>
> On Mon, Aug 22, 2016 at 10:25 AM, b123400  
> wrote:
>
>> Hello, I find it confusing about ports in modules, I have sent an issue 
>>  but didn't get 
>> notice for a month, so I'd like to post it here for discussion.
>>
>> I have two modules, they both have a port with the same name:
>>
>> port module ModuleA exposing (main)
>> import Html exposing (text)import Platform.Sub as Sub
>> port incomePort : (String -> msg) -> Sub msg
>> main =
>>   text "Hello"
>>
>> port module ModuleB exposing (main)
>> import Html exposing (text)import Platform.Sub as Sub
>> port incomePort : (String -> msg) -> Sub msg
>> main =
>>   text "Hey!"
>>
>> And I compiled it by this command:
>>
>> elm make ModuleA.elm ModuleB.elm --output combined.js
>>
>> The generated JS file will output the following error:
>>
>> Error: There can only be one port named `incomePort`, but your program has 
>> multiple.
>>
>> These two modules are not connected and there should be no ambiguity 
>> between the ports. I think the ports name checking should be bounded to the 
>> module, instead of JS-file-wise.
>>
>> By the way, when I generate the modules separately and include them in 
>> the same page, there is no error.
>>
>> elm make ModuleA.elm --output a.js
>> elm make ModuleB.elm --output b.js
>>
>> 
>> 
>>
>> Is this behaviour intended?
>>
>> -- 
>> 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...@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.