git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Use dot for module name separator, not a colon
38e324aPhil Freeman
examples/passing/Module.purs+6−6
@@ -2,7 +2,7 @@ module Test where
2
2
3 data Foo = Foo String
3 data Foo = Foo String
4
4
5− foo :: Test:Foo -> String
5+ foo :: Test.Foo -> String
6 foo = \f -> case f of Foo s -> s ++ "foo"
6 foo = \f -> case f of Foo s -> s ++ "foo"
7
7
8 bar :: Foo -> String
8 bar :: Foo -> String
@@ -12,11 +12,11 @@ module Test where
12
12
13 inner = "Inner"
13 inner = "Inner"
14
14
15−baz :: Test:Foo -> String
15+baz :: Test.Foo -> String
16−baz = Test:foo
16+baz = Test.foo
17
17
18innerCopy :: String
18innerCopy :: String
19−innerCopy = Test:Inner:inner
19+innerCopy = Test.Inner.inner
20
20
21−match :: Test:Foo -> String
21+match :: Test.Foo -> String
22−match = \f -> case f of Test:Foo s -> s ++ "foo"
22+match = \f -> case f of Test.Foo s -> s ++ "foo"
examples/passing/NameResolution.purs+1−1
@@ -12,4 +12,4 @@ module A where
12
12
13 baz = foo
13 baz = foo
14
14
15− abc = A:B:abc
15+ abc = A.B.abc
examples/passing/Operators.purs+2−2
@@ -32,6 +32,6 @@ module Ops where
32
32
33 bar = \s1 s2 -> s1 ++ s2
33 bar = \s1 s2 -> s1 ++ s2
34
34
35−test9 = Ops:foo Ops:@@ "Hello World"
35+test9 = Ops.foo Ops.@@ "Hello World"
36
36
37−test10 = "Hello" `Ops:bar` "World"
37+test10 = "Hello" `Ops.bar` "World"
purescript.cabal+1−1
@@ -1,5 +1,5 @@
1name: purescript
1name: purescript
2−version: 0.1.14
2+version: 0.1.15
3cabal-version: >=1.8
3cabal-version: >=1.8
4build-type: Simple
4build-type: Simple
5license: MIT
5license: MIT
src/Language/PureScript/Names.hs+1−1
@@ -44,7 +44,7 @@ global = ModulePath []
44data Qualified a = Qualified ModulePath a deriving (Eq, Ord, Data, Typeable)
44data Qualified a = Qualified ModulePath a deriving (Eq, Ord, Data, Typeable)
45
45
46instance (Show a) => Show (Qualified a) where
46instance (Show a) => Show (Qualified a) where
47− show (Qualified (ModulePath names) a) = intercalate ":" (map show names ++ [show a])
47+ show (Qualified (ModulePath names) a) = intercalate "." (map show names ++ [show a])
48
48
49qualify :: ModulePath -> Qualified a -> (ModulePath, a)
49qualify :: ModulePath -> Qualified a -> (ModulePath, a)
50qualify mp (Qualified (ModulePath []) a) = (mp, a)
50qualify mp (Qualified (ModulePath []) a) = (mp, a)
src/Language/PureScript/Parser/Common.hs+11−3
@@ -151,7 +151,7 @@ parseQualified parser = part global
151 part path = (do name <- P.try (properName <* delimiter)
151 part path = (do name <- P.try (properName <* delimiter)
152 part (subModule path name))
152 part (subModule path name))
153 <|> (Qualified path <$> P.try parser)
153 <|> (Qualified path <$> P.try parser)
154− delimiter = indented *> colon <* P.notFollowedBy colon
154+ delimiter = indented *> dot
155
155
156integerOrFloat :: P.Parsec String u (Either Integer Double)
156integerOrFloat :: P.Parsec String u (Either Integer Double)
157integerOrFloat = (Left <$> P.try (PT.natural tokenParser) <|>
157integerOrFloat = (Left <$> P.try (PT.natural tokenParser) <|>
@@ -166,8 +166,16 @@ fold first more combine = do
166 bs <- P.many more
166 bs <- P.many more
167 return $ foldl combine a bs
167 return $ foldl combine a bs
168
168
169−buildPostfixParser :: P.Stream s m t => [P.ParsecT s u m (a -> a)] -> P.ParsecT s u m a -> P.ParsecT s u m a
169+buildPostfixParser :: P.Stream s m t => [a -> P.ParsecT s u m a] -> P.ParsecT s u m a -> P.ParsecT s u m a
170−buildPostfixParser f x = fold x (P.choice f) (flip ($))
170+buildPostfixParser fs first = do
171+ a <- first
172+ go a
173+ where
174+ go a = do
175+ maybeA <- P.optionMaybe $ P.choice (map ($ a) fs)
176+ case maybeA of
177+ Nothing -> return a
178+ Just a' -> go a'
171
179
172operatorOrBuiltIn :: P.Parsec String u String
180operatorOrBuiltIn :: P.Parsec String u String
173operatorOrBuiltIn = P.try operator <|> P.choice (map (\s -> P.try (reservedOp s) >> return s) builtInOperators)
181operatorOrBuiltIn = P.try operator <|> P.choice (map (\s -> P.try (reservedOp s) >> return s) builtInOperators)
src/Language/PureScript/Parser/Types.hs+2−2
@@ -75,8 +75,8 @@ parseTypeAtom = indented *> P.choice (map P.try
75parseAnyType :: P.Parsec String ParseState Type
75parseAnyType :: P.Parsec String ParseState Type
76parseAnyType = (P.buildExpressionParser operators . buildPostfixParser postfixTable $ parseTypeAtom) P.<?> "type"
76parseAnyType = (P.buildExpressionParser operators . buildPostfixParser postfixTable $ parseTypeAtom) P.<?> "type"
77 where
77 where
78− postfixTable :: [P.Parsec String ParseState (Type -> Type)]
78+ postfixTable :: [Type -> P.Parsec String ParseState Type]
79− postfixTable = [ flip TypeApp <$> P.try (indented *> parseTypeAtom) ]
79+ postfixTable = [ \x -> TypeApp x <$> P.try (indented *> parseTypeAtom) ]
80 operators = [ [ P.Infix (lexeme (P.try (P.string "->")) >> return (\t1 t2 -> Function [t1] t2)) P.AssocRight ] ]
80 operators = [ [ P.Infix (lexeme (P.try (P.string "->")) >> return (\t1 t2 -> Function [t1] t2)) P.AssocRight ] ]
81
81
82parseType :: P.Parsec String ParseState Type
82parseType :: P.Parsec String ParseState Type
src/Language/PureScript/Parser/Values.hs+9−5
@@ -126,6 +126,10 @@ parsePropertyUpdate = do
126 value <- C.indented *> parseValue
126 value <- C.indented *> parseValue
127 return (name, value)
127 return (name, value)
128
128
129+parseAccessor :: Value -> P.Parsec String ParseState Value
130+parseAccessor (Constructor _) = P.unexpected "constructor"
131+parseAccessor obj = Accessor <$> (C.indented *> C.dot *> C.indented *> C.identifier) <*> pure obj
132+
129parseValue :: P.Parsec String ParseState Value
133parseValue :: P.Parsec String ParseState Value
130parseValue =
134parseValue =
131 (buildExpressionParser operators
135 (buildExpressionParser operators
@@ -133,11 +137,11 @@ parseValue =
133 $ indexersAndAccessors) P.<?> "expression"
137 $ indexersAndAccessors) P.<?> "expression"
134 where
138 where
135 indexersAndAccessors = C.buildPostfixParser postfixTable1 parseValueAtom
139 indexersAndAccessors = C.buildPostfixParser postfixTable1 parseValueAtom
136− postfixTable1 = [ Accessor <$> (C.indented *> C.dot *> C.indented *> C.identifier)
140+ postfixTable1 = [ parseAccessor
137− , P.try $ flip ObjectUpdate <$> (C.indented *> C.braces (C.commaSep1 (C.indented *> parsePropertyUpdate))) ]
141+ , \v -> P.try $ flip ObjectUpdate <$> (C.indented *> C.braces (C.commaSep1 (C.indented *> parsePropertyUpdate))) <*> pure v ]
138− postfixTable2 = [ P.try (C.indented *> indexersAndAccessors >>= \t2 -> return (\t1 -> App t1 [t2]))
142+ postfixTable2 = [ \v -> P.try (C.indented *> indexersAndAccessors >>= \t2 -> return (\t1 -> App t1 [t2])) <*> pure v
139− , P.try $ flip App <$> (C.indented *> C.parens (C.commaSep parseValue))
143+ , \v -> P.try $ flip App <$> (C.indented *> C.parens (C.commaSep parseValue)) <*> pure v
140− , flip TypedValue <$> (P.try (C.lexeme (C.indented *> P.string "::")) *> parsePolyType) ]
144+ , \v -> flip TypedValue <$> (P.try (C.lexeme (C.indented *> P.string "::")) *> parsePolyType) <*> pure v ]
141 operators = [ [ Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "!") >> return (Unary Not)
145 operators = [ [ Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "!") >> return (Unary Not)
142 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "~") >> return (Unary BitwiseNot)
146 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "~") >> return (Unary BitwiseNot)
143 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "-") >> return (Unary Negate)
147 , Prefix $ C.lexeme (P.try $ C.indented *> C.reservedOp "-") >> return (Unary Negate)