elm-lang.org icon indicating copy to clipboard operation
elm-lang.org copied to clipboard

Add pattern aliasing to syntax reference

Open narkisr opened this issue 9 years ago • 5 comments

The ability of using pattern aliasing, ie:

update ({ a } as model) action 
  -- rest of function body

is missing from the syntax docs.

narkisr avatar Nov 09 '15 23:11 narkisr

+1

trotha01 avatar Feb 06 '16 21:02 trotha01

This seems cool. What are its uses exactly? I've seen it used to update a nested record. I've used let expressions or helper functions to do that.

ghost avatar Oct 13 '16 11:10 ghost

You can destruct records/nested DS within the function definition itself

narkisr avatar Oct 13 '16 11:10 narkisr

It is also used for aliasing modules as in

import Html.Attributes as Attr

pdamoc avatar Oct 13 '16 11:10 pdamoc

I see. The example here is illustrative. So it saves you writing object.x everywhere, you just write x.

ghost avatar Oct 13 '16 11:10 ghost