git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix warnings introduced by -Wall
6fa5829Phil Freeman
purescript.cabal+20−21
@@ -14,46 +14,45 @@ author: Phil Freeman <paf31@cantab.net>
14data-dir: ""
14data-dir: ""
15
15
16library
16library
17− build-depends: base >=4 && <5, syb -any, cmdtheline -any,
17+ build-depends: base >=4 && <5, cmdtheline -any, containers -any,
18− containers -any, mtl -any, transformers -any, parsec -any,
18+ directory -any, filepath -any, mtl -any, parsec -any,
19− utf8-string -any
19+ syb -any, transformers -any, utf8-string -any
20− exposed-modules: Data.Generics.Extras Language.PureScript.Operators
20+ exposed-modules: Data.Generics.Extras Language.PureScript
21− Language.PureScript.Optimize Language.PureScript.Pretty.JS
22− Language.PureScript.CodeGen.JS.AST Main Language.PureScript
23− Language.PureScript.Declarations Language.PureScript.Names
24− Language.PureScript.Types Language.PureScript.Values
25− Language.PureScript.Kinds Language.PureScript.Pretty
26− Language.PureScript.Pretty.Common Language.PureScript.Pretty.Values
27− Language.PureScript.Pretty.Types Language.PureScript.Pretty.Kinds
28 Language.PureScript.CodeGen Language.PureScript.CodeGen.Externs
21 Language.PureScript.CodeGen Language.PureScript.CodeGen.Externs
29− Language.PureScript.CodeGen.JS Language.PureScript.CodeGen.Monad
22+ Language.PureScript.CodeGen.JS Language.PureScript.CodeGen.JS.AST
23+ Language.PureScript.CodeGen.Monad Language.PureScript.Declarations
24+ Language.PureScript.Kinds Language.PureScript.Names
25+ Language.PureScript.Operators Language.PureScript.Optimize
30 Language.PureScript.Parser Language.PureScript.Parser.Common
26 Language.PureScript.Parser Language.PureScript.Parser.Common
31 Language.PureScript.Parser.Declarations
27 Language.PureScript.Parser.Declarations
28+ Language.PureScript.Parser.Kinds Language.PureScript.Parser.State
32 Language.PureScript.Parser.Types Language.PureScript.Parser.Values
29 Language.PureScript.Parser.Types Language.PureScript.Parser.Values
30+ Language.PureScript.Pretty Language.PureScript.Pretty.Common
33− Language.PureScript.Parser.State Language.PureScript.Parser.Kinds
31+ Language.PureScript.Pretty.JS Language.PureScript.Pretty.Kinds
32+ Language.PureScript.Pretty.Types Language.PureScript.Pretty.Values
34 Language.PureScript.TypeChecker
33 Language.PureScript.TypeChecker
35 Language.PureScript.TypeChecker.Kinds
34 Language.PureScript.TypeChecker.Kinds
36 Language.PureScript.TypeChecker.Monad
35 Language.PureScript.TypeChecker.Monad
37− Language.PureScript.TypeChecker.Types
38 Language.PureScript.TypeChecker.Synonyms
36 Language.PureScript.TypeChecker.Synonyms
39− Language.PureScript.Unknown
37+ Language.PureScript.TypeChecker.Types Language.PureScript.Types
38+ Language.PureScript.Unknown Language.PureScript.Values Main
40 exposed: True
39 exposed: True
41 buildable: True
40 buildable: True
42 hs-source-dirs: src
41 hs-source-dirs: src
43
42
44executable psc
43executable psc
45 build-depends: base >=4 && <5, cmdtheline -any, containers -any,
44 build-depends: base >=4 && <5, cmdtheline -any, containers -any,
46− mtl -any, transformers -any, parsec -any, utf8-string -any,
45+ directory -any, filepath -any, mtl -any, parsec -any,
47− syb -any
46+ purescript -any, syb -any, transformers -any, utf8-string -any
48 main-is: Main.hs
47 main-is: Main.hs
49 buildable: True
48 buildable: True
50 hs-source-dirs: src
49 hs-source-dirs: src
51− other-modules:
50+ ghc-options: -Wall -O2 -fno-warn-unused-do-bind
52
51
53test-suite tests
52test-suite tests
54− build-depends: base >=4 && <5, syb -any, directory -any,
53+ build-depends: base >=4 && <5, cmdtheline -any, containers -any,
55− filepath -any, containers -any, mtl -any, transformers -any,
54+ directory -any, filepath -any, mtl -any, parsec -any,
56− parsec -any, utf8-string -any, purescript -any
55+ purescript -any, syb -any, transformers -any, utf8-string -any
57 type: exitcode-stdio-1.0
56 type: exitcode-stdio-1.0
58 main-is: Main.hs
57 main-is: Main.hs
59 buildable: True
58 buildable: True
src/Language/PureScript/Operators.hs+1
@@ -113,6 +113,7 @@ builtIns = [ (globalOp "<", Binary LessThan, 3, Infixl)
113 , (globalOp "/", Binary Divide, 5, Infixl)
113 , (globalOp "/", Binary Divide, 5, Infixl)
114 , (globalOp "%", Binary Modulus, 5, Infixl)
114 , (globalOp "%", Binary Modulus, 5, Infixl)
115 , (globalOp "++", Binary Concat, 6, Infixr)
115 , (globalOp "++", Binary Concat, 6, Infixr)
116+ , (globalOp ":", Binary Cons, 6, Infixr)
116 , (globalOp "+", Binary Add, 7, Infixl)
117 , (globalOp "+", Binary Add, 7, Infixl)
117 , (globalOp "-", Binary Subtract, 7, Infixl)
118 , (globalOp "-", Binary Subtract, 7, Infixl)
118 , (globalOp "<<", Binary ShiftLeft, 8, Infixl)
119 , (globalOp "<<", Binary ShiftLeft, 8, Infixl)
src/Language/PureScript/Parser/Common.hs+67−25
@@ -16,14 +16,11 @@
16
16
17module Language.PureScript.Parser.Common where
17module Language.PureScript.Parser.Common where
18
18
19−import Data.Char (isSpace)
19+import Data.Functor.Identity
20import Control.Applicative
20import Control.Applicative
21import Control.Monad
21import Control.Monad
22−import Control.Monad.State
23import Language.PureScript.Parser.State
22import Language.PureScript.Parser.State
24−import qualified Data.Map as M
25import qualified Text.Parsec as P
23import qualified Text.Parsec as P
26−import qualified Text.Parsec.Pos as P
27import qualified Text.Parsec.Token as PT
24import qualified Text.Parsec.Token as PT
28
25
29import Language.PureScript.Names
26import Language.PureScript.Names
@@ -77,7 +74,7 @@ reservedNames = [ "case"
77
74
78builtInOperators :: [String]
75builtInOperators :: [String]
79builtInOperators = [ "~", "-", "<=", ">=", "<", ">", "*", "/", "%", "++", "+", "<<", ">>>", ">>"
76builtInOperators = [ "~", "-", "<=", ">=", "<", ">", "*", "/", "%", "++", "+", "<<", ">>>", ">>"
80− , "==", "!=", "&&", "||", "&", "^", "|", "!!", "!" ]
77+ , "==", "!=", "&&", "||", "&", "^", "|", "!!", "!", ":" ]
81
78
82reservedOpNames :: [String]
79reservedOpNames :: [String]
83reservedOpNames = builtInOperators ++ [ "->" ]
80reservedOpNames = builtInOperators ++ [ "->" ]
@@ -92,11 +89,12 @@ identLetter :: P.Parsec String u Char
92identLetter = P.alphaNum <|> P.oneOf "_'"
89identLetter = P.alphaNum <|> P.oneOf "_'"
93
90
94opStart :: P.Parsec String u Char
91opStart :: P.Parsec String u Char
95−opStart = P.oneOf "!#$%&*+/<=>?@^|~"
92+opStart = P.oneOf "!#$%&*+/<=>?@^|~:"
96
93
97opLetter :: P.Parsec String u Char
94opLetter :: P.Parsec String u Char
98opLetter = P.oneOf ":#$%&*+./<=>?@^|"
95opLetter = P.oneOf ":#$%&*+./<=>?@^|"
99
96
97+langDef :: PT.GenLanguageDef String u Identity
100langDef = PT.LanguageDef
98langDef = PT.LanguageDef
101 { PT.reservedNames = reservedNames
99 { PT.reservedNames = reservedNames
102 , PT.reservedOpNames = reservedOpNames
100 , PT.reservedOpNames = reservedOpNames
@@ -111,36 +109,80 @@ langDef = PT.LanguageDef
111 , PT.caseSensitive = True
109 , PT.caseSensitive = True
112 }
110 }
113
111
112+tokenParser :: PT.GenTokenParser String u Identity
114tokenParser = PT.makeTokenParser langDef
113tokenParser = PT.makeTokenParser langDef
115
114
116−lexeme = PT.lexeme tokenParser
115+lexeme :: P.Parsec String u a -> P.Parsec String u a
117−identifier = PT.identifier tokenParser
118−reserved = PT.reserved tokenParser
119−reservedOp = PT.reservedOp tokenParser
120−operator = PT.operator tokenParser
121−stringLiteral = PT.stringLiteral tokenParser
122−whiteSpace = PT.whiteSpace tokenParser
123−squares = PT.squares tokenParser
124−semi = PT.semi tokenParser
125−comma = PT.comma tokenParser
126−colon = PT.colon tokenParser
127−dot = PT.dot tokenParser
128−natural = PT.natural tokenParser
116+lexeme = PT.lexeme tokenParser
129
117
118+identifier :: P.Parsec String u String
119+identifier = PT.identifier tokenParser
120+
121+reserved :: String -> P.Parsec String u ()
122+reserved = PT.reserved tokenParser
123+
124+reservedOp :: String -> P.Parsec String u ()
125+reservedOp = PT.reservedOp tokenParser
126+
127+operator :: P.Parsec String u String
128+operator = PT.operator tokenParser
129+
130+stringLiteral :: P.Parsec String u String
131+stringLiteral = PT.stringLiteral tokenParser
132+
133+whiteSpace :: P.Parsec String u ()
134+whiteSpace = PT.whiteSpace tokenParser
135+
136+semi :: P.Parsec String u String
137+semi = PT.semi tokenParser
138+
139+colon :: P.Parsec String u String
140+colon = PT.colon tokenParser
141+
142+dot :: P.Parsec String u String
143+dot = PT.dot tokenParser
144+
145+comma :: P.Parsec String u String
146+comma = PT.comma tokenParser
147+
148+tick :: P.Parsec String u Char
149+tick = lexeme $ P.char '`'
150+
151+pipe :: P.Parsec String u Char
152+pipe = lexeme $ P.char '|'
153+
154+natural :: P.Parsec String u Integer
155+natural = PT.natural tokenParser
156+
157+squares :: P.Parsec String ParseState a -> P.Parsec String ParseState a
158+squares = P.between (lexeme $ P.char '[') (lexeme $ indented *> P.char ']') . (indented *>)
159+
160+parens :: P.Parsec String ParseState a -> P.Parsec String ParseState a
130parens = P.between (lexeme $ P.char '(') (lexeme $ indented *> P.char ')') . (indented *>)
161parens = P.between (lexeme $ P.char '(') (lexeme $ indented *> P.char ')') . (indented *>)
162+
163+braces :: P.Parsec String ParseState a -> P.Parsec String ParseState a
131braces = P.between (lexeme $ P.char '{') (lexeme $ indented *> P.char '}') . (indented *>)
164braces = P.between (lexeme $ P.char '{') (lexeme $ indented *> P.char '}') . (indented *>)
165+
166+angles :: P.Parsec String ParseState a -> P.Parsec String ParseState a
132angles = P.between (lexeme $ P.char '<') (lexeme $ indented *> P.char '>') . (indented *>)
167angles = P.between (lexeme $ P.char '<') (lexeme $ indented *> P.char '>') . (indented *>)
133
168
169+sepBy :: P.Parsec String ParseState a -> P.Parsec String ParseState sep -> P.Parsec String ParseState [a]
134sepBy p s = P.sepBy (indented *> p) (indented *> s)
170sepBy p s = P.sepBy (indented *> p) (indented *> s)
171+
172+sepBy1 :: P.Parsec String ParseState a -> P.Parsec String ParseState sep -> P.Parsec String ParseState [a]
135sepBy1 p s = P.sepBy1 (indented *> p) (indented *> s)
173sepBy1 p s = P.sepBy1 (indented *> p) (indented *> s)
136
174
137−semiSep = flip sepBy semi
175+semiSep :: P.Parsec String ParseState a -> P.Parsec String ParseState [a]
138−semiSep1 = flip sepBy1 semi
176+semiSep = flip sepBy semi
139−commaSep = flip sepBy comma
140−commaSep1 = flip sepBy1 comma
141
177
142−tick = lexeme $ P.char '`'
178+semiSep1 :: P.Parsec String ParseState a -> P.Parsec String ParseState [a]
143−pipe = lexeme $ P.char '|'
179+semiSep1 = flip sepBy1 semi
180+
181+commaSep :: P.Parsec String ParseState a -> P.Parsec String ParseState [a]
182+commaSep = flip sepBy comma
183+
184+commaSep1 :: P.Parsec String ParseState a -> P.Parsec String ParseState [a]
185+commaSep1 = flip sepBy1 comma
144
186
145properName :: P.Parsec String u ProperName
187properName :: P.Parsec String u ProperName
146properName = lexeme $ ProperName <$> P.try ((:) <$> P.upper <*> many (PT.identLetter langDef) P.<?> "name")
188properName = lexeme $ ProperName <$> P.try ((:) <$> P.upper <*> many (PT.identLetter langDef) P.<?> "name")
src/Language/PureScript/Parser/Types.hs−1
@@ -24,7 +24,6 @@ import Language.PureScript.Parser.Common
24import Control.Applicative
24import Control.Applicative
25import qualified Text.Parsec as P
25import qualified Text.Parsec as P
26import qualified Text.Parsec.Expr as P
26import qualified Text.Parsec.Expr as P
27−import Control.Arrow (Arrow(..))
28import Control.Monad (unless)
27import Control.Monad (unless)
29
28
30parseNumber :: P.Parsec String ParseState Type
29parseNumber :: P.Parsec String ParseState Type
src/Language/PureScript/Pretty/Values.hs+1
@@ -133,6 +133,7 @@ prettyPrintValue = fromMaybe (error "Incomplete pattern") . pattern matchValue (
133 , [ binary Divide "/" ]
133 , [ binary Divide "/" ]
134 , [ binary Modulus "%" ]
134 , [ binary Modulus "%" ]
135 , [ binary Concat "++" ]
135 , [ binary Concat "++" ]
136+ , [ binary Cons ":" ]
136 , [ binary Add "+" ]
137 , [ binary Add "+" ]
137 , [ binary Subtract "-" ]
138 , [ binary Subtract "-" ]
138 , [ binary ShiftLeft "<<" ]
139 , [ binary ShiftLeft "<<" ]
src/Language/PureScript/Values.hs+2−1
@@ -46,7 +46,8 @@ data BinaryOperator
46 | ShiftLeft
46 | ShiftLeft
47 | ShiftRight
47 | ShiftRight
48 | ZeroFillShiftRight
48 | ZeroFillShiftRight
49+ | Concat
49− | Concat deriving (Show, Eq, Data, Typeable)
50+ | Cons deriving (Show, Eq, Data, Typeable)
50
51
51data Value
52data Value
52 = NumericLiteral (Either Integer Double)
53 = NumericLiteral (Either Integer Double)
src/Main.hs+7−10
@@ -15,19 +15,15 @@
15module Main where
15module Main where
16
16
17import qualified Language.PureScript as P
17import qualified Language.PureScript as P
18−import Data.Maybe (mapMaybe)
19−import Data.List (intercalate)
20import System.Console.CmdTheLine
18import System.Console.CmdTheLine
21import Control.Applicative
19import Control.Applicative
22import Control.Monad (forM)
20import Control.Monad (forM)
23import System.Exit (exitSuccess, exitFailure)
21import System.Exit (exitSuccess, exitFailure)
24−import qualified Text.Parsec as P
25import qualified System.IO.UTF8 as U
22import qualified System.IO.UTF8 as U
26−import qualified Data.Map as M
27
23
28compile :: [FilePath] -> Maybe FilePath -> Maybe FilePath -> IO ()
24compile :: [FilePath] -> Maybe FilePath -> Maybe FilePath -> IO ()
29−compile inputFiles outputFile externsFile = do
25+compile input output externs = do
30− asts <- fmap (fmap concat . sequence) $ forM inputFiles $ \inputFile -> do
26+ asts <- fmap (fmap concat . sequence) $ forM input $ \inputFile -> do
31 text <- U.readFile inputFile
27 text <- U.readFile inputFile
32 return $ P.runIndentParser P.parseDeclarations text
28 return $ P.runIndentParser P.parseDeclarations text
33 case asts of
29 case asts of
@@ -36,14 +32,14 @@ compile inputFiles outputFile externsFile = do
36 exitFailure
32 exitFailure
37 Right decls ->
33 Right decls ->
38 case P.compile decls of
34 case P.compile decls of
39− Left error -> do
35+ Left err -> do
40− U.putStrLn error
36+ U.putStrLn err
41 exitFailure
37 exitFailure
42 Right (js, exts, _) -> do
38 Right (js, exts, _) -> do
43− case outputFile of
39+ case output of
44 Just path -> U.writeFile path js
40 Just path -> U.writeFile path js
45 Nothing -> U.putStrLn js
41 Nothing -> U.putStrLn js
46− case externsFile of
42+ case externs of
47 Nothing -> return ()
43 Nothing -> return ()
48 Just filePath -> U.writeFile filePath exts
44 Just filePath -> U.writeFile filePath exts
49 exitSuccess
45 exitSuccess
@@ -70,4 +66,5 @@ termInfo = defTI
70 , termDoc = "Compiles PureScript to Javascript"
66 , termDoc = "Compiles PureScript to Javascript"
71 }
67 }
72
68
69+main :: IO ()
73main = run (term, termInfo)
70main = run (term, termInfo)