On Sat, Apr 22, 2017 at 11:50 AM, Dwayne Crooks <dwayne.cro...@gmail.com>
wrote:

> However, if I update the let bindings as follows:
>
>     let
>>         defaultViewConfig = Rating.defaultViewConfig
>>         ratingViewConfig =
>>             { defaultViewConfig | readOnly = model.readOnly }
>>     in
>>         ...
>
>
> Then, there is no error. Am I missing something or is this a bug in the
> parser?
>
> This is related to an active topic around record update syntax.
In short, currently it is not allowed to directly update nested records. ({
Rating.defaultViewConfig | readOnly = model.readOnly } is invalid syntax)
The temporary solution is the one you stumbled upon: creating an alias for
the nested record.

Another solution would be to use custom functions:


updateReadOnly : { a | readOnly : Bool } -> Bool -> a
updateReadOnly rec readOnly =
    { rec | readOnly = readOnly }

and then use it like:

ratingViewConfig =
    updateReadOnly Rating.defaultViewConfig True


-- 
There is NO FATE, we are the creators.
blog: http://damoc.ro/

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to