Re: [elm-discuss] Re: How to walk my own implementation of an array

2017-12-04 Thread Matthieu Pizenberg


> I wouldn't want to go through hundreds of thousands for just one thousand. 
> That's why I'm trying to come up with a function that have the behavior I 
> described initially, "nextlocation". Along with "index" function I can work 
> out in O(1) the index for the next one


Yep sorry, I didn't realize that initially. Then you could do something 
like:

nextLocation : Location -> Shape -> Maybe Location
nextLocation location shape =
let
increment (loc, size) (locationAcc, shouldInc) =
if shouldInc then
if loc + 1 < size then
( loc + 1 :: locationAcc, False )
else
( 0 :: locationAcc, True )
else
( loc :: locationAcc, False )

newLocation =
List.map2 (,) location shape
|> List.foldr increment ([],True)
in
if Tuple.second newLocation then
Nothing
else
Tuple.first newLocation


-- 
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: How to walk my own implementation of an array

2017-12-04 Thread Matthieu Pizenberg
I wasn't very far ^^ here is the function:

location : Int -> Int -> ( Int, Int ) -> ( Int, Int ) -> Maybe ( Int, Int )
location bufferIndex offset ( str1, str2 ) ( height, width ) =
let
unOffset =
bufferIndex - offset

( line, lineRest ) =
( unOffset // str1
, unOffset % str1
)

( column, columnRest ) =
( lineRest // str2
, lineRest % str2
)

locationOk =
line < height && column < width && columnRest == 0
in
if locationOk then
Just ( line, column )
else
Nothing

You can easily verify your example by putting it in a file, and in elm-repl:

import TheFile
import List

List.range 0 8 |> List.map (\id -> TheFile.location id 0 (6,2) (2,2))

-- 
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: How to walk my own implementation of an array

2017-12-03 Thread Matthieu Pizenberg
Oops, not as trivial as I thought ahah. Forget previous answer. It may 
require just some little adjustment though, I will think about it.

On Monday, December 4, 2017 at 3:49:23 PM UTC+8, Matthieu Pizenberg wrote:
>
> Regarding your question, walking the array is not complicated I think. You 
> can just walk the underlying buffer, and use a function like below if I'm 
> not mistaking.
>
> location : Int -> Int -> Strides -> Shape -> Maybe Location
> location bufferIndex bufferOffset (stride1, stride2) (height, width) =
> let
> unOffset =
> bufferIndex - bufferOffset
> 
> line =
> unOffset // stride1
> 
> column =
> unOffset % stride1
> in
> if line < height && column < width then
> Just (line, column)
> else
> Nothing
>
> Generalization would proceed the same, using euclidean division and 
> modulo, dimension after dimension.
>
> On Friday, December 1, 2017 at 11:22:16 PM UTC+8, Francisco Ramos wrote:
>>
>> Hi guys,
>>
>> been trying to figure out for a while now how I can solve this problem. 
>> I've implemented my own type of array, it's called NdArray. The way it 
>> works is as follow:
>> It has a buffer (an array of something), a shape (list of dimensions), 
>> strides (list of steps) and an offset. Imagine we have a NdArray with a 
>> buffer of 9 numbers [1, 2, 3, 4, 5, 6, 7, 8, 9], shape [3, 3] (square 
>> matrix) and this leads to a list of strides [3, 1]. This last one means, 
>> there is a jump of 3 numbers for each of the first dimension. Better 
>> visualised:
>>
>> buffer => [1, 2, 3, 4, 5, 6, 7, 8, 9]
>> view of this buffer with shape [3, 3] => 
>> [ 1, 2, 3
>> , 4, 5, 6
>> , 7, 8, 9
>> ]
>>
>> Now, imagine I change the strides to be [2, 2], that means, I'm jumping 
>> one per dimension (in this square matrix I'm jumping one column and one 
>> row). The result is:
>> [ 1, 3
>> , 7, 9
>> ]
>>
>> I'm jumping one number in the last dimension, and an entire row in the 
>> first dimension. Shape is now [2, 2].
>>
>> So I have all this implemented already here 
>> https://github.com/jscriptcoder/elm-ndarray. This is port of ndarray 
>> by Mikola Lysenko, https://github.com/scijs/ndarray. But I got stuck how 
>> to walk this array. I'm trying to implement map, filter and fold (foldl), 
>> and to do so I must be able to walk this array, which is not that trivial 
>> (or at least not for me). I have implemented a function "index" which takes 
>> a location in the form of list of Int and calculates the index based on 
>> shape, strides and offset. So I'm trying to find a way to implement this 
>> functionality:
>> For example, for a [3, 3] shape then
>> nextLocation [0, 0] => Just [0, 1]
>> nextLocation [0, 1] => Just [0, 2]
>> nextLocation [0, 2] => Just [1, 0]
>> nextLocation [1, 0] => Just [1, 1]
>> nextLocation [1, 1] => Just [1, 2]
>> ...
>>  nextLocation [2, 2] => Nothing
>>
>> By far not an expert in functional programming, maybe someone can help me 
>> to figur this one out?
>>
>> Thanks a lot.
>>
>> Fran
>>
>

-- 
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: How to walk my own implementation of an array

2017-12-03 Thread Matthieu Pizenberg
Regarding your question, walking the array is not complicated I think. You 
can just walk the underlying buffer, and use a function like below if I'm 
not mistaking.

location : Int -> Int -> Strides -> Shape -> Maybe Location
location bufferIndex bufferOffset (stride1, stride2) (height, width) =
let
unOffset =
bufferIndex - bufferOffset

line =
unOffset // stride1

column =
unOffset % stride1
in
if line < height && column < width then
Just (line, column)
else
Nothing

Generalization would proceed the same, using euclidean division and modulo, 
dimension after dimension.

On Friday, December 1, 2017 at 11:22:16 PM UTC+8, Francisco Ramos wrote:
>
> Hi guys,
>
> been trying to figure out for a while now how I can solve this problem. 
> I've implemented my own type of array, it's called NdArray. The way it 
> works is as follow:
> It has a buffer (an array of something), a shape (list of dimensions), 
> strides (list of steps) and an offset. Imagine we have a NdArray with a 
> buffer of 9 numbers [1, 2, 3, 4, 5, 6, 7, 8, 9], shape [3, 3] (square 
> matrix) and this leads to a list of strides [3, 1]. This last one means, 
> there is a jump of 3 numbers for each of the first dimension. Better 
> visualised:
>
> buffer => [1, 2, 3, 4, 5, 6, 7, 8, 9]
> view of this buffer with shape [3, 3] => 
> [ 1, 2, 3
> , 4, 5, 6
> , 7, 8, 9
> ]
>
> Now, imagine I change the strides to be [2, 2], that means, I'm jumping 
> one per dimension (in this square matrix I'm jumping one column and one 
> row). The result is:
> [ 1, 3
> , 7, 9
> ]
>
> I'm jumping one number in the last dimension, and an entire row in the 
> first dimension. Shape is now [2, 2].
>
> So I have all this implemented already here 
> https://github.com/jscriptcoder/elm-ndarray. This is port of ndarray 
> by Mikola Lysenko, https://github.com/scijs/ndarray. But I got stuck how 
> to walk this array. I'm trying to implement map, filter and fold (foldl), 
> and to do so I must be able to walk this array, which is not that trivial 
> (or at least not for me). I have implemented a function "index" which takes 
> a location in the form of list of Int and calculates the index based on 
> shape, strides and offset. So I'm trying to find a way to implement this 
> functionality:
> For example, for a [3, 3] shape then
> nextLocation [0, 0] => Just [0, 1]
> nextLocation [0, 1] => Just [0, 2]
> nextLocation [0, 2] => Just [1, 0]
> nextLocation [1, 0] => Just [1, 1]
> nextLocation [1, 1] => Just [1, 2]
> ...
>  nextLocation [2, 2] => Nothing
>
> By far not an expert in functional programming, maybe someone can help me 
> to figur this one out?
>
> Thanks a lot.
>
> Fran
>

-- 
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: How to walk my own implementation of an array

2017-12-03 Thread Matthieu Pizenberg
Hi Francisco,
I think there is a confusion here. If you keep the same buffer, your 
matrice [1 3; 7 9] will be represented by { strides = (6, 2), shape = (2,2) 
} not strides = (2,2). Because 6 is the jump from one line to the other (1 
to 7).
Let me know if I'm mistaking or not clear.

On Friday, December 1, 2017 at 11:22:16 PM UTC+8, Francisco Ramos wrote:
>
> Hi guys,
>
> been trying to figure out for a while now how I can solve this problem. 
> I've implemented my own type of array, it's called NdArray. The way it 
> works is as follow:
> It has a buffer (an array of something), a shape (list of dimensions), 
> strides (list of steps) and an offset. Imagine we have a NdArray with a 
> buffer of 9 numbers [1, 2, 3, 4, 5, 6, 7, 8, 9], shape [3, 3] (square 
> matrix) and this leads to a list of strides [3, 1]. This last one means, 
> there is a jump of 3 numbers for each of the first dimension. Better 
> visualised:
>
> buffer => [1, 2, 3, 4, 5, 6, 7, 8, 9]
> view of this buffer with shape [3, 3] => 
> [ 1, 2, 3
> , 4, 5, 6
> , 7, 8, 9
> ]
>
> Now, imagine I change the strides to be [2, 2], that means, I'm jumping 
> one per dimension (in this square matrix I'm jumping one column and one 
> row). The result is:
> [ 1, 3
> , 7, 9
> ]
>
> I'm jumping one number in the last dimension, and an entire row in the 
> first dimension. Shape is now [2, 2].
>
> So I have all this implemented already here 
> https://github.com/jscriptcoder/elm-ndarray. This is port of ndarray 
> by Mikola Lysenko, https://github.com/scijs/ndarray. But I got stuck how 
> to walk this array. I'm trying to implement map, filter and fold (foldl), 
> and to do so I must be able to walk this array, which is not that trivial 
> (or at least not for me). I have implemented a function "index" which takes 
> a location in the form of list of Int and calculates the index based on 
> shape, strides and offset. So I'm trying to find a way to implement this 
> functionality:
> For example, for a [3, 3] shape then
> nextLocation [0, 0] => Just [0, 1]
> nextLocation [0, 1] => Just [0, 2]
> nextLocation [0, 2] => Just [1, 0]
> nextLocation [1, 0] => Just [1, 1]
> nextLocation [1, 1] => Just [1, 2]
> ...
>  nextLocation [2, 2] => Nothing
>
> By far not an expert in functional programming, maybe someone can help me 
> to figur this one out?
>
> Thanks a lot.
>
> Fran
>

-- 
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] Pointer (mouse/touch/pointer) events community coordination attempt

