[elm-discuss] Re: A beginner issue with GeoJSON and type definitions

2016-09-22 Thread Max Goldstein
> Last night I fought with random number generators > Have you seen my library, mgold/elm-random-pcg? It doesn't solve the basic problem of "randomness is hard in a functional language" but it has better docs and some useful helper functions. > And while I encourage you to create a

[elm-discuss] Re: A beginner issue with GeoJSON and type definitions

2016-09-22 Thread J. E. Marca
Good advice thanks. Last night I fought with random number generators, looks like tonight I'm going to be doing the same with the JSON decoders. And while I encourage you to create a GeoJSON decoder, I won't wait for it...the point of this exercise is to learn, and it would be really

[elm-discuss] pattern matching on a field within a record

2016-09-22 Thread Martin DeMello
If I have the following code: type Cell = Empty | Letter String type alias Square = { cell : Cell , num : Int } and c : Maybe Square, can I do the following in a single match? case c of Just { cell } -> case cell of Letter s -> s _ -> "" _ -> "" that is,

[elm-discuss] Re: A beginner issue with GeoJSON and type definitions

2016-09-22 Thread Max Goldstein
You can definitely get the topojson file using Elm's HTTP library, suppling the value decoder so you get back an opaque JSON value, which you can pass out a port (nearly certain on that) for the JS topojson decoder to

Re: [elm-discuss] Elm, Objects and Components

2016-09-22 Thread Mark Hamburg
The issue is that when you have external state, there need to be ways — features, patterns of coding, etc — that prevent accidental destruction of one component accompanied by creation of a new component when what one wanted was an update to the existing component. This depends on having a notion

Re: [elm-discuss] Elm, Objects and Components

2016-09-22 Thread Richard Feldman
I'm not sure what you mean there - what part about the status quo regarding form elements doesn't seem sensible? On Thu, Sep 22, 2016, 8:43 PM Max Goldstein wrote: > I really like Mark's summary, and I think Richard is incorrect to dismiss > the first point: > > 1. Make

Re: [elm-discuss] Elm, Objects and Components

2016-09-22 Thread Max Goldstein
I really like Mark's summary, and I think Richard is incorrect to dismiss the first point: 1. Make sure the virtual DOM works "sensibly" with elements with hidden local state. Checkboxes, drop downs, and other form inputs are a root problem. Maybe the solution is web components, but maybe

Re: [elm-discuss] Structuring a simple App

2016-09-22 Thread Max Goldstein
Hold on folks. All of this is motivated by wanting to be able to change a text box for a slider, yes? You want an interface, not a component. The Msg type should include a SetSpeed Float tag. The view should have the input send this Msg. The view can also expect to use the current speed in

[elm-discuss] Modeling cross-references

2016-09-22 Thread Dénes Harmath
Hi everybody, in a typical model, there are cross-references: e.g. we have artists and albums, and the album refers to its artist. How do we model this in Elm? A possible approach is giving unique identifiers to objects and store the referred object's identifiers similar to the TodoMVC example

Re: [elm-discuss] Structuring a simple App

2016-09-22 Thread OvermindDL1
I would still like to find a good way to structure messages. I'm up to 146 in the base Msg type, and it is not flat, by counting it seems that I have 6 message types that just hold another message type for something further down, which average in size from 2 for 1 of them, 4 for 3 of them, 8

Re: [elm-discuss] Structuring a simple App

2016-09-22 Thread Charlie Koster
As far as Msgs go, why not just flatten it since it's, as you say, a simple app? type Msg = NoOp | Component1Msg | Component2Msg We decided to go down that route on our project and we currently have 10 Msgs, and it will likely grow to be a few dozen. Unless there's a really

Re: [elm-discuss] Structuring a simple App

2016-09-22 Thread Brian Marick
Perhaps the idiomatic way is just forwarding, as in this from https://medium.com/@_rchaves_/structured-todomvc-example-with-elm-a68d87cd38da#.prhqa9c5n type Msg = NoOp | MsgForComponent1 Component1.Msg | MsgForComponent2 Component2.Msg -- You received this message because you are

[elm-discuss] Subscriptions and deep nested components.

2016-09-22 Thread Umur Ozkul
I have a deep component hierarchy and subscriptions are needed by the components deep down. However subscriptions are handled by main. What is the best way to delegate the messages to responsible components deep in the hierarchy? -- You received this message because you are subscribed to the

Re: [elm-discuss] Elm, Objects and Components

