Re: [elm-discuss] Re: Request: loosen syntactic constraints on base-record in record extend/update syntax

2016-09-14 Thread Jaap Bouma
.. or depending on your wider context, if you don't want the customerDefaults value polluting your namespace: customers = let customerDefaults = { name = "", height = 0.0 } in [ newCustomer 1 { customerDefaults | name = "Bill" } ... ] On Wed, Sep 14, 2016

Re: [elm-discuss] Re: Request: loosen syntactic constraints on base-record in record extend/update syntax

2016-09-14 Thread Jaap Bouma
How about this: type alias Customer = { id : Int , name : String , height: Float } customerDefaults = { name = "", height = 0.0 } newCustomer : Int -> { a | name: String, height: Float } -> Customer newCustomer id opts = { id = id , name = opts.name , height =

Re: [elm-discuss] Re: Request: loosen syntactic constraints on base-record in record extend/update syntax

2016-09-14 Thread Martin Cerny
The pipe solution seems OKish - thanks for the suggestion! Martin On Tuesday, 13 September 2016 20:03:14 UTC+2, Nick H wrote: > > Another solution might be to define some setters, so that you could write > something like: > > [ > defaultCustomer 1 |> setName "Smith" |> setOccupation |>

Re: [elm-discuss] Re: Request: loosen syntactic constraints on base-record in record extend/update syntax

2016-09-13 Thread Nick H
Another solution might be to define some setters, so that you could write something like: [ defaultCustomer 1 |> setName "Smith" |> setOccupation |> "Clerk", defaultCustomer 2 |> setName "Jones", defaultCustomer 3 |> setNickname "R2-D2" |> setHeight 0.5 ] Unfortunately, defining all those

Re: [elm-discuss] Re: Request: loosen syntactic constraints on base-record in record extend/update syntax

2016-09-13 Thread Nick H
OK, this is a more complex issue than what I had in mind. If you have a small number of desired initializations (maybe 2 or 3 cases besides defaultCustomer), I think it would make sense to have multiple construction functions. But of course that won't scale at all. On Tue, Sep 13, 2016 at 7:03

Re: [elm-discuss] Re: Request: loosen syntactic constraints on base-record in record extend/update syntax

2016-09-13 Thread Martin Cerny
Hi, thanks for the suggestion, but I think you are answering to a different problem than the one I had in mind, I'll try to be more clear to avoid confusion. In my use case, I have a lot of fields, which usually can be kept with their default values, but some of them aren't. So not all