2017-11-30 Thread Matthieu Pizenberg
PS: duplicate of reddit for people not using reddit 
(https://www.reddit.com/r/elm/comments/7gksya/pointer_mousetouchpointer_events_community/)

Hi folks,

I've been browsing the elm packages repository in search of packages 
dealing with pointer events in general, mouse / touch / pointer. My 
conclusion is that we are all doing more or less the same things over and 
over. The timeline is the following:

First publication:

* 2016-08: knledg/touch-events
* 2016-10: mbr/elm-mouse-events
* 2016-11: mpizenberg/elm-touch-events
* 2017-05: mpizenberg/elm-mouse-events
* 2017-06: Elm-Canvas/element-relative-mouse-events
* 2017-07: zwilias/elm-touch-events
* 2017-10: mpizenberg/elm-pointer-events

Last update:

* 2017-05: 1.0.4 of mbr/elm-mouse/events
* 2017-05: 2.1.2 of knledg/touch-events
* 2017-06: 3.0.1 of mpizenberg/elm-touch-events
* 2017-06: 1.0.0 of Elm-Canvas/element-relative-mouse-events
* 2017-10: 1.0.4 of mpizenberg/elm-pointer-events
* 2017-11: 1.1.1 of mpizenberg/elm-mouse-events
* 2017-11: 1.1.0 of zwilias/elm-touch-events

As you can see, I'm partially (mpizenberg) responsible for starting 
additional mouse and touch packages. Of course, I had reasons to do so at 
the time, but now, I feel that it would be a good time to coordinate and 
have a united approach before the switch to 0.19.

To start this coordinating discussion, if you have been using some of 
these, could you explain why? for what needs? Please provide examples if 
possible. I will start with myself.

* *mpizenberg/elm-touch-events*:
  That's the first package I created. I needed multitouch support, which 
was not available in knledg/touch-events.
* *mpizenberg/elm-mouse-events*:
  My main need was to get the reliable relative positions of mouse move 
events, the most efficient way possible. It meant using the 
"offsetX/offsetY" properties of mouse events, which are not exposed by 
mbr/elm-mouse-events. Example usage was a user study, demo still available 
at http://mm17-otis.pizenberg.fr .
* *mpizenberg/elm-pointer-events*:
  Eventually, after having implemented both mouse and touch behaviors for 
each of my projects, I got tired of doing the job twice each time. So this 
library is to support the web pointer events API, that inherit from mouse 
events but support mouse, touch, and others (pens, ...) pointer events. 
Unfortunately, the API is not well supported by Safari and Firefox yet 
(https://caniuse.com/#feat=pointer) so I also made a minimalist polyfill, 
compatible with elm (https://github.com/mpizenberg/elm-pep). Example usage 
at http://elm-image-annotation.pizenberg.fr/ (code at 
https://github.com/mpizenberg/demo-elm-image-annotation).

-- 
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] JS typed array implementation for elm

2017-11-28 Thread Matthieu Pizenberg
I've started API design thinking in this issue [1]. Say hello there if 
you'd like to participate, any help appreciated :)

[1] Github issue: https://github.com/mpizenberg/elm-js-typed-array/issues/1

-- 
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: Array map with start and end

2017-11-27 Thread Matthieu Pizenberg
Following your advice, I came back to elm 0.18 and just started a 
repository to try to wrap JS typed arrays in elm. I've moved the discussion 
to a new post [1] since we were drifting from the original post here.
Cheers

[1] JS typed array implementation for elm: 
https://groups.google.com/d/topic/elm-discuss/ZfdV85yq9jU/discussion

-- 
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: Array map with start and end

2017-11-23 Thread Matthieu Pizenberg

>
> Do you need to rebuild the compiler for this?
>

I'm not familiar with so called "native" elm 0.18 code. So I wanted to use 
the example given by Robin with `Elm/JsArray.elm` and 
`Elm/Kernel/JsArray.js` from elm master branch to try the same thing with 
`JsArrayBuffer.[elm/js]`. Since this is code in the master branch only, 
which is 0.19 syntax (`elm.json`, "kernel" js code, ...), I cannot compile 
it with elm-make from 0.18 branch.

But it's ok, this need no rush, will try when I have a little more time.

-- 
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: Array map with start and end

2017-11-20 Thread Matthieu Pizenberg
Hi again,

So out of curiosity, I just spend a couple hours looking for variations of:
"(immutable/persistent) (tensor/multidimentional array/multidimentional 
data structure) implementation"
and my conclusion is that I did not easily find examples of implementations 
of data structures tailored for such specific needs as tensor manipulation. 
It must not be the right way to search for this.

What I found however was many references to Okasaki's work on immutable 
data structures. This question [1] with it's answer provide good starting 
points in my opinion. Okasaki's book seems to focus on how to 
design/implement fuctional data structures so it could give good insights 
for the raw data structure at the base of your ndarray type.

Maybe the first thing to do would be to clearly define all the operations 
you want to have for your ndarray in some document. Then design a data 
structure considering trade-off for all the operations supported. 
Apparently, there is a paper for the numpy arrays listed on scipy website 
[2]. These are not immutable however so I don't know if it is usefull.

In hope that it may help,
Cheers,
Matthieu

[1] interesting question: https://cs.stackexchange.com/a/25953/34063
[2] scipy citations: https://www.scipy.org/citing.html

-- 
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: Array map with start and end

2017-11-19 Thread Matthieu Pizenberg
Hi Francisco, just a few words about arrays and image manipulation.

I've been doing some work along this way and encountered multiple issues. 
One of them was with slicing. If I'm not wrong Robin's work will be merged 
in 0.19 but meanwhile, you should be aware that there are few issues with 
the current arrays, especially large ones [1]. You can already use his 
library as a drop-in replacement though.

I was also about to mention the numelm project but I think you know about 
it ^^. Regarding those kind of operations (slicing, transposing, ...) I 
think a generic image (/tensor) type would benefit a lot from having lazy 
"views" [2] and expressions of matrices as explained in the xtensor [3] 
project I mentionned in your numelm post.

Cheers and good luck for this amazing project!

[1] elm 0.18 array issues : https://github.com/elm-lang/core/issues/649
[2] lazy views at 12:30 : https://youtu.be/mwIQUgigjbE?t=12m30s
[3] https://github.com/QuantStack/xtensor

-- 
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: Discovering Elm packages

2017-08-20 Thread Matthieu Pizenberg
Wow, that's awesome! when are your next holidays? ^^

On Wednesday, August 9, 2017 at 10:37:40 AM UTC+8, Ryan Rempel wrote:
>
> There are new or updated Elm packages every day.
>
> Well, not quite every day -- there were none on July 30, 2017. Before 
> that, the previous day without any new or updated Elm packages was April 1, 
> 2017. And, before that, you would have to go back to October 2, 2016 to 
> find an empty day. (This is counting a "day" in terms of UTC -- you'd get 
> different results from the point of view of different time zones).
>
> How, you might ask, do I know this? By consulting <
> https://package.frelm.org/recent>
>
> Now, perhaps you're thinking that visiting a web page to find recently 
> published Elm packages is too much effort. How about a Twitter feed? <
> https://twitter.com/frelmorg>
>
> You may also be amazed to learn that there are 2073 distinct module names 
> implemented by published Elm packages. How do I know that? By consulting <
> https://package.frelm.org/module>
>
> This is all a bit of an experiment I've put together on my summer 
> vacation. (I really ought to learn what vacations are for someday). I hope 
> it's a useful supplementary source of information about Elm packages.
>

-- 
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 `reusable views`

2017-08-20 Thread Matthieu Pizenberg
Could the size be left to specify by the css of the user of the library? 
You would need to enable user to give the class name they want for this.

On Thursday, August 3, 2017 at 4:43:21 PM UTC+8, enetsee wrote:
>
> Hi, 
>
> I have been trying to create a `resuable view` following the structure 
> outlined in evanczs `elm-sortable-table` 
>  and other examples, 
> including:
>
>- abadi199s `datetimepicker` 
>
>- thebriticans `elm-autocomplete` 
>
>
> I was attempting the reproduce the range slider from Palantir's 
> BlueprintJS component library (example here 
> ). My 
> Elm version is here , with a live 
> version in Ellie here . 
>
> The Elm version extends the original by allowing the user to specify the 
> scale that should be used. The live demo shows both a linear and 
> logarithmic scale; the latter is particularly useful when asking users to 
> select values which have a heavily skewed distribution (common in finance 
> and insurance).
>
> The main limitation of the Elm version compared with the original is 
> having to specify a fixed width. The react version seems to use `
> clientWidth 
> ` to 
> determine the rendered width of the component and uses that when 
> positioning visual elements. As far as I'm aware there is no way to achieve 
> this with Elm.
>
> I would really appreciate any pointers on my approach, particularly if I 
> have misunderstood the `reusable view` approach, and any ideas on how 
> overcome the fixed width limitation mentioned above.
>
> Thanks,
>
> Michael
>

-- 
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: deprecating packages?

2017-07-06 Thread Matthieu Pizenberg
Hello Raoul, just a few remarks about your post:

This output you show in the first message `Here are some ...`, is this an 
output of the compiler? If so, and if you found it a bit confusing there is 
something awesome you can do. Great error messages in the elm ecosystem are 
important, so there exist a repo 
(https://github.com/elm-lang/error-message-catalog) for that. If you think 
this output is confusing, especially because some packages are not up to 
date, you should make an issue there.

Now regarding those two posts, I'm not sure exactly what you're looking 
for? There is a question mark in you title, but no question in your posts. 
Are you looking for help to choose a package? wanting to make a point about 
possible improvements, or just ranting about something that does not suit 
you? In any case (except the last one ^^) you might want to be a little 
more verbose, because now we are in the unconfortable situation of not 
knowing what to answer.

Best regards,
Matthieu

-- 
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: How to manage long running computations in Elm?

2017-06-13 Thread Matthieu Pizenberg

>
> One thing that I think I would have tried in this case, it to delegate the 
> long running computation to a webworker 
> , and then talk with it through 
> a port.


I'm not from the web community. I had bases in html+css+js, but pretty much 
had to relearn my JS when started to try elm, so I've never used web 
workers before. Not sure I'd like to take some time to learn how it works.

On Wednesday, June 14, 2017 at 5:10:30 AM UTC+8, Rupert Smith wrote:
>
> Did you try this technique? Its not ideal, but at least it makes it no 
> longer a stopper.
>

Nope, but thanks, I keep the idea in mind. Actually, It wasn't the only 
issue I had since this was mainly image manipulation. The lack of binary 
data type support was also very restricting. Then I didn't want to invest 
too much energy in this. I prefer to wait and see for now, busy with other 
matters. I'm still confident in the fact that elm is a great language and 
evolves slowly but surely. I'm just here a bit too early for some of my 
needs. For the rest, I'm very happy with elm.

-- 
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: The way forward for Elm Arrays

2017-06-12 Thread Matthieu Pizenberg
On Monday, June 12, 2017 at 7:15:59 AM UTC+8, Robin Heggelund Hansen wrote:
>
> I've been doing some thinking on how to improve Arrays in Elm.
>

Thanks alot for this work on an alternative array implementation! It's 
awesome! It's one of some challenges to use elm for my needs (scientific 
programming), with blocking UI on long computation, and handling natively 
some binary data types (eg. for image manipulations).

A few words regarding your questions:

1) Can the benchmarks be improved?
Could there be one example at a very different scale? For example, I'm 
manipulating scientific data for my work which tend to hold many thousands 
values (like images). Would be nice to see how the different 
implementations scale.
>From the results point of view, it's very important to have an idea of the 
standard deviation of statistical results (or box plots, or similar). If a 
value oscilates between 10 and 100, there is no point giving only it's 
mean or median value.

