git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge branch 'master' into pure11
commite28f17bf57b7ebb44cd584efcbcfbc88923ea0e0 authorAndy Arvanitis <andyarvanitis@gmail.com> dateSat 19 Nov 2016, 16:15 (10 years ago) parent69cb2e479060d4
4 files changed+29−4
psc-package/Main.hs+23 src/Language/PureScript/Errors.hs+1−1 src/Language/PureScript/Parser/Declarations.hs+2−2 src/Language/PureScript/Sugar/Operators/Expr.hs+3−1
psc-package/Main.hs+23
@@ -181,6 +181,14 @@ install pkgName = do
181181 writePackageFile pkg'
182182 echo "psc-package.json file was updated"
183183
184+uninstall :: String -> IO ()
185+uninstall pkgName = do
186+ pkg <- readPackageFile
187+ let pkg' = pkg { depends = filter (/= pack pkgName) $ depends pkg }
188+ updateImpl pkg'
189+ writePackageFile pkg'
190+ echo "psc-package.json file was updated"
191+
184192listDependencies :: IO ()
185193listDependencies = do
186194 pkg@PackageConfig{ depends } <- readPackageFile
@@ -188,6 +196,15 @@ listDependencies = do
188196 trans <- getTransitiveDeps db depends
189197 traverse_ (echo . fst) trans
190198
199+listPackages :: IO ()
200+listPackages = do
201+ pkg <- readPackageFile
202+ db <- readPackageSet pkg
203+ traverse_ echo (fmt <$> Map.assocs db)
204+ where
205+ fmt :: (Text, PackageInfo) -> Text
206+ fmt (name, PackageInfo{ version }) = name <> " (" <> version <> ")"
207+
191208getSourcePaths :: PackageConfig -> PackageSet -> [Text] -> IO [Turtle.FilePath]
192209getSourcePaths PackageConfig{..} db pkgNames = do
193210 trans <- getTransitiveDeps db pkgNames
@@ -240,6 +257,9 @@ main = do
240257 , Opts.command "update"
241258 (Opts.info (pure update)
242259 (Opts.progDesc "Update dependencies"))
260+ , Opts.command "uninstall"
261+ (Opts.info (uninstall <$> pkg)
262+ (Opts.progDesc "Uninstall the named package"))
243263 , Opts.command "install"
244264 (Opts.info (install <$> pkg)
245265 (Opts.progDesc "Install the named package"))
@@ -252,6 +272,9 @@ main = do
252272 , Opts.command "sources"
253273 (Opts.info (pure listSourcePaths)
254274 (Opts.progDesc "List all (active) source paths for dependencies"))
275+ , Opts.command "available"
276+ (Opts.info (pure listPackages)
277+ (Opts.progDesc "List all packages available in the package set"))
255278 ]
256279 where
257280 pkg = Opts.strArgument $
src/Language/PureScript/Errors.hs+1−1
@@ -640,7 +640,7 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
640640 go _ = False
641641 renderSimpleErrorMessage (AmbiguousTypeVariables t _) =
642642 paras [ line "The inferred type"
643− , indent $ line $ markCode $ prettyPrintType t
643+ , markCodeBox $ indent $ typeAsBox t
644644 , line "has type variables which are not mentioned in the body of the type. Consider adding a type annotation."
645645 ]
646646 renderSimpleErrorMessage (PossiblyInfiniteInstance nm ts) =
src/Language/PureScript/Parser/Declarations.hs+2−2
@@ -392,7 +392,7 @@ parseLet = do
392392 return $ Let ds result
393393
394394parseValueAtom :: TokenParser Expr
395−parseValueAtom = P.choice
395+parseValueAtom = withSourceSpan PositionedValue $ P.choice
396396 [ parseAnonymousArgument
397397 , Literal <$> parseNumericLiteral
398398 , Literal <$> parseCharLiteral
@@ -418,7 +418,7 @@ parseValueAtom = P.choice
418418parseInfixExpr :: TokenParser Expr
419419parseInfixExpr
420420 = P.between tick tick parseValue
421− <|> Op <$> parseQualified parseOperator
421+ <|> withSourceSpan PositionedValue (Op <$> parseQualified parseOperator)
422422
423423parseHole :: TokenParser Expr
424424parseHole = Hole <$> holeLit
src/Language/PureScript/Sugar/Operators/Expr.hs+3−1
@@ -20,7 +20,9 @@ matchExprOperators = matchOperators isBinOp extractOp fromOp reapply modOpTable
2020 isBinOp _ = False
2121
2222 extractOp :: Expr -> Maybe (Expr, Expr, Expr)
23− extractOp (BinaryNoParens op l r) = Just (op, l, r)
23+ extractOp (BinaryNoParens op l r)
24+ | PositionedValue _ _ op' <- op = Just (op', l, r)
25+ | otherwise = Just (op, l, r)
2426 extractOp _ = Nothing
2527
2628 fromOp :: Expr -> Maybe (Qualified (OpName 'ValueOpName))