2016-09-22 Thread OvermindDL1
Yes, then you pay the price twice. That would be hard to solve because an elm module != js module, which would solve the problem, but would require an overhaul in how elm generates code and would basically just be doing what bucklescript does then as a language (though without TEA). On Thu, Sep

Re: [elm-discuss] Elm, Objects and Components

2016-09-22 Thread OvermindDL1
On Thursday, September 22, 2016 at 9:17:47 AM UTC-6, Rupert Smith wrote: > > On Thursday, September 22, 2016 at 3:12:27 PM UTC+1, OvermindDL1 wrote: >> >> You can compile multiple main files together and they will share a >> code-base, standard library, and all such. >> > > I had not considered

Re: [elm-discuss] Elm, Objects and Components

2016-09-22 Thread 'Rupert Smith' via Elm Discuss
On Thursday, September 22, 2016 at 3:12:27 PM UTC+1, OvermindDL1 wrote: > > You can compile multiple main files together and they will share a > code-base, standard library, and all such. > I had not considered that - useful if you want to take a one page, one main approach rather than nested

Re: [elm-discuss] Elm, Objects and Components

2016-09-22 Thread OvermindDL1
You can compile multiple main files together and they will share a code-base, standard library, and all such. On Thursday, September 22, 2016 at 8:01:58 AM UTC-6, Rupert Smith wrote: > > On Wednesday, September 21, 2016 at 10:59:00 PM UTC+1, John Mayer wrote: >> >> I also posit that

Re: [elm-discuss] Elm, Objects and Components

2016-09-22 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, September 21, 2016 at 10:59:00 PM UTC+1, John Mayer wrote: > > I also posit that automatically generating a web component for every > top-level Elm app is isomorphic and maybe even superior interface to our > existing method of embedding Elm in native HTML pages, and could even >

[elm-discuss] Re: Http 401 Interceptor? My 3rd Elm Project - authentication

2016-09-22 Thread 'Rupert Smith' via Elm Discuss
On Wednesday, September 21, 2016 at 3:02:51 PM UTC+1, Erik Lott wrote: > > Regarding the outmsg and translating types, you've got 2 options - you can > either keep the outmsg in the scope of the module, or you can pass the > outmsg to the update function from the upper level > Thanks for that,

Re: [elm-discuss] Post mortem for my first attempt at using Elm in a real app.

2016-09-22 Thread Peter Damoc
Keeping in mind that this is a post mortem I could tell you what I did. I had an activePage field that was used in the view to select whatever is displayed. I did not have an itemList state because all the information needed was contained in a business object at the top level. I did have state

Re: [elm-discuss] View API stylistic question

2016-09-22 Thread Joaquín Oltra
First one as goto option for splitting view functions out. Second one if viewCheckbox is a standalone reusable triplet with internal state and Msg types (much less often). This talk from Ossi gives great insight on different ways to organize your code

Re: [elm-discuss] Post mortem for my first attempt at using Elm in a real app.

2016-09-22 Thread Lars Jacobsson
> If you implement the Router in Elm (the implementation starts with Elm), then > Pages are a reasonable abstraction. In this scenario - do you wire the state from each separate “page” up into the top level app.elm (or wherever the routing lives), or do you let each page manage it’s own

[elm-discuss] Re: Is this a refresh issue, or something to do with ordering?

2016-09-22 Thread David Legard
Perfect. Many thanks. -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+unsubscr...@googlegroups.com. For more options, visit

Re: [elm-discuss] Is this a refresh issue, or something to do with ordering?

2016-09-22 Thread Eduardo Cuducos
Hi David, I've noticed in one of Evan's exemples (repos) that he uses textarea [ value model.whatever ] [] instead of textarea [] [ text model.whatever ]. I haven't studied the reasons why, but in my tests they seem to work (and using the second way ended up in the same bug you described). Can

[elm-discuss] Is this a refresh issue, or something to do with ordering?

2016-09-22 Thread David Legard
I have a very simple SPA, one textbox, two buttons, and a div for showing messages. The aim of the app is to analyse the text in the textbox (on clicking the 'Process' button) to show messages in the div. The other button, Reset, is supposed to clear the textbox and the messages. The 'update'

Re: [elm-discuss] Re: Post mortem for my first attempt at using Elm in a real app.

2016-09-22 Thread Lars Jacobsson
Thanks for a very informative answer! I think this is a very important part of making an elm application work when it grows. I'm pretty sure that we should be very careful before breaking stuff "prematurely". I started writing an app breaking it up like i used to break up my react/redux -apps,