2) Are people getting similar results as I have?
Not tested yet but starred your repo to come back later. I've been pausing 
my elm coding lately.

3) Has anyone encountered performance issues with lists, and if so, do you 
have an example?
No, not for typical small size lists used here and there.

4) Have you been confused by Lists and Arrays? What could be improved to 
reduce that confusion?
No, but I've been needing to do some gymnastic between lists, arrays and 
dicts for different features specific to each. 

-- 
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: How to manage long running computations in Elm?

2017-06-12 Thread Matthieu Pizenberg
On Wednesday, June 7, 2017 at 4:08:37 PM UTC+8, Rupert Smith wrote:
>
> On Tuesday, June 6, 2017 at 3:20:42 PM UTC+1, Rupert Smith wrote:
>>
>> The problem with long running computations in a single threaded UI is 
>> that they may cause the UI to block and become unresponsive for a period. 
>> Definitely not an acceptable user experience.
>>
>
Yep, totally agree with you. I also would love to be able to run some 
scientific computation, but the UI blocking is a stopper. 

-- 
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: Best practices to create examples for an elm package?

2017-05-08 Thread Matthieu Pizenberg

>
> - Use elm-doc-test for examples whereever possible
> - If you have views, use elm-html-test.
>

Thanks Noah, I didn't know about those for lack of using tests. Thank you 
everyone for your feedback. So if I sum up, the main ideas are:

1. Keep in sync doc examples by using doc tests.
2. For more advanced examples, use a dedicated `elm-package.json` to avoid 
unnecessary package dependencies and integrate them in a test suite.

-- 
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: Missing json decoding tool to decode multitouch events cleanly

2017-05-08 Thread Matthieu Pizenberg
On Monday, May 8, 2017 at 11:36:13 PM UTC+8, Erik Lott wrote:
>
> Yeah, I think you spotted my bad logic. You're talking about functions 
> like this, right?
>

Yep that was it :) 

-- 
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] Announce: new package (elm-mouse-events), major update (elm-touch-events)

2017-05-08 Thread Matthieu Pizenberg
Hi all,

Since I often need coordinates of mouse events and was getting tired of 
recoding the
json encoders / decoders for each project, I made a package for this: 
mpizenberg/elm-mouse-events 
.

The main differences from mbr/elm-mouse-events 
 are:
- mbr's is better fit to handle mouse "behaviors" like click, double click, 
... while I'm focused on the three main events (down, move, up).
- mbr's provides client, and target positions. I chose to provide client, 
offset positions and the movement since those better fit my usage.
- I also provides the status of the alt, ctrl and shift keys.

In the meantime, after multiple months of usage of my elm-touch-events 
package, and feedback from Ian (thanks) I rewrote completely the package. 
The new API is much simpler than previously and more intuitive, I hope.

The main difference with knledg/touch-events 
 is that 
mpizenberg/elm-touch-events 
 
supports multitouch interactions.

Don't hesitate to give me feedback on any of those two here, through slack 
(user mattpiz) or github issues.
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] Best practices to create examples for an elm package?

2017-05-07 Thread Matthieu Pizenberg
Exploring a bit the packages repository, I've come accross the following 
options:

1. no examples/ dir, all in readme and documentation. 
(elm-array-exploration, ...)
2. examples/ dir with nothing more than `.elm` files (elm-decode-pipeline, 
elm-monocle, ...)
3. examples/ dir with an `elm-package.json` file (elm-transducers, ...)
4. examples/ dir with a `package.json` node builder (elm-kinto, ...)

I personally have a mix of (2) and (3). However I feel like they all have 
issues.

1. Sometimes, having a "ready to build" example is useful.
2. It relies on building from the root directory of the package (where the 
`elm-package.json` file lives). It also means that the example file can 
"cheat" by accessing non exposed modules.
3. If you add your `src/` dir in the json, then you can also "cheat" like 
in 2. If you do not, and you use your package as if it was loaded from elm 
packages, then you cannot verify that your latest modifications (not pushed 
yet) are working with your examples.
4. Well, it's a bit too heavy of a machinery most of the times. Plus it 
also requires an `elm-package.json` file anyway so the same issues as (2) 
and (3) apply.

*Do you think there is a best practice? Are there alternatives to those 
four?*

-- 
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] ADL: possible language for serialization

2017-05-07 Thread Matthieu Pizenberg
I've no idea if the name picked was done purposely but the purpose looks 
similar to ADL 
(https://en.wikipedia.org/wiki/Architecture_description_language). This 
language is used as a modeling language to create and manipulate systems. 
If I remember well, we used it in software engineering course in a pipeline 
to transform language to other languages. That was just to point at the 
coincidence, I'm not an Haskell user, so I can't really know if they are 
related in some way.

On Monday, May 8, 2017 at 7:34:10 AM UTC+8, Witold Szczerba wrote:
>
> I like the idea, but without a strong community support to provide 
> bindings for many languages, it can just... fail, I guess. I'm wondering 
> what my colleagues would tell, will show our them tomorrow. 
>
> 08.05.2017 00:55 "Joey Eremondi" > 
> napisał(a):
>
>> I saw this on the Haskell Reddit and thought it looked interesting for 
>> Elm:
>>
>> https://github.com/timbod7/adl
>>
>>
>> "A framework for building cross language data models. It consists of a 
>> DSL for describing data types, code generators for several target 
>> languages, and runtimes for these languages."
>>
>> This could help with sharing data types between the front-end and backend 
>> of a web app, as well as with automatically generating JSON Encoders and 
>> Decoders.
>>
>> Thoughts?
>>
>> -- 
>> 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] Re: Linear algebra for 2d geometry?

2017-05-04 Thread Matthieu Pizenberg
I definitely recommend looking at https://github.com/opensolid/geometry 
(with it's svg counterpart : https://github.com/opensolid/svg).
I've been using it a bit and it's awesome for what I understand you want.

I've been using eeue56/elm-flat-matrix also but for more "raster" drawings 
than "vectorial" stuff. One issue though is that it is based on the elm 
core array implementation, which is flawed 
.


On Thursday, May 4, 2017 at 9:58:46 PM UTC+8, Rupert Smith wrote:
>
> On Thursday, May 4, 2017 at 2:56:05 PM UTC+1, Rupert Smith wrote:
>>
>> I need to implement some 2d geometry transformations, and would like to 
>> use 3x3 matrices for this. Does anyone have some experience or recommend 
>> one library over another? I don't really need maximum performance at this 
>> stage, the drawing I am rendering will be relatively static and not consist 
>> of a huge number of parts. The output will be SVG.
>>
>
> In the future I might need things algorithms like overlap/collision 
> detection, convex hull, and 2d graph layouts. I don't know if any of these 
> things have libraries but if they do, and are based on the same underlying 
> vector representation as the basic 2d linear algebra, that might help too. 
>

-- 
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: Charty: SVG charts library (feedback request)

2017-05-02 Thread Matthieu Pizenberg
Hi Juan,

I just checked the demo app and the two plots there look great. But what is 
it in elm-plot 
 or 
elm-visualization 
 
(to cite the two most known elm libraries for plots) that you felt was 
missing to start a new chart lib? Or did you know about these ?

On Sunday, April 23, 2017 at 3:04:24 AM UTC+8, Juan Edi wrote:
>
> Hello everyone,
>
> Today I released a library to generate SVG markup for charts.
>
> It certainly worked for my particular use case but I'd love to hear if it 
> works for you or if I'm missing something.
> There is still work to do regarding API design and features, but I thought 
> I'd better release soon and get some feedback from all of you.
>
> Docs: http://package.elm-lang.org/packages/juanedi/charty/latest
> Repo: https://github.com/juanedi/charty
> Demo: https://juanedi.github.io/charty/
>
> 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: Elm "missing library / I was blocked by ..." scoreboard?

2017-05-02 Thread Matthieu Pizenberg
It looks a lot like something that could be done on reddit from the images 
I've seen on this website. I've no idea how reddit works though, I'm not a 
user. Could this be done with some kind of reddit channel or subreddit or 
whatever ?

Another option I see, is someone doing *some kind of a "state of the rant"*. 
It is definitely a huge work but it is something we do in research when 
publishing a research article. It always starts with a *"state of the art"*. 
The idea here would be to collect all the most represented issues here and 
there all over the discussion list, slack, reddit, blog posts, etc, and 
make a coherent summary of all this. (Anyone working in natural language 
analysis with machine learning in here? ^^). It could be immensely valuable 
to start working on improvements.

But maybe first, we could all participate in the creation of one document 
with pointers to all theses resources related to each issue. Any idea on 
what shared community writable medium would best fit this task? (feel like 
a simple google doc could do it but could also get out of control). Maybe 
this could also be done in reddit?


On Wednesday, April 12, 2017 at 6:57:51 PM UTC+8, Martin Janiczek wrote:
>
> Would it be a good idea to create Elm "scoreboard" at canny.io or 
> something similar? (See https://react-native.canny.io/feature-requests 
> for example)
>
> Seeing Twitter @elmlang mentions like: "It's sad that we lack touch 
> subscription support on @elmlang", it seems to me that we could aggregate 
> these on the canny.io page and in some time see what are the biggest 
> pains (ie. touch events / web audio / window scroll subscriptions / ...)
>
> On Slack it has been noted that GitHub issues could serve the same 
> purpose, although it lacks the UI (sort by most wanted feature) and from 
> the top of my head I don't know which repo would be good for that. 
> elm-community/something?
>

-- 
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] Linear algebra (matrix, vectors, ...) in the context of image processing

2017-05-02 Thread Matthieu Pizenberg


> I think ultimately Elm could be a great language for working with binary 
> data but it's not there yet.


Indeed ^^. In case you're still interested, I posted there what I did (at 
the end) : 
https://groups.google.com/forum/#!searchin/elm-discuss/pizenberg|sort:relevance/elm-discuss/u_ui3PlDwLc/uLf9yhNjAgAJ
 

-- 
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: Better syntax for nested pattern matching (destructuring)?

2017-03-30 Thread Matthieu Pizenberg

