[elm-discuss] what's the preferred way to implement the submit mentioned in elm guide?

2016-05-24 Thread 诺铁
hi, in http://guide.elm-lang.org/architecture/user_input/forms.html , there is an exercise: - Add a "Submit" button. Only show errors *after* it has been pressed. I tried and find it not as easy as I thought. I have to put color and message in the model, I put the result code here:

Re: [elm-discuss] Static Tzpe Checking in Elm vs Java

2016-05-24 Thread Zachary Kessin
A major issue is the "Maybe". In Java a type can be null so you always have to check for that. WHile in Elm there is difference between "Maybe User" and "User". So the type system will prevent any form of null pointer exception. Zach ᐧ On Tue, May 24, 2016 at 10:06 PM, Joey Eremondi

Re: [elm-discuss] interesting article

2016-05-24 Thread Nick H
Cool, thanks for that example. I can see the advantage of decoupling the actions from the effects. Even without being enforced by the core platform, I think an Elm programmer could follow this pattern without too much trouble. Much in the same way that the current platform architecture was

Re: [elm-discuss] interesting article

2016-05-24 Thread James Wilson
My impression from a brief discussion on the gitter chat room (https://gitter.im/jdubray/sam) about SAM with the creator is that basically if you turn: update msg model = case msg of Increment -> (model + 1, Cmd.none) Decrement -> (model - 1, someEffect) into updateModel msg model =

Re: [elm-discuss] Static Tzpe Checking in Elm vs Java

2016-05-24 Thread Joey Eremondi
Are you interested in the actual type checking algorithms, or just the type systems? Big differences of the type systems: * Elm has tagged union types, meaning that you can make a value that many have one of many types, and pattern match on its possible variants. * Elm has type inference, Java

Re: [elm-discuss] interesting article

2016-05-24 Thread Stefan Houtzager
> What would need to change in the Elm architecture for it to match SAM? I'm just someone interested in learning elm, so I cannot answer. Are the architects of elm, following these messages, who can? Evan Czaplicki? And is this interesting enough to contact Jean-Jacques Dubray, Evan? Op

Re: [elm-discuss] interesting article

2016-05-24 Thread Nick H
Peter's description is very close to how I manage states in my code. It never occurred to me that it might have its own name; it just seemed the most natural way to manage states within the Elm Architecture. The model is a union type. The action is a union type. The update function is just a case

[elm-discuss] Static Tzpe Checking in Elm vs Java

2016-05-24 Thread John Orford
Can someone /wittily/ sum up the experience of type checking in Java vs something pure like Elm? I feel purity, preciseness and descriptiveness is the main difference somehow... Java is too long in the distant past for me, but it's something I love about Elm and never really cared for in

Re: [elm-discuss] Making new Cmds

2016-05-24 Thread Janis Voigtländer
This is not doing what you almost certainly think it does. ​ 2016-05-24 18:44 GMT+02:00 Wil C : > It's just an aside, in case someone searches for it. Here's how to make > new commands: > > Cmd.map (\_ -> NewMsg) Cmd.none > > It wasn't obvious to me. > > Wil > > -- > You

Re: [elm-discuss] Integer / String Input in HTML

2016-05-24 Thread Nick H
Result has its own withDefault function. You do not need to convert the Result to a Maybe. On Tue, May 24, 2016 at 9:15 AM, Thomas Coopman wrote: > I do not completely agree that the solution is not so nice. > The app can return an invalid string and here you are

[elm-discuss] Trigger child action from parent

2016-05-24 Thread TheGryzor123
I created a child component that is supposed to display notifications coming from the parent. I know how to initialize and listen to a child but here I would like to tell him to execute actions for me. What do you suggest me to do? -- You received this message because you are subscribed to

Re: [elm-discuss] Integer / String Input in HTML

2016-05-24 Thread Herwig Habenbacher
Thanks! The Solution just don't look that nice ;-) update : Msg -> Applications -> Applications >> >> update action model = >> >> case action of >> >> AID app -> >> >> { model | appID = String.toInt app |> Result.toMaybe |> >>> Maybe.withDefault 0 } >> >> >>> Name nname -> >> >>

Re: [elm-discuss] Re: Create an alert that disappears after 5 seconds

2016-05-24 Thread Janis Voigtländer
How could a task fail for things like getting a random number or getting the current date? It can’t. And that’s what the never in Task.perform never expresses, and lets the type-checker confirm. ​ 2016-05-24 15:41 GMT+02:00 TheGryzor123 : > Thanks for the answer. How could a

[elm-discuss] Re: Create an alert that disappears after 5 seconds

2016-05-24 Thread TheGryzor123
Thanks for the answer. How could a task fail for things like getting a random number or getting the current date? -- 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

Re: [elm-discuss] Create an alert that disappears after 5 seconds

2016-05-24 Thread Janis Voigtländer
Yeah, I’m thinking of adding that version of perform to a task-extra package. Actually wondering about the name. Maybe performUnfailing, because the standard perform is not really “unsafe” either. ​ 2016-05-24 13:17 GMT+02:00 Peter Damoc : > I would love to have `never` in core

Re: [elm-discuss] Create an alert that disappears after 5 seconds

2016-05-24 Thread Peter Damoc
I would love to have `never` in core and available on elm-lang.org/try Or have performSafe: (a -> Cmd msg) -> Task Never a -> Cmd msg Until then, I prefer the universality of NoOp. On Tue, May 24, 2016 at 12:49 PM, Janis Voigtländer < janis.voigtlaen...@gmail.com> wrote: > My standard

[elm-discuss] Re: Looking for people experienced with elm-html's "key" function

2016-05-24 Thread Kris Jenkins
I've just run into this too, but for me it causes a runtime exception. I've added a demo to reproduce (based on Gera's code) to the same issue: https://github.com/elm-lang/html/issues/21 On Monday, 23 May 2016 13:41:56 UTC+1, ge...@theoldmonk.net wrote: > > I'm not sure if the lazyDict

Re: [elm-discuss] Create an alert that disappears after 5 seconds

2016-05-24 Thread Peter Damoc
You should use Process.sleep dismissCmd = Process.sleep (2 * second) |> Task.perform (\_ -> NoOp) (\_ -> DismissAlert) On Tue, May 24, 2016 at 11:56 AM, TheGryzor123 wrote: > I'm still pretty new to Elm so I prefer to ask. > > I'm creating a typical alert

[elm-discuss] Embed external HTML into elm

2016-05-24 Thread Zachary Kessin
What I want to do is have a chunk of HTML that is not controlled by elm inside an elm full page application. Specifically, I want to use Vega to create graphs in a div on my site. But when I tried to do that with a port if flickered and generally was unusable. I think some of the issue was that