@@ -134,65 +134,40 @@ parensTerm =
134134
135135recordTerm :: IParser Source.Expr
136136recordTerm =
137− addLocation $
138− brackets (choice [ misc, record ])
139− where
140− record =
141− E.Record <$> commaSep field
142−
143− field =
144− do label <- rLabel
145− patterns <- spacePrefix Pattern.term
146− padded equals
147− body <- expr
148− return (label, makeFunction patterns body)
149−
150− misc =
151− do nextParser <- try miscStarter
152− whitespace
153− nextParser
154−
155− miscStarter =
156− do start <- getMyPosition
157− record <- addLocation (E.rawVar <$> rLabel)
137+ addLocation $ brackets $ choice $
138+ [ do starter <- try (addLocation rLabel)
158139 whitespace
159140 choice
160− [ string "-" >> return (afterMinus start record)
161− , string "|" >> return (afterBar record)
141+ [ update starter
142+ , literal starter
162143 ]
144+ , return (E.Record [])
145+ ]
146+ where
147+ update (A.A ann starter) =
148+ do try (string "|")
149+ whitespace
150+ fields <- commaSep1 field
151+ return (E.Update (A.A ann (E.rawVar starter)) fields)
163152
164− afterMinus start record =
165− do field <- rLabel
166− end <- getMyPosition
167− let subRecord' = E.Remove record field
168− maybe <- optionMaybe (try (whitespace >> string "|"))
169− case maybe of
170− Nothing ->
171− return subRecord'
172− Just _ ->
173− do whitespace
174− field <- rLabel
175− padded equals
176− E.Insert (A.at start end subRecord') field <$> expr
177−
178− afterBar record =
179− do field <- rLabel
153+ literal (A.A _ starter) =
154+ do try (string "<-")
155+ whitespace
156+ value <- expr
180157 whitespace
181158 choice
182− [ do equals
183− whitespace
184− E.Insert record field <$> expr
185− , do leftArrow
159+ [ do try comma
186160 whitespace
187− value <- expr
188− updates <- spaceyPrefixBy comma update
189− return (E.Modify record ((field,value) : updates))
161+ fields <- commaSep field
162+ return (E.Record ((starter, value) : fields))
163+ , return (E.Record [(starter, value)])
190164 ]
191165
192− update =
193− do lbl <- rLabel
194− padded leftArrow
195− (,) lbl <$> expr
166+ field =
167+ do key <- rLabel
168+ padded (string "<-")
169+ value <- expr
170+ return (key, value)
196171
197172
198173term :: IParser Source.Expr