>
> Instead of calling it 'getVar3', I am using names like 'whenWithVar3'. The 
> 'when' part better reflects that the operation will not always produce a 
> result. 'whenWith' is a bit long, perhaps 'whenVar3' might be better?
>

This sounds well also. I've no idea though about conventions that may 
exist. 
 

> But perhaps the 'get' and 'set' conventions are already better established 
> from lenses or monocles?
>

 You got me curious by mentionning lenses and monocles. I looked around for 
existing packages explaining those concepts and found a few interesting. 
Maybe the more versatile, that could be helpful with my nested pattern 
matching issue is elm-monocle 
(http://package.elm-lang.org/packages/arturopala/elm-monocle/latest) from 
arturopala. In particular, the Optional type seems very interesting. I will 
keep it in mind for next time. There is no rush.

-- 
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: Better syntax for nested pattern matching (destructuring)?

2017-03-30 Thread Matthieu Pizenberg

>
> model.study.status
>   |> getProgressingSteps
>   |> Maybe.map Pivot.getCurrent
>   |> Maybe.andThen getScribbles
>   |> Maybe.map (Scribbles.update scribblesMsg model)
>   |> Maybe.withDefault model
> ...
>

 Thank you Aaron, that makes it definitely more readable! Those getters are 
the key (`Maybe` I should go back to code in Java ^^)

-- 
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: Better syntax for nested pattern matching (destructuring)?

2017-03-29 Thread Matthieu Pizenberg

>
> We have found that this pattern is typically a good case for chaining a 
> bunch of andThen statements with a withDefault statement at the end 
> together.  The one thing is you would have to be able to adjust your values 
> to all be Maybes.
>

Yes Christian, I am wondering if people are aware of some more generic 
continuation pattern matching syntax. The andThen expression is very useful 
for monadic types like Maybe. (sorry for the M term use ^^ but it seemed 
appropiate even if I'm not into category theory). But in my exemples, I'm 
using Union types that are not Maybes. I guess what I could do is create my 
own "andThenX" like this:

f1 : Var1 -> Type2
f2 : Var2 -> Type3
...

Type Type2
= DataType2 Var2
| ...

Type Type3
= DataType3 Var3
| ...

andThen2 : (Var2 -> a) -> Type2 -> Maybe a
andThen2 f2 type2 =
case type2 of
DataType2 var2 ->
Just (f2 var2)
_ ->
Nothing

andThen3 : (Var3 -> a) -> Type3 -> Maybe a
andThen3 f3 type3 =
case type3 of
DataType3 var3 ->
Just (f3 var3)
_ ->
Nothing
...

And then (no pun intended ^^) do something like:

f1 var1
|> andThen2 f2
|> andThen (andThen3 f3)
|> ...
|> andThen (andThenN fN)
|> withDefault otherwise

This has the advantage of having a clear flow, but the inconvenient that I 
need to write the my special andThenX functions.
What do you think of this approach? 

-- 
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] Better syntax for nested pattern matching (destructuring)?

2017-03-29 Thread Matthieu Pizenberg
Multiple times in my projects, I happen to need nested pattern matching.
Below is a raw extract of code (in an update) showing this need.

Study.ScribblesMsg scribblesMsg ->
case model.study.status of
Study.Progressing steps ->
case Pivot.getC steps of
Study.ScribblesStep ( imageUrl, scribbles ) ->
( Scribbles.update scribblesMsg model scribbles
, Cmd.none
)

_ ->
( model, Cmd.none )

_ ->
( model, Cmd.none )

Basically, this is a specific case of a generic following code:

case f1 var1 of
DataType2 var2 ->
...
case fn varn of
finalVar ->
doSomethingOf finalVar
_ ->
otherwise
...
 _ ->
otherwise

Do you think there could exist a syntax enabling better handling of such a 
case?
Have you encountered one in another langage maybe?

-- 
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: Post Examples of Painful Record Updates Here!

2017-03-22 Thread Matthieu Pizenberg
Here is a somewhat painful record update:

setImage : String -> String -> Image -> Model -> Model
setImage tool url image model =
let
mapping =
case tool of
"rectangle" ->
.rectangle model.resourcesMapping

"outline" ->
.outline model.resourcesMapping

"scribbles" ->
.scribbles model.resourcesMapping

_ ->
Dict.empty

id =
Dict.get url mapping
|> Maybe.withDefault -1

config =
model.config

newConfig =
case tool of
"rectangle" ->
{ config | rectangle = Dict.insert id (NoGT url image) 
config.rectangle }

"outline" ->
{ config | outline = Dict.insert id (NoGT url image) 
config.outline }

"scribbles" ->
{ config | scribbles = Dict.insert id (NoGT url image) 
config.scribbles }

_ ->
config
in
{ model | config = newConfig }


On Friday, March 3, 2017 at 2:12:39 PM UTC+8, Richard Feldman wrote:
>
> There have been various discussions of potential ways to improve Elm's 
> record update syntax. Evan commented that "(examples > design work) at this 
> point" - any potential designs for syntax improvements would need to be run 
> through a gauntlet of examples to see how well they'd work, so the first 
> step in the process is to gather those examples.
>
> So let's collect a ton of different real-world examples! That will help 
> guide the design process.
>
> If you've run into a record update that you felt was painful and could be 
> improved in some way, please post it here! (Also, *please keep this 
> thread for posting of examples* *only* - it'll be easier to link back 
> here during design discussions if we can reference a clean thread of 
> examples, as opposed to a mismash of examples interleaved with suggestions.)
>

-- 
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-package install doing nothing?

2017-03-17 Thread Matthieu Pizenberg
Oups sorry for the noise discussion thread.
A wrong copy paste and my version specified for elm-navigation was too old 
(1.0.1 instead of 2.1.0). This was causing elm-package to do nothing.

On Friday, March 17, 2017 at 3:34:26 PM UTC+8, Matthieu Pizenberg wrote:
>
> Hi, did something like this already happened to you?
>
> My elm-package.json :
>
> {
> ...
> "dependencies": {
> "elm-lang/core": "5.1.1 <= v < 6.0.0",
> "elm-lang/html": "2.0.0 <= v < 3.0.0",
> "elm-lang/window": "1.0.1 <= v < 2.0.0",
> "elm-lang/navigation": "1.0.1 <= v < 2.0.0"
> },
> "elm-version": "0.18.0 <= v < 0.19.0"
> }
>
> When I remove elm-stuff and use the command: elm-package install, it does 
> nothing
>
> $ elm-package install
> Packages configured successfully!
>
> But elm-stuff/packages is empty and nothing get installed. I don't see 
> what could possibly be wrong since last night when it was working ...
>

-- 
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-package install doing nothing?

2017-03-17 Thread Matthieu Pizenberg
Hi, did something like this already happened to you?

My elm-package.json :

{
...
"dependencies": {
"elm-lang/core": "5.1.1 <= v < 6.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0",
"elm-lang/window": "1.0.1 <= v < 2.0.0",
"elm-lang/navigation": "1.0.1 <= v < 2.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}

When I remove elm-stuff and use the command: elm-package install, it does 
nothing

$ elm-package install
Packages configured successfully!

But elm-stuff/packages is empty and nothing get installed. I don't see what 
could possibly be wrong since last night when it was working ...

-- 
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] Uncaught TypeError with a value obtained from a decoder

2017-03-14 Thread Matthieu Pizenberg

>
> Looks like you hit on this issue:
> https://github.com/elm-lang/core/issues/444
>

Seems to be the case indeed. 
 

> Have you tried switching to a different implementation? 
> http://package.elm-lang.org/packages/Skinney/elm-array-exploration/2.0.2
>

Not yet, thanks for the advice, I will try another implementation.

-- 
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] Uncaught TypeError with a value obtained from a decoder

2017-03-14 Thread Matthieu Pizenberg
Thanks Peter,
After a long process of reducing the code, it came down to (in REPL):

> Array.append (Array.repeat 993 False) (Array.repeat 1 True)
TypeError: Cannot read property 'length' of undefined

Whereas with 992 instead of 993, it works fine. Should I report this as an 
issue?

-- 
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] Uncaught TypeError with a value obtained from a decoder

2017-03-14 Thread Matthieu Pizenberg
Hi, this morning I got into a weird bug with a value obtained from a 
decoder. I got elm code compiling but runtime error.
I have this inside an update:

let
groundtruth : Maybe RLE
groundtruth =
Decode.decodeString RLE.decode rleString
|> Result.toMaybe

-- The problem appears when I add this code:
groundtruthMatrix : Maybe (Matrix Bool)
groundtruthMatrix =
groundtruth
|> Maybe.map RLE.toMatrix
in
( { model | groundtruth = groundtruth }
, Cmd.none
)

where the signature of RLE.toMatrix is:

-- Convert a RLE image to a Matrix.
toMatrix : RLE -> Matrix Bool

and this fonction is working (according to manual tests in REPL).

The error I get when adding the groundthruthMatrix definition is in 
chromium:

main.js:790 Uncaught TypeError: Cannot read property 'length' of undefined
at calcToRemove (main.js:790)
at Function.append [as func] (main.js:683)
at A2 (main.js:92)
at main.js:16660
at main.js:7
at Function.func (main.js:8581)
at A2 (main.js:92)
at indexedMap_ (main.js:498)
at indexedMap_ (main.js:499)
at Function.indexedMap [as func] (main.js:480)

calcToRemove @ main.js:790
append @ main.js:683
A2 @ main.js:92
(anonymous) @ main.js:16660
(anonymous) @ main.js:7
(anonymous) @ main.js:8581
A2 @ main.js:92
indexedMap_ @ main.js:498
indexedMap_ @ main.js:499
indexedMap @ main.js:480
A2 @ main.js:92
(anonymous) @ main.js:8577
(anonymous) @ main.js:7
A3 @ main.js:99
_mpizenberg$elm_image_annotation$RLE$toMatrix @ main.js:16656
(anonymous) @ main.js:16776
(anonymous) @ main.js:1887
A2 @ main.js:92
(anonymous) @ main.js:16772
A2 @ main.js:92
(anonymous) @ main.js:3439
step @ main.js:4074
work @ main.js:4132

Do you think there is a way to correct this issue?

-- 
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: elm + reactive programming

2017-03-10 Thread Matthieu Pizenberg


> Let's consider throttling.
> ...
>
 
What you are describing here Mark is almost exactly what I implemented in 
mpizenberg/elm-debounce [1]. I have no experience in observables and 
unfortunately, do not know yet about effect managers so it is done with 
messages. I agree that it has been painful, especially at the beginning. 
But after many iterations, I think I got something working well and 
relatively well designed (but that is not for me to judge).

[1] http://package.elm-lang.org/packages/mpizenberg/elm-debounce/latest 

-- 
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: What about partial public exposition of private types?

2017-03-10 Thread Matthieu Pizenberg

