on master help sign in
Rename some functions and export `typeAnnotation`
commitfecc96dde71e65461b72ddfcf6165b829e08956f authorEvan Czaplicki <info@elm-lang.org> dateWed 4 Sep 2013, 17:16 (13 years ago) parent24642c8
1 file changed+12−10
compiler/Parse/Expression.hs+12−10
compiler/Parse/Expression.hs+12−10
@@ -1,4 +1,4 @@
1−module Parse.Expression (def,term) where
1+module Parse.Expression (def,term,typeAnnotation) where
22
33import Control.Arrow ((***))
44import Control.Applicative ((<$>), (<*>))
@@ -208,7 +208,8 @@ expr = addLocation (choice [ ifExpr, letExpr, caseExpr ])
208208 <|> binaryExpr
209209 <?> "an expression"
210210
211−funcDef =
211+defStart :: IParser [Pattern]
212+defStart =
212213 choice [ do p1 <- try Pattern.term
213214 infics p1 <|> func p1
214215 , func =<< (PVar <$> parens symOp)
@@ -231,19 +232,20 @@ makeFunction :: [Pattern] -> LExpr t v -> LExpr t v
231232makeFunction args body@(L s _) =
232233 foldr (\arg body' -> L s $ Lambda arg body') body args
233234
234−assignExpr :: IParser (Def t v)
235−assignExpr = withPos $ do
236− (name:args) <- funcDef
235+definition :: IParser (Def t v)
236+definition = withPos $ do
237+ (name:args) <- defStart
237238 whitespace >> string "=" >> whitespace
238239 body <- expr
239240 return . Def name $ makeFunction args body
240241
241242typeAnnotation :: IParser (Def t v)
242243typeAnnotation = TypeAnnotation <$> try start <*> Type.expr
243− where
244− start = do v <- lowVar <|> parens symOp
245− whitespace ; hasType ; whitespace
246− return v
244+ where
245+ start = do
246+ v <- lowVar <|> parens symOp
247+ whitespace ; hasType ; whitespace
248+ return v
247249
248250def :: IParser (Def t v)
249−def = typeAnnotation <|> assignExpr
251+def = typeAnnotation <|> definition