@@ -125,6 +125,28 @@ parseAccessor :: Value -> P.Parsec String ParseState Value
125parseAccessor (Constructor _) = P.unexpected "constructor"
125parseAccessor (Constructor _) = P.unexpected "constructor"
126parseAccessor obj = P.try $ Accessor <$> (C.indented *> C.dot *> P.notFollowedBy C.opLetter *> C.indented *> C.identifier) <*> pure obj
126parseAccessor obj = P.try $ Accessor <$> (C.indented *> C.dot *> P.notFollowedBy C.opLetter *> C.indented *> C.identifier) <*> pure obj
128+parseDoNotationLet :: P.Parsec String ParseState DoNotationElement
129+parseDoNotationLet = DoNotationLet <$> (C.reserved "let" *> C.indented *> parseBinder)
130+ <*> (C.indented *> C.reservedOp "=" *> parseValue)
132+parseDoNotationBind :: P.Parsec String ParseState DoNotationElement
133+parseDoNotationBind = DoNotationBind <$> parseBinder <*> (C.indented *> C.reservedOp "<-" *> parseValue)
135+parseDoNotationReturn :: P.Parsec String ParseState DoNotationElement
136+parseDoNotationReturn = DoNotationReturn <$> (C.reserved "return" *> C.indented *> parseValue)
138+parseDoNotationElement :: P.Parsec String ParseState DoNotationElement
139+parseDoNotationElement = P.choice
140+ [ P.try parseDoNotationBind
141+ , parseDoNotationLet
142+ , parseDoNotationReturn
143+ , P.try (DoNotationValue <$> parseValue) ]
145+parseManyDoNotationElements :: P.Parsec String ParseState [DoNotationElement]
146+parseManyDoNotationElements = do
148+ C.mark (P.many (C.same *> C.mark parseDoNotationElement))
128parseValue :: P.Parsec String ParseState Value
150parseValue :: P.Parsec String ParseState Value
129parseValue =
151parseValue =
130 (buildExpressionParser operators
152 (buildExpressionParser operators
@@ -136,7 +158,9 @@ parseValue =
136 , \v -> P.try $ flip ObjectUpdate <$> (C.indented *> C.braces (C.commaSep1 (C.indented *> parsePropertyUpdate))) <*> pure v ]
158 , \v -> P.try $ flip ObjectUpdate <$> (C.indented *> C.braces (C.commaSep1 (C.indented *> parsePropertyUpdate))) <*> pure v ]
137 postfixTable2 = [ \v -> P.try (C.indented *> indexersAndAccessors >>= \t2 -> return (\t1 -> App t1 [t2])) <*> pure v
159 postfixTable2 = [ \v -> P.try (C.indented *> indexersAndAccessors >>= \t2 -> return (\t1 -> App t1 [t2])) <*> pure v
138 , \v -> P.try $ flip App <$> (C.indented *> C.parens (C.commaSep parseValue)) <*> pure v
160 , \v -> P.try $ flip App <$> (C.indented *> C.parens (C.commaSep parseValue)) <*> pure v
139− , \v -> flip TypedValue <$> (P.try (C.lexeme (C.indented *> P.string "::")) *> parsePolyType) <*> pure v ]
161+ , \v -> flip TypedValue <$> (P.try (C.lexeme (C.indented *> P.string "::")) *> parsePolyType) <*> pure v
162+ , \v -> P.try $ Do v <$> (C.indented *> C.reserved "do" *> parseManyDoNotationElements)
140 operators = [ [ Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "!") >> return (Unary Not)
164 operators = [ [ Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "!") >> return (Unary Not)
141 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "~") >> return (Unary BitwiseNot)
165 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "~") >> return (Unary BitwiseNot)
142 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "-") >> return (Unary Negate)
166 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "-") >> return (Unary Negate)