>
> Did calling the type and its alias both 'Test' somehow override the 
> private one with the public one?
>

No actually it is misleading you here. The main difference is that when I 
write:

-- module Test exposing (testFunction)
import Public exposing (Test)
import Private
testFunction : Test
testFunction = Private.SomeTest

`Test` in `testFunction` type definition refers to `Public.Test`. It is the 
same as writing:

-- module Test exposing (testFunction)
import Public
import Private
testFunction : Public.Test
testFunction = Private.SomeTest

whereas everywhere in elm-style-animation, mdgriffith is defining its 
functions with the `Animation.Model.Animation msg` return type instead of 
using the `State` public type:

initialState : List Animation.Model.Property -> Animation msg

Technically both types are the same (well not exactly since he defined 
State as Animation *Never*) and both could compile (not here because of 
this Never). But for public interface, I think that type definitions should 
use the public types.

-- 
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: What about partial public exposition of private types?

2017-03-09 Thread Matthieu Pizenberg

>
> So I think a type becomes opaque if its constructors are not exposed, or 
> if its module is not exposed.
> It might be better in that case, if the compiler just referred to the 
> opaque type as Animation.State?
>
 
Actually, the compiler can do that. I just checked and figured that it was 
a design choice from mdgriffith. I have made this simple example:

-- module Private exposing (..)
type Test = SomeTest | OtherTest

-- module Public exposing (Test)
import Private
type alias Test = Private.Test

-- module Test exposing (testFunction)
import Public exposing (Test)
import Private
testFunction : Test
testFunction = Private.SomeTest

In that case, both the documentation and the compiler refers the return 
type of testFunction to be Public.test.

One way you can create a partially exposed type is like this:
>
> module Test exposing (Test(One))
>
> type Test
> = One
> | Two
>

 Thanks, it wasn't the kind of "partial" exposure I had in mind but good to 
know in case I have this kind of need some time.

-- 
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: What about partial public exposition of private types?

2017-03-09 Thread Matthieu Pizenberg

>
> However, as the constructor for Animation is exposed by its module, I am 
> not prevented from deconstructing it or pattern matching against it.
>

Hmm, I tried to do this but got errors as I thought:

Cannot find pattern `Animation`
6| f (Animation { steps, running }) =
  

Could you explain how you can abuse this by destructuring or similar?

-- 
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] Recent Mozilla Tech announcement regarding Web Assembly

2017-03-08 Thread Matthieu Pizenberg

>
> There's a GSoC project suggestion on this at 
> https://github.com/elm-lang/projects#explore-webassembly - otherwise, I 
> think that's as far along as planning has gone. If you're a student and 
> interested, you might apply to take it on! :D
>

Technically I am, but far too busy with my PhD because of "loosing" time 
with elm instead matlabing ^^. But hey YOU student reading this with time 
this summer, your duty calls :)

-- 
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] Recent Mozilla Tech announcement regarding Web Assembly

2017-03-08 Thread Matthieu Pizenberg
Hey everyone, today is a very good day (as any Elm coding day ^^).

Mozilla Tech just made an article : Why WebAssembly is a game changer for 
the web — and a source of pride for Mozilla and Firefox 
.
 
Check it out.
They have also published few interresting videos on their youtube account 
.

This makes me wonder. Are there any plans regarding Elm and Web Assembly 
being drawn or is it still too early?

-- 
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] What about partial public exposition of private types?

2017-03-06 Thread Matthieu Pizenberg
Hi everyone,

I would like to have the point of view of the community regarding some 
private/public types code organisation. I have some types very useful to 
many sub modules that are currently publicly exposed in a Types module. In 
order to hide the type implementation, I wonder what you think of a module 
organization like below:

-- Private/Types.elm
module Private.Types exposing (Point2d(Point2d))
type Point2d = Point2d (Float, Float)

-- Public/Types.elm
module Public.Types exposing (Point2d)
import Private.Types exposing (Point2d)

-- Point2d.elm
module Point2d exposing (fromCoordinates)
import Private.Types exposing (..)
fromCoordinates : (Float, Float) -> Point2d

The Public.Types would act as a "symbolic" link to the equivalent private 
types without exposing the type constructors. However I wonder if it means 
that fromCoordinates is returning a non exposed private Point2d type or if 
the linkage to the equivalent public type is effective. Is this considered 
bad practice, and/or potentially forbidden in future version of elm?

-- 
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] Linear algebra (matrix, vectors, ...) in the context of image processing

2017-03-04 Thread Matthieu Pizenberg
Thanks Ian for the link. I will keep this work in mind though I don't think
I could use it for my current project. It seems focused on rgbd matrix data
type which is great for transparent dynamic graphics. Svg representation
does really suits my needs for now since I'm visualizing non changing data
(or rarely, or path/polygon types of data) in changing frame (zooming,
moving, etc). So svg transformations are the only thing to change, no
canvas recomputation.

For my image binary masks representation, I just stumbled upon Noah's
elm-flat-matrix
 lib
which feels very interesting. The only thing a bit weird for matrix
manipulation is the row-major implementation and notation (first index
refers to column). This makes sense in the context of image manipulation
though (with x corresponding to the width, being always the first
coordinate).

Regarding the transformation of the image file to matrix data, I feel like
I have no other choice than to do it in JS. I found some interesting
example of how to deal with this in the jimp

lib code. Since I can't escape JS for now, I might also try to visualize
the binary masks with ports. The idea being that I create a dedicated
tag+id in the elm view code. Pass the data and the id of the tag in which
JS should include the visualization by generating the data uri to put in
the dedicated tag. (hoping following elm view updates will not change this
tag if no reason to - maybe by using html keyed ?).

If anyone thinks I'm heading for a fall, please tell me.

PS: Ian your OpenSolid repositories rock. I just switched to it instead of
my previous home made solutions. I might have propositions also for an
addition into the the Polygon2d and LineSegment2d modules but that's
another story.

On Mar 3, 2017 20:54, "Ian Mackenzie"  wrote:

For your second question, I know there's work being done currently on
supporting the Canvas API in Elm (https://github.com/elm-community/canvas),
which may be more appropriate for visualizing bitmap data than SVG, but
it's still very experimental.

--
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/to
pic/elm-discuss/BbPBd8Rq2Pw/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: Post Examples of Painful Record Updates Here!

2017-03-03 Thread Matthieu Pizenberg
Hi Antoine, just to let you know that you could write:

( { model | mode =
case model.mode of
Drawing (Just shape) ->
Drawing <| Just <| Shapes.setID id shape

_ ->
model.mode
  }
, Cmd.none
)

Nested pattern matching is allowed for many constructions. Though I usually 
prefer having a clear return value, and define intermediate values like:

let
newMode =
case model.mode of
Drawing (Just shape) ->
Drawing <| Just <| Shapes.setID id shape

_ ->
model.mode
in
( { model | mode = newMode }
, Cmd.none
)

Which is still verbose but because of code logic, not record syntax IMHO.

-- 
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] Linear algebra (matrix, vectors, ...) in the context of image processing

2017-03-02 Thread Matthieu Pizenberg
I'm currently looking for a library to do some basic image processing and 
matrix manipulation stuff.

I have a research background (mostly spending time in Matlab), and 
currently preparing a user study. Elm has been great for my needs so far, 
but I'm encountering now a few obstacles.

Types and functions regarding the manipulations I might need could be:
* Binary image mask ~> could be some kind of Matrix/Array Bool
* Boolean mask operations (And, Or, ...) ~> I guess if using a _ Bool data 
structure, this is not complicated
* Mask generation from simple polygons
* etc.

The second issue, is the visualization of these masks/images. Until now, I 
was only dealing with raw png images, and polygons. So the obvious choice 
of representation was SVG. Now I'd also like to visualize those masks (that 
would be computed in some form of matrix data type). I do not know of a 
trivial way to do this in svg?

Finally, I wonder how to retrieve those (binary mask or not) images and 
transform them in a more computing-friendly data type (kind of imread in 
Matlab). Since I don't think Elm is able to manipulate byte data types, 
this doesn't seem trivial to me.

Any thought regarding these problematics?

-- 
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: 0.18 Chaining Http requests

2017-02-06 Thread Matthieu Pizenberg
Hi Kingsley,

Regarding point 2, the Http.send 
 
function enables you to create Cmd messages from http requests, and as you 
mentionned, Cmd.batch 
 
can group any Cmd messages together. Order of treatment of these commands 
however is not guaranted in my understanding.

Regarding point 1, if these are async (like http requests) my feelings are 
that you have no other choice than using the update function. This is 
because you need an effect manager for this. I guess you could also make 
your own effect manager but this seems to be something that is not 
encouraged in the community, and not documented.
If you go the task way, the key functions are:
toTask : Request a -> Task Error a
andThen : (a -> Task x b) -> Task x a -> Task x b
attempt : (Result x a -> msg) -> Task x a -> Cmd msg
So you can chain your tasks with andThen, and finally once the "big" 
chained task is complete, create a command message with attempt.

This said, if your purpose is dealing with navigation, don't hesitate to 
look at those two interesting articles from Wouter :
https://medium.com/elm-shorts/more-on-spa-navigation-in-elm-31a066c6b9ae#.fnu1ejfzk
https://medium.com/elm-shorts/choosing-the-right-elm-spa-architecture-d6e8275f6899#.qk45rxw8n

Happy coding,
Matthieu


On Sunday, February 5, 2017 at 8:51:03 PM UTC+1, Kingsley Hendrickse wrote:
>
> Hi, 
>
> I've just started learning Elm and am using version 0.18.
>
> I want to do 2 things:
>
> 1. Make an http get and use the result to make another get request
> 2. Make 3 http requests (I don't mind whether they happen concurrently or 
> one after the other)
>
> Anyway after googling I found that in the previous version of Elm the Http 
> operations were done using Tasks. So on Task there was an andThen which 
> could be used.
>
> But in 0.18 it seems the new way of doing things is with Http send - but I 
> don't see how I can chain Http requests using the new send mechanism. It 
> also seems that in the 0.17 version you could 
> process the result inline but in 0.18 you have to use the update 
> mechanism. But that would suggest I would need to do a single http request 
> using send and capture the result in the update and then fire off another 
> send from the update - and catch it's result in the update again. Is that 
> how I should chain http requests in 0.18? 
>
> I like how Cmd.batch can take a list of Cmd's to run - it would be nice if 
> there was an equivalent for doing Http requests.
>
> Any pointers would be appreciated
>
> --Kingsley
>

-- 
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: Emphasizing /r/elm more

2017-01-27 Thread Matthieu Pizenberg
Yep he definitely should evan-gelize more. ... (OK I'm out)

On Jan 27, 2017 19:46, "Duane Johnson"  wrote:


On Fri, Jan 27, 2017 at 10:52 AM, Rex van der Spuy 
wrote:

> And, I hope he always remains the sole maintainer and developer of the
> language, because, frankly, I just don't trust anyone else :)
>

Gosh, I hope not, because that would mean he failed to teach anyone else
how to replicate Elm's leadership success.

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


Re: [elm-discuss] State of Elm Survey 2017 is live

2017-01-18 Thread Matthieu Pizenberg
Hey, I just participated in the survey :)
A few remarks before forgetting:
- I am not sure large scale notations (0->10) with only indications of what 
the 2 ends are, are a good thing in surveys. 0 to 3 is very often enough 
(not at all / small / medium / high )
- The question "What is your level of influence within your team?" may not 
apply to everyone. I am currently a PhD student in image processing, so I 
can't really say "let's use elm" ^^. The same would apply to people working 
alone as freelancers.

On Wednesday, January 18, 2017 at 9:15:35 PM UTC+1, Brian Hicks wrote:
>
> You're right that there are a large number of people using Elm for side 
> projects. I'm still interested in their professional experiences. We want 
> to reduce the activation energy to go from hobby to production.
>
> There are about a hundred responses so far! Keep them coming!
>
> Also for those curious, here are the results from last year: 
> https://www.brianthicks.com/post/2016/04/22/state-of-elm-2016-results/ Forgot 
> to include that before!
>
> On Jan 18, 2017, 1:57 PM -0600, Martin DeMello  >, wrote:
>
> the survey seemed overly focused on people whose day job was web 
> development. i'm guessing a significant fraction of the elm community are 
> people developing side projects. 
>
> martin
>
>

-- 
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: Emphasizing /r/elm more

2017-01-18 Thread Matthieu Pizenberg
Cool! it will provide first insights of/for the community I hope. However, 
if we really want to understand how the community should evolve, I think 
that another, more detailed survey on this specific matter will be needed 
at some point.

On Wednesday, January 18, 2017 at 3:52:15 PM UTC+1, Brian Hicks wrote:
>
> This will be part of the State of Elm survey. It goes live this week, and 
> I'll post a new thread here when it does. It doesn't go into quite as much 
> detail as your post because we're already pushing the length limit. That 
> said, this is what I've got for this: 
>
> *Which of the following do you read / contribute to?*
>
> - Elm Slack
> - elm-discuss mailing list
> - elm-dev mailing list
> - Twitter discussions
> - Facebook groups
> - Elm subreddit
> - Elm weekly newsletter
> - Elm town podcast
>
>
> On Jan 18, 2017, 8:19 AM -0600, Matthieu Pizenberg  >, wrote:
>
> Hi again, since this is not the first time that this matter is discussed, 
> and since this time Evan launched it, it means that it is an important 
> matter for the community and it's going to evolve anytime soon ^^. So, 
> instead of discussing it here with passion and obvious bias since we are on 
> the mailing list, what would you think of asking the questions to all the 
> community in a more objective way?
>
> What I think of is for example a google form like the one below, that 
> would be accessible from all the community entry points (slack, reddit, 
> mailing list, ...). Please tell if you like the idea, or not. (sorry for 
> the long post XD)
>
>
> # Community Checkpoint Form
>
> --- PROFILE
>
> What is your experience with elm ?
>  - New here
>  - Not so much experience (1-2 completed projects)
>  - Start feeling confident (understand most of it, multiple successful 
> projects)
>  - Total expert (yeah I even master effect managers, native code, etc.)
>
> Are you familiar with functional programming?
>  - What is that?
>  - I know the basics
>  - Yes I use it regurlarly
>  - Peace of cake, I'm currently doing a PhD on homotopy type theory for 
> functional programming
>
> --- COMMUNITY
>
> Some description here to introduce the dilemna between Reddit, Google 
> Groups (alias mailing list), and something else dedicated (let's say a 
> Discourse).
>
> Did you know about:
>  o The elm Reddit?
>  o The elm Slack?
>  o The elm discussion group (mailing list)?
>
> Are you currently a Reddit user?
>  - No
>  - Yes, sometimes
>  - Yes, everytime
>
> Are you currently a Google Groups user?
>  - No
>  - Yes, sometimes
>  - Yes, everytime
>
> Are you currently using a Discourse forum?
>  - No
>  - Yes, sometimes
>  - Yes, everytime
>
> Rank your preferences between those:
>  1. elm Reddit
>  1. elm discussion group (mailing list)
>  1. elm Discourse
>
> (If you ranked first Reddit) would you volunteer to help with the 
> moderation?
>  - yes/no
> (If you ranked first the mailing list) would you volunteer to help with 
> the moderation?
>  - yes/no
> (If you ranked first Discourse) would you volunteer to help with the 
> creation, funding of the server, or moderation of this forum?
>  - yes/no
>
> (If you answered yes to one of the previous volunteering questions) please 
> give us details of what you would like to do and a way to contact you in 
> case this might go further:
> 
> ||
> 
>
> Anything you would like to add?
> 
> ||
> 
>
> On Tuesday, January 3, 2017 at 2:51:05 AM UTC+1, Evan wrote: 
>>
>> I recently talked with folks who moderate the various Elm discussion 
>> forums about the challenges that come up and how we can do better. 
>>
>> The short version is: *we should start migrating more discussion 
>> to /r/elm <https://www.reddit.com/r/elm/>.*
>>
>> Now the long version!
>>
>>
>> How Things Are Now
>>
>> Long-form discussion is split between elm-discuss and /r/elm 
>> <https://www.reddit.com/r/elm/>. There are a lot of regulars that spend 
>> more time on elm-discuss, but I think it's fair to say that /r/elm is much 
>> more easily accessible and "public facing" for newcomers. This creates some 
>> problems.
>>
>> Problems with elm-discuss:
>>
>>- Threads are linear, so it's hard for people to branch off into 
>>sub-discussions.
>>- There's no voting mechanism in elm-discuss, so topics are sorted by 
>>"are people posting?" not by "do people care?"
>>

[elm-discuss] Re: POST Http.request in Elm 0.18

2017-01-18 Thread Matthieu Pizenberg
Hi, in case it may be of help, I just did a small test elm project using 
web api which is available at this repo 
.
Basically it was to test a way to use api (and authentified api using JWT) 
that I adapted from a 0.17 tutorial available on the Auth0 website 
.

On Wednesday, January 18, 2017 at 3:22:23 PM UTC+1, bey...@gmail.com wrote:
>
> I'm trying to use elm-lang/http without success so far. I want to address 
> an API with a POST request via JSON. All my efforts so far result in having 
> the wrong headers.
>
> There are two things I've tried in the following: in both cases the server 
> tells me that it wasn't a POST request but OPTIONS.
>
> I've tried using "Http.post":
>
> jsonify : String -> Http.Body
> jsonify str =
> Http.jsonBody <| Encode.object [("sentiment", Encode.string str)]
>
>
> decodeJson : Decode.Decoder String
> decodeJson =
> Decode.map2 (\classification status -> classification)
> (Decode.field "classification" Decode.string)
> (Decode.field "status" Decode.int)
>
>
> fetchSentiment : String -> Cmd Msg
> fetchSentiment sentiment =
> Http.send Fetch (Http.post (jsonify sentiment) decodeJson)
>
> and a custom request:
>
> fetchSentiment : String -> Cmd Msg
> fetchSentiment sentiment =
> Http.send Fetch (postSentiment sentiment decodeJson)
>
> postSentiment : String -> Decode.Decoder String -> Http.Request String
> postSentiment sentiment decoder =
> Http.request
> { method = "POST"
> , headers = [(Http.header "Content-Type" "application/json")]
> , url = "http://127.0.0.1:5000/sentiment";
> , body = (jsonify sentiment)
> , expect = Http.expectJson decoder
> , timeout = Nothing
> , withCredentials = False
> }
>
> Is my problem related to the code above, and if so, how can I fix it?
>
>

-- 
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: Emphasizing /r/elm more

2017-01-18 Thread Matthieu Pizenberg
Hi again, since this is not the first time that this matter is discussed, 
and since this time Evan launched it, it means that it is an important 
matter for the community and it's going to evolve anytime soon ^^. So, 
instead of discussing it here with passion and obvious bias since we are on 
the mailing list, what would you think of asking the questions to all the 
community in a more objective way?

What I think of is for example a google form like the one below, that would 
be accessible from all the community entry points (slack, reddit, mailing 
list, ...). Please tell if you like the idea, or not. (sorry for the long 
post XD)


# Community Checkpoint Form

--- PROFILE

What is your experience with elm ?
 - New here
 - Not so much experience (1-2 completed projects)
 - Start feeling confident (understand most of it, multiple successful 
projects)
 - Total expert (yeah I even master effect managers, native code, etc.)

Are you familiar with functional programming?
 - What is that?
 - I know the basics
 - Yes I use it regurlarly
 - Peace of cake, I'm currently doing a PhD on homotopy type theory for 
functional programming

--- COMMUNITY

Some description here to introduce the dilemna between Reddit, Google 
Groups (alias mailing list), and something else dedicated (let's say a 
Discourse).

Did you know about:
 o The elm Reddit?
 o The elm Slack?
 o The elm discussion group (mailing list)?

Are you currently a Reddit user?
 - No
 - Yes, sometimes
 - Yes, everytime

Are you currently a Google Groups user?
 - No
 - Yes, sometimes
 - Yes, everytime

Are you currently using a Discourse forum?
 - No
 - Yes, sometimes
 - Yes, everytime

Rank your preferences between those:
 1. elm Reddit
 1. elm discussion group (mailing list)
 1. elm Discourse

(If you ranked first Reddit) would you volunteer to help with the 
moderation?
 - yes/no
(If you ranked first the mailing list) would you volunteer to help with the 
moderation?
 - yes/no
(If you ranked first Discourse) would you volunteer to help with the 
creation, funding of the server, or moderation of this forum?
 - yes/no

(If you answered yes to one of the previous volunteering questions) please 
give us details of what you would like to do and a way to contact you in 
case this might go further:

||


Anything you would like to add?

||


On Tuesday, January 3, 2017 at 2:51:05 AM UTC+1, Evan wrote:
>
> I recently talked with folks who moderate the various Elm discussion 
> forums about the challenges that come up and how we can do better.
>
> The short version is: *we should start migrating more discussion 
> to /r/elm .*
>
> Now the long version!
>
>
> How Things Are Now
>
> Long-form discussion is split between elm-discuss and /r/elm 
> . There are a lot of regulars that spend 
> more time on elm-discuss, but I think it's fair to say that /r/elm is much 
> more easily accessible and "public facing" for newcomers. This creates some 
> problems.
>
> Problems with elm-discuss:
>
>- Threads are linear, so it's hard for people to branch off into 
>sub-discussions.
>- There's no voting mechanism in elm-discuss, so topics are sorted by 
>"are people posting?" not by "do people care?"
>- Moderation to avoid spam is more difficult. All new users are 
>moderated by default to avoid those awful spam robots that Google Groups 
>does not catch.
>- It goes to people's already full inboxes. If you change this, you 
>use the online interface, which is not amazing.
>
> Problems from having two long-form forums:
>
>- Lots of valuable expertise *only* lives on elm-discuss. When new 
>folks come to /r/elm, there are not as many folks with as much production 
>experience.
>- Blog posts (frequently shared on /r/elm) miss out on a lot of 
>valuable feedback.
>
>
> How Things Could Be
>
> Right now I'm just suggesting that folks who are regulars here get on 
> /r/elm and see if you like it. I'd like to start by shifting the center of 
> gravity for community discussion.
>
> Longer term though, things could look more like how Rust does it. It seems 
> like /r/rust  is the center of gravity 
> for community discussion. See their sidebar! They moderate content well and 
> have 
> some laughs 
> . 
> (I personally think it's very important for moderators to be active in 
> guiding people towards *friendly* discussion! That's super hard on 
> elm-discuss.)
>
> They also have an interesting approach to answering beginner questions 
> 
>  that 
> I think it'd be good to try out!
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" 

[elm-discuss] Re: Emphasizing /r/elm more

2017-01-17 Thread Matthieu Pizenberg
I would also like to keep something like this group. The fact that every 
one get a chance to be read by the community (without being downvoted or 
just ignored) is very important. A few times in Stack Overflow I have asked 
somewhat hard/specific questions with nobody caring answering it because it 
wasn't popular. I fear that Reddit might be the same. But I'm not a Reddit 
user so I don't know.

Also agree with many elm-discuss arguments given including (but not 
exclusively) :
 - visibility of what I have already read
 - getting emailed when there is an answer in a discussion I'm in
 - real people names 

I strongly feel that the wealth of this discussion group is due to the fact 
that the community likes it, and of course thanks to the great spam 
filtering done for first posts. So encouraging people to change to reddit 
might no be a good idea. If the spam really is a problem, is there a 
mecanism to involve more the community for this control?

In my opinion, the active community here is very useful and I would have 
loved to be redirected here earlier than I was. I only knew about the elm 
slack initially. And may be the same for some newcomers from reddit who 
don't know about this group?

-- 
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 events 2017

2017-01-17 Thread Matthieu Pizenberg

Hi,

Just to say that there is one meetup in Paris tomorrow: 
https://www.meetup.com/Meetup-Elm-Paris/events/236216040/
It seems to be already full though.

There is another one in Amsterdam 1st of February: 
https://www.meetup.com/Elm-Amsterdam/events/236942429/
Kind of a hacking night. 15 spots still available now.


On Friday, January 6, 2017 at 9:08:54 PM UTC+1, Rupert Smith wrote:
>
> On Friday, January 6, 2017 at 5:56:35 PM UTC, Josh Adams wrote:
>>
>> Both of my talks at NDC London in a couple of weeks involve Elm: 
>> http://ndc-london.com/speaker/josh-adams
>>
>
> Just trying to figure out what NDC is about:
>  
> "About NDC
>
> Since its start-up in Oslo 2008, the Norwegian Developers Conference (NDC) 
> quickly became one of Europe`s largest conferences for .NET & Agile 
> development. Today NDC Conferences are 5-day events with 2 days of 
> pre-conference workshops and 3 days of conference sessions."
>
> Is it very agile + .Net focused still? What is the overall theme of this 
> event?
>
>

-- 
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] Feedback on a new package for debouncing and throttling of messages

2016-12-02 Thread Matthieu Pizenberg
Hi all,

I just release a package (mpizenberg/elm-debounce 
) for 
debouncing and throttling of messages. Any feedback would be great!

For the story about why another debouncing and throttling package:
Initially, I wanted to use an already existing package that handle 
throttle. So I tried jinjor/elm-debounce 
 but found 
the interface and usage not intuitive. Then stumbled upon 
bcardiff/elm-debounce 
, which 
I really liked, but did not handle throttling of messages and was not 
updated to 0.18. While helping bcardiff to update to 0.18 (with a PR), and 
creating few issues to discuss the implementation of throttling, I realized 
I wanted to do more than just a few modifications.

So here 
 it is.
It is mostly inspired by the works of bcardiff and jinjor.

-- 
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] Proposed addition for Task package

2016-11-23 Thread Matthieu Pizenberg
Hi, I am on Wouter side on this. As a newcomer, I was not aware of these 
things. I figured out a way to do this sendMsg function (which I called at 
the time msgToCmd ^^) because I needed it at some point. And since it was 
"so convenient" I ended up using it all the time instead of calling the 
appropriate update. Turns out later when the app grew, I had many unsolving 
problems due to this architecture and tried to find a way to order my 
batched cmds since I need few things to happen after others. In sum, update 
when synchrone, only create commands (with functions like sendMsg) when 
asynchrone.

Though I do needed to create this function ^^.

On Tuesday, November 22, 2016 at 10:59:37 PM UTC+8, Charlie Koster wrote:
>
> The log then shows that between the DoStuff message and the DoMore 
>> message, a Tick message comes in.
>>
>
> Well, that's troubling and undermines my assumption. That's for looking 
> into this.
>
> For those skimming through this post, *race conditions are possible when 
> doing something like `*Task.perform (\_ -> GoToLoginPage) (Task.succeed 
> Nothing)`
>
> The fact that we do not agree on this, makes it an interesting discussion 
>> here.
>
> Where do others stand on this?
>
>
> ^^^ 
>

-- 
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] Unpublishing a package

2016-11-21 Thread Matthieu Pizenberg
On Tuesday, November 22, 2016 at 1:52:09 PM UTC+8, Peter Damoc wrote:
>
> On Tue, Nov 22, 2016 at 1:33 AM, Richard Feldman  > wrote:
>
>> There is no unpublish feature, and it's important that there never be one 
>> . :)
>>
>
> What would happen if someone deletes their github repository? Wouldn't the 
> same kind of breakage take place?
>

 Is it what happened to elm-community/elm-function-extra 

?

-- 
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: Open discussion about optimization of code potentially triggered very often (mousemove) ?

2016-11-20 Thread Matthieu Pizenberg
Thank you Nick, indeed it worked. It is far better now :). Though there is
still a minor issue. It is the fact that some applications may become
incorrect if some events are ignored (the ones before view update at next
frame).

Meanwhile, I have been digging a bit and found one quite impressive
debouncing and throttling package [1]. It is based on controlling not the
event listener with the view attributes but controlling the messages after
they have been captured in the update method. It is kind of logic if you
think of debouncing, you will need those events (otherwise there is nothing
to "debounce" ^^).

In sum, the advantages and issues of these methods might be the following:

My method (controlling the view event listener) *advantages* :
 * Complete remove of the events. Can be a relief for the CPU in case of
many events to throttle.
My method (controlling the view event listener) *issues* :
 * Not able to deal with debouncing (since the events do not exist).
 * Possible wrong states created because of ignored events (I guess a work
around could be done here to pass all events that have been ignored also).

Jinjor package method (controlling the events after trigger) *advantages* :
 * Ability to deal with a wider range of message control (debounce,
throttle, manual, etc).
 * No wrong state possible since we can batch process all ignored events
(or just care about the last one).
Jinjor package method (controlling the events after trigger) *issues* :
 * Possible CPU overload ? (if many frequent events need
debouncing/throttle) -> to be checked, maybe computers nowadays are fast
enough for any sane amount of those debouncing mechanics.
 * Possible memory overload ? For big delays the amount of messages to keep
in memory until next debounce/throttle can grow huge. But this is not fair
comparison since it would also be the case in my method if I had to deal
with debouncing. Again, this would have to be checked.


[1] http://package.elm-lang.org/packages/jinjor/elm-debounce/latest


On Nov 21, 2016 08:57, "Nick H"  wrote:

> That actually sounds like it works pretty well. Even though you are
> getting multiple triggers, you are still preventing an enormous volume of
> mousemove updates. (I am assuming the time until reactivation is relatively
> long).
>
> The only thing that I would add is a filter on MoveMsg updates... if
> `active` is already set to False, ignore the MoveMsg update entirely. That
> way you guarantee you aren't triggering multiple calls to Reactivate.
>
>
> On Sun, Nov 20, 2016 at 1:24 AM, Matthieu Pizenberg <
> matthieu.pizenb...@gmail.com> wrote:
>
>> I have been trying something that I think could be shared.
>>
>> Basically I tried to see if it was possible to throttle commands by
>> controlling the event attributes in the view that generate those commands.
>> Well, turns out, not really ^^. The idea was the following:
>>
>> * In the model, have an attribute `active : Boolean` initialized at True
>> (meaning that the event will trigger).
>> * In the `MoveMsg` case of update function, set `active` to False and
>> create a command that will reactivate it later in some time.
>> * In the `Reactivate` case of update, reset `active` to True.
>> * In the view, use `div [on "mousemove" ...] [...]` if active else `div
>> [] [...]`
>>
>> This almost work (so it doesn't ^^). Since mouse events can be triggered
>> more often than the rendering of the view, multiple mousemove events can be
>> triggered before the `[on "mousmove" ...]` is removed.
>> In practice the longer the functon in your mousemove update, the higher
>> are the chance that I got these multiple trigger before deactivation of the
>> listener.
>>
>> --
>> 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 a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/elm-discuss/WSMyDrpPs7s/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.


Re: [elm-discuss] Re: Open discussion about optimization of code potentially triggered very often (mousemove) ?

2016-11-20 Thread Matthieu Pizenberg
I have been trying something that I think could be shared.

Basically I tried to see if it was possible to throttle commands by 
controlling the event attributes in the view that generate those commands. 
Well, turns out, not really ^^. The idea was the following:

* In the model, have an attribute `active : Boolean` initialized at True 
(meaning that the event will trigger).
* In the `MoveMsg` case of update function, set `active` to False and 
create a command that will reactivate it later in some time.
* In the `Reactivate` case of update, reset `active` to True.
* In the view, use `div [on "mousemove" ...] [...]` if active else `div [] 
[...]`

This almost work (so it doesn't ^^). Since mouse events can be triggered 
more often than the rendering of the view, multiple mousemove events can be 
triggered before the `[on "mousmove" ...]` is removed.
In practice the longer the functon in your mousemove update, the higher are 
the chance that I got these multiple trigger before deactivation of the 
listener.

-- 
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: Proposal: Shorter qualified imports

2016-11-19 Thread Matthieu Pizenberg
Hi, I am quite often doing the same thing (plus exposing the main type 
having the same name than the module) like:

import Module.Something as Something exposing (Something)

What I am concerned about is that it would be implicit, and all implicit 
things tend to lead to confusion.


On Sunday, November 20, 2016 at 2:51:42 PM UTC+8, Robin Heggelund Hansen 
wrote:
>
> Note. The `as` keyword would still be necessary for brevity is desired, 
> and for when two modules are imported where the last part of the name is 
> the same.
>
> søndag 20. november 2016 07.50.42 UTC+1 skrev Robin Heggelund Hansen 
> følgende:
>>
>> I mostly try to use qualified imports instead of exposing variables into 
>> my namespace. This leads me to using the `as` keyword often, like this:
>>
>> ```
>> import Module.B as B
>> import Module.C as C
>> {- etc. -}
>> ```
>>
>> In Go, accessing a namespace through the last part of it's name, is 
>> implicit. If that was true of Elm as well, the example above would be the 
>> same as:
>>
>> ```
>> import Module.B
>> import Module.C
>> {- etc. -}
>> ```
>>
>> For me, having this in Elm would remove most of my uses of the `as` 
>> keyword. If my other import proposal was also implemented, import handling 
>> would be simpler, at least for me, without sacrificing readability.
>>
>> What do people think?
>>
>

-- 
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: Open discussion about optimization of code potentially triggered very often (mousemove) ?

2016-11-19 Thread Matthieu Pizenberg
Ok, thanks for the clarification Robin.

On Sun, Nov 20, 2016 at 8:32 AM, Robin Heggelund Hansen <
skinney...@gmail.com> wrote:

> It's specific to the virtual dom. Events are triggered as normal, but the
> code that renders the view is only called with the latest state once per
> frame.
>
>
> lørdag 19. november 2016 15.51.56 UTC+1 skrev Matthieu Pizenberg følgende:
>>
>> Hi everyone,
>>
>> I am currently developing some functionality that get triggered on
>> mousemove. I do not have any speed issue now so I am not trying to optimize
>> things that do not need optimization right now ^^. But this work made me
>> curious about how code is optimized in elm. In this blog post [1]
>> <http://elm-lang.org/blog/blazing-fast-html-round-two> Evan says that
>> Elm uses requestAnimationFrame by default. I wonder what this means. Does
>> this mean that all events are "filtered" to trigger only once per frame ?
>> (for example the mousemove?) or is it specific to virtualdom since this
>> post was about that. If not, what do you think would be a suitable strategy?
>>
>> [1] http://elm-lang.org/blog/blazing-fast-html-round-two
>>
> --
> 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/WSMyDrpPs7s/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] Open discussion about optimization of code potentially triggered very often (mousemove) ?

2016-11-19 Thread Matthieu Pizenberg
Hi everyone,

I am currently developing some functionality that get triggered on 
mousemove. I do not have any speed issue now so I am not trying to optimize 
things that do not need optimization right now ^^. But this work made me 
curious about how code is optimized in elm. In this blog post [1] 
 Evan says that Elm 
uses requestAnimationFrame by default. I wonder what this means. Does this 
mean that all events are "filtered" to trigger only once per frame ? (for 
example the mousemove?) or is it specific to virtualdom since this post was 
about that. If not, what do you think would be a suitable strategy?

[1] http://elm-lang.org/blog/blazing-fast-html-round-two

-- 
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] Possible compiler bug while parsing type annotation in a let ?

2016-11-11 Thread Matthieu Pizenberg
Oh cool, thank you for the info, I will just comment it for now then.

On Friday, November 11, 2016 at 5:09:31 PM UTC+8, Janis Voigtländer wrote:
>
> What you encountered is 
> https://github.com/elm-lang/elm-compiler/issues/1214, and it is fixed in 
> version 0.18 of the compiler.
>

-- 
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: Gestures in Elm

2016-11-11 Thread Matthieu Pizenberg
Hi, m.hag... ;)
Just to say that I am with you and would love to have support of these also.
As maybe a small step I wrote recently a slightly more complete library 
 
handling also multitouch events, not only single touches.
You can retrieve clientX and clientY of all touches in the attributes 
touches, targetTouches and changedTouches. This could (theoretically) allow 
to process the touches and recognize some gestures, but thats not marginal 
work ...
Unfortunately, it does not support gesture yet, and don't know if I plan to 
work on this (not so much time these days).

On Friday, November 11, 2016 at 5:32:08 AM UTC+8, m.hag...@gmail.com wrote:
>
> Is there a recommended way to support gestures in Elm? In Javascript there 
> are nice libraries (HammerJS for example) that offer high level gesture 
> primitives. I'm relatively new to Elm but as far as I can tell:
>
> (a) There are no higher level touch/gesture libraries written natively in 
> Elm (the `Touch` package was discontinued in 0.17 (quite alarming if you 
> care about gestures), https://github.com/knledg/touch-events is just a 
> super thin wrapper around touch event listeners).
>
> (b) There isn't a clean way to "fall back to JS" in the case of touch 
> libraries because these libraries' APIs involve attaching directly to DOM 
> nodes. This causes problems because the virtual DOM is pure (and opaque). 
> In particular it doesn't have an equivalent to the "mount"/"unmount" 
> lifecycle events from React so you can't pass DOM nodes out to JS.
>
> I'd be super interested to hear about any practical experience with this 
> in a production environment. It seems like a problem that anyone writing 
> production applications for mobile must have encountered but I haven't been 
> able to find a solution.
>
> I absolutely love Elm compared to JS but the lack of high level gesture 
> primitives makes it impossible to use if you plan on having non-trivial 
> support for mobile (unless you want to write your own gesture support in 
> Elm).
>

-- 
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] Possible compiler bug while parsing type annotation in a let ?

2016-11-11 Thread Matthieu Pizenberg
Hi,

I just came accross one very strange compiler error and wanted to have the 
point of view of the community before creating any github issue.
I wrote some code to create  tag more easily (seems to be trendy 
these days ^^) in a module Helpers.Views.elm. When I put a type annotation 
for a very simple variable (see gist here 
)
 
*inside* a let expression, the compiler goes crazy XD and tell me that the 
type annotation of the function *containing* the let expression is wrong 
and tell me what it should be -> (apparently it should be what I wrote ^^).

The type annotation is saying:

(Maybe ( Int, a ) -> String)
-> Array a
-> Maybe ( Int, a )
-> (Maybe ( Int, a ) -> b)
-> Html b

But I am inferring that the definition has this type:

(Maybe ( Int, a ) -> String)
-> Array a
-> Maybe ( Int, a )
-> (Maybe ( Int, a ) -> b)
-> Html b

All the corresponding code is on this gist 

 
if you want to try by yourself.
Any idea ?
Should I fill a github issue ?

-- 
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: Correct use of port subscriptions in a submodule reused multiple times?

2016-11-10 Thread Matthieu Pizenberg
Thanks OverminDL1 and Wouter In t Velt, I will try to explain how I have 
come to this issue.
Originally, I have designed a web page (the "part") that was loading a 
collection of images to display them.
So the flow was:
 - init the elm page with a list of images urls
 - [port] send the urls to JS
 - JS create local blob copies of the images at these urls
 - [port] JS send back the urls of local images to elm
 - elm can display and manipulate the collection of locally stored images

Everything was working fine.
Then we wanted to deal with multiple collections of images successively.
So the app becomed kind of a SPA (the "Group") where each page (a part) 
corresponded to one collection.

And so the problem is that each page is receiving a notification for loaded 
images that should notify only the page corresponding to their own 
collection.

Currently, I have circumvent the problem by filtering.
Since each page is aware of its own images urls, if it receives a port 
notification with an new url that does not correspond to one of its own, it 
does nothing of it.

I have been reading a lot since, and a lot about the problem of making too 
many "components".
So as you suggested Wouter In t Velt, I am refactoring a lot of my code 
(and getting rid of a lot of those "components" inside it ^^).
It turns out it is getting much simpler than before. So I think I will go 
with your first advice once it is finished, and manage all ports from the 
top level SPA (the "Group").

Thanks again, I will let you know how it is going as soon as I get some 
time to take care of this.

On Wednesday, November 9, 2016 at 5:37:19 AM UTC+8, Wouter In t Velt wrote:
>
> In your design, the port has a 1-to-1 connection to the Part.
> The port does not communicate for which Part the incoming message is 
> intended, because it "expects" that their is only 1 Part.
>
> Your batch function in the subscriptions in the Group.elm passes on the 
> port message on to all your Parts.
> Your port receives one message of type `PortMsg (Some, Values)`.
> The Group subscription function effectively turns this into 10 messages of 
> type `PartMsg 0 PortMsg (Some, Values)` etcetera.
> And passes each on Group update function.
> So all parts respond to the one message.
>
> You could:
>
>- refactor your port, to provide also an Int id of the intended Part 
>to receive the message
>- subscribe to this port ONLY in Group
>- that would also mean you need to change code in JavaScript-land, to 
>provide the Id when sending info to Elm
>
> Or:
>
>- store an `activePart: Int`  in your Group model, so your Group 
>update knows to which single Part the message should go
>- subscribe to the (unchanged) port in your Group subscriptions only 
>(without bundling the subscriptions of each of the Parts)
>
> Or other options.
> But that depends very much on what you want to achieve. The terms 'Part' 
>  and 'Group' are quite generic, and it is unknown what happens at the other 
> end of the port.
> Maybe you could elaborate on what you want to achieve?
>
>
>

-- 
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] Correct use of port subscriptions in a submodule reused multiple times?

2016-11-08 Thread Matthieu Pizenberg
Hi, I am currently struggling with port subscriptions in a submodule 
(`Part`)
reused multiple times in a bigger (`Group`) module like:

-- In Group.elm
type alias Model =
  { parts : Array Part.Model }

I've been using the following "batching" technique (here are the relevant 
parts of 3 files: Part.elm, Ports.elm, Group.elm)

-- Part.elm

type Msg
 = PortMsg (Some, Values)

update msg model =
 case msg of
   PortMsg (some, values) -> (...) -- using Debug.log here to see how many 
times this is called

subscriptions : Model -> Sub Msg
subscriptions model =
   Ports.portFunction PortMsg


-- Ports.elm

port portFunction : ((Some, Values) -> msg) -> Sub msg


-- Group.elm

type alias Model =
 { parts : Array Part.Model }

type Msg
 = PartMsg Int Part.Msg

subscriptions : Model -> Sub Msg
subscriptions model =
Sub.batch
  <| Array.toList <| Array.indexedMap (Sub.map << PartMsg) (Array.map 
Part.subscriptions 
model.parts)


The problem I face is that when a Sub Msg is processed, the updates of all 
the parts are triggered instead of just the only one
that should be subscribing to the msg (I verified it with the `Debug.log` 
mentionned in the code).
This means that if I have 10 parts in the group, it will trigger the update 
function of the right part and also of the 9 other parts that should not be 
updated with this sub msg.
This is a huge efficiency problem in addition to potentially modifying my 
models incorrectly if I don't care somehow in the update function.

I fear I have come to this issue by design flaws since I'm not finding a 
way to overcome it.
Does anyone have an idea of what I'm doing wrong ?

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