git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge branch 'master' into 0.10.4-untested
0f8fc03Andy Arvanitis
purescript.cabal+1−1
@@ -121,7 +121,7 @@ library
121 aeson-better-errors >= 0.8,
121 aeson-better-errors >= 0.8,
122 ansi-terminal >= 0.6.2 && < 0.7,
122 ansi-terminal >= 0.6.2 && < 0.7,
123 base-compat >=0.6.0,
123 base-compat >=0.6.0,
124− bower-json >= 0.8,
124+ bower-json >= 1.0.0.1 && < 1.1,
125 boxes >= 0.1.4 && < 0.2.0,
125 boxes >= 0.1.4 && < 0.2.0,
126 bytestring -any,
126 bytestring -any,
127 containers -any,
127 containers -any,
src/Language/PureScript/Docs/Types.hs+6−7
@@ -10,6 +10,7 @@ import Control.Arrow (first, (***))
10import Control.Monad (when)
10import Control.Monad (when)
11import Control.Monad.Error.Class (catchError)
11import Control.Monad.Error.Class (catchError)
12
12
13+import Data.Monoid ((<>))
13import Data.Aeson ((.=))
14import Data.Aeson ((.=))
14import Data.Aeson.BetterErrors
15import Data.Aeson.BetterErrors
15import Data.ByteString.Lazy (ByteString)
16import Data.ByteString.Lazy (ByteString)
@@ -358,8 +359,6 @@ displayPackageError e = case e of
358 "Invalid kind: \"" <> str <> "\""
359 "Invalid kind: \"" <> str <> "\""
359 InvalidDataDeclType str ->
360 InvalidDataDeclType str ->
360 "Invalid data declaration type: \"" <> str <> "\""
361 "Invalid data declaration type: \"" <> str <> "\""
361− where
362− (<>) = T.append
363
362
364instance A.FromJSON a => A.FromJSON (Package a) where
363instance A.FromJSON a => A.FromJSON (Package a) where
365 parseJSON = toAesonParser displayPackageError
364 parseJSON = toAesonParser displayPackageError
@@ -413,7 +412,7 @@ asReExport =
413
412
414asInPackage :: Parse BowerError a -> Parse BowerError (InPackage a)
413asInPackage :: Parse BowerError a -> Parse BowerError (InPackage a)
415asInPackage inner =
414asInPackage inner =
416− build <$> key "package" (perhaps (withString parsePackageName))
415+ build <$> key "package" (perhaps (withText parsePackageName))
417 <*> key "item" inner
416 <*> key "item" inner
418 where
417 where
419 build Nothing = Local
418 build Nothing = Local
@@ -468,8 +467,8 @@ asTypeArguments = eachInArray asTypeArgument
468 where
467 where
469 asTypeArgument = (,) <$> nth 0 asText <*> nth 1 (perhaps asKind)
468 asTypeArgument = (,) <$> nth 0 asText <*> nth 1 (perhaps asKind)
470
469
471−asKind :: Parse e P.Kind
470+asKind :: Parse PackageError P.Kind
472−asKind = fromAesonParser
471+asKind = P.kindFromJSON .! InvalidKind
473
472
474asType :: Parse e P.Type
473asType :: Parse e P.Type
475asType = fromAesonParser
474asType = fromAesonParser
@@ -532,7 +531,7 @@ asBookmark =
532
531
533asResolvedDependencies :: Parse PackageError [(PackageName, Version)]
532asResolvedDependencies :: Parse PackageError [(PackageName, Version)]
534asResolvedDependencies =
533asResolvedDependencies =
535− eachInObjectWithKey (mapLeft ErrorInPackageMeta . parsePackageName . T.unpack) asVersion
534+ eachInObjectWithKey (mapLeft ErrorInPackageMeta . parsePackageName) asVersion
536 where
535 where
537 mapLeft f (Left x) = Left (f x)
536 mapLeft f (Left x) = Left (f x)
538 mapLeft _ (Right x) = Right x
537 mapLeft _ (Right x) = Right x
@@ -557,7 +556,7 @@ instance A.ToJSON a => A.ToJSON (Package a) where
557 , "versionTag" .= pkgVersionTag
556 , "versionTag" .= pkgVersionTag
558 , "modules" .= pkgModules
557 , "modules" .= pkgModules
559 , "bookmarks" .= map (fmap (first P.runModuleName)) pkgBookmarks
558 , "bookmarks" .= map (fmap (first P.runModuleName)) pkgBookmarks
560− , "resolvedDependencies" .= assocListToJSON (T.pack . runPackageName)
559+ , "resolvedDependencies" .= assocListToJSON runPackageName
561 (T.pack . showVersion)
560 (T.pack . showVersion)
562 pkgResolvedDependencies
561 pkgResolvedDependencies
563 , "github" .= pkgGithub
562 , "github" .= pkgGithub
src/Language/PureScript/Errors.hs+2
@@ -498,6 +498,8 @@ prettyPrintSingleError (PPEOptions codeColor full level showDocs) e = flip evalS
498 line $ "The type declaration for " <> markCode (showIdent nm) <> " should be followed by its definition."
498 line $ "The type declaration for " <> markCode (showIdent nm) <> " should be followed by its definition."
499 renderSimpleErrorMessage (RedefinedIdent name) =
499 renderSimpleErrorMessage (RedefinedIdent name) =
500 line $ "The value " <> markCode (showIdent name) <> " has been defined multiple times"
500 line $ "The value " <> markCode (showIdent name) <> " has been defined multiple times"
501+ renderSimpleErrorMessage (UnknownName name@(Qualified Nothing (IdentName (Ident "bind")))) =
502+ line $ "Unknown " <> printName name <> ". You're probably using do-notation, which the compiler replaces with calls to the " <> markCode "bind" <> " function. Please import " <> markCode "bind" <> " from module " <> markCode "Prelude"
501 renderSimpleErrorMessage (UnknownName name) =
503 renderSimpleErrorMessage (UnknownName name) =
502 line $ "Unknown " <> printName name
504 line $ "Unknown " <> printName name
503 renderSimpleErrorMessage (UnknownImport mn name) =
505 renderSimpleErrorMessage (UnknownImport mn name) =
src/Language/PureScript/Kinds.hs+66−4
@@ -1,12 +1,15 @@
1−{-# LANGUAGE TemplateHaskell #-}
2−
3module Language.PureScript.Kinds where
1module Language.PureScript.Kinds where
4
2
5import Prelude.Compat
3import Prelude.Compat
6
4
5+import Data.Text (Text)
7−import qualified Data.Aeson.TH as A
6+import qualified Data.Text as T
7+import Data.Aeson.BetterErrors (Parse, key, asText, asIntegral, nth, fromAesonParser, toAesonParser, throwCustomError)
8+import Data.Aeson ((.=))
9+import qualified Data.Aeson as A
8
10
9import Language.PureScript.Names
11import Language.PureScript.Names
12+import qualified Language.PureScript.Constants as C
10
13
11-- | The data type of kinds
14-- | The data type of kinds
12data Kind
15data Kind
@@ -20,7 +23,66 @@ data Kind
20 | NamedKind (Qualified (ProperName 'KindName))
23 | NamedKind (Qualified (ProperName 'KindName))
21 deriving (Show, Eq, Ord)
24 deriving (Show, Eq, Ord)
22
25
23−$(A.deriveJSON A.defaultOptions ''Kind)
26+-- This is equivalent to the derived Aeson ToJSON instance, except that we
27+-- write it out manually so that we can define a parser which is
28+-- backwards-compatible.
29+instance A.ToJSON Kind where
30+ toJSON kind = case kind of
31+ KUnknown i ->
32+ obj "KUnknown" i
33+ Row k ->
34+ obj "Row" k
35+ FunKind k1 k2 ->
36+ obj "FunKind" [k1, k2]
37+ NamedKind n ->
38+ obj "NamedKind" n
39+ where
40+ obj :: A.ToJSON a => Text -> a -> A.Value
41+ obj tag contents =
42+ A.object [ "tag" .= tag, "contents" .= contents ]
43+
44+-- This is equivalent to the derived Aeson FromJSON instance, except that it
45+-- also handles JSON generated by compilers up to 0.10.3 and maps them to the
46+-- new representations (i.e. NamedKinds which are defined in the Prim module).
47+kindFromJSON :: Parse Text Kind
48+kindFromJSON = do
49+ t <- key "tag" asText
50+ case t of
51+ "KUnknown" ->
52+ KUnknown <$> key "contents" (nth 0 asIntegral)
53+ "Star" ->
54+ pure kindType
55+ "Bang" ->
56+ pure kindEffect
57+ "Row" ->
58+ Row <$> key "contents" kindFromJSON
59+ "FunKind" ->
60+ let
61+ kindAt n = key "contents" (nth n kindFromJSON)
62+ in
63+ FunKind <$> kindAt 0 <*> kindAt 1
64+ "Symbol" ->
65+ pure kindSymbol
66+ "NamedKind" ->
67+ NamedKind <$> key "contents" fromAesonParser
68+ other ->
69+ throwCustomError (T.append "Unrecognised tag: " other)
70+
71+ where
72+ -- The following are copied from Environment and reimplemented to avoid
73+ -- circular dependencies.
74+ primName :: Text -> Qualified (ProperName a)
75+ primName = Qualified (Just $ ModuleName [ProperName C.prim]) . ProperName
76+
77+ primKind :: Text -> Kind
78+ primKind = NamedKind . primName
79+
80+ kindType = primKind "Type"
81+ kindEffect = primKind "Effect"
82+ kindSymbol = primKind "Symbol"
83+
84+instance A.FromJSON Kind where
85+ parseJSON = toAesonParser id kindFromJSON
24
86
25everywhereOnKinds :: (Kind -> Kind) -> Kind -> Kind
87everywhereOnKinds :: (Kind -> Kind) -> Kind -> Kind
26everywhereOnKinds f = go
88everywhereOnKinds f = go
src/Language/PureScript/Publish.hs+6−7
@@ -209,7 +209,7 @@ getBowerRepositoryInfo = either (userError . BadRepositoryField) return . tryExt
209 Just Repository{..} -> do
209 Just Repository{..} -> do
210 unless (repositoryType == "git")
210 unless (repositoryType == "git")
211 (Left (BadRepositoryType repositoryType))
211 (Left (BadRepositoryType repositoryType))
212− maybe (Left NotOnGithub) Right (extractGithub (T.pack repositoryUrl))
212+ maybe (Left NotOnGithub) Right (extractGithub repositoryUrl)
213
213
214checkLicense :: PackageMeta -> PrepareM ()
214checkLicense :: PackageMeta -> PrepareM ()
215checkLicense pkgMeta =
215checkLicense pkgMeta =
@@ -217,7 +217,7 @@ checkLicense pkgMeta =
217 [] ->
217 [] ->
218 userError NoLicenseSpecified
218 userError NoLicenseSpecified
219 ls ->
219 ls ->
220− unless (any isValidSPDX ls)
220+ unless (any (isValidSPDX . T.unpack) ls)
221 (userError InvalidLicense)
221 (userError InvalidLicense)
222
222
223-- |
223-- |
@@ -320,8 +320,7 @@ asResolvedDependencies = nubBy ((==) `on` fst) <$> go
320 go =
320 go =
321 fmap (fromMaybe []) $
321 fmap (fromMaybe []) $
322 keyMay "dependencies" $
322 keyMay "dependencies" $
323− (++) <$> eachInObjectWithKey (parsePackageName . T.unpack)
323+ (++) <$> eachInObjectWithKey parsePackageName asDependencyStatus
324− asDependencyStatus
325 <*> (concatMap snd <$> eachInObject asResolvedDependencies)
324 <*> (concatMap snd <$> eachInObject asResolvedDependencies)
326
325
327-- | Extracts only the top level dependency names from the output of
326-- | Extracts only the top level dependency names from the output of
@@ -330,7 +329,7 @@ asToplevelDependencies :: Parse BowerError [PackageName]
330asToplevelDependencies =
329asToplevelDependencies =
331 fmap (map fst) $
330 fmap (map fst) $
332 key "dependencies" $
331 key "dependencies" $
333− eachInObjectWithKey (parsePackageName . T.unpack) (return ())
332+ eachInObjectWithKey parsePackageName (return ())
334
333
335asDependencyStatus :: Parse e DependencyStatus
334asDependencyStatus :: Parse e DependencyStatus
336asDependencyStatus = do
335asDependencyStatus = do
@@ -371,7 +370,7 @@ handleDeps deps = do
371 ResolvedOther _ -> (ms, pkgName : os, is)
370 ResolvedOther _ -> (ms, pkgName : os, is)
372 ResolvedVersion v -> (ms, os, (pkgName, v) : is)
371 ResolvedVersion v -> (ms, os, (pkgName, v) : is)
373
372
374− bowerDir pkgName = "bower_components/" ++ runPackageName pkgName
373+ bowerDir pkgName = T.unpack $ "bower_components/" <> runPackageName pkgName
375
374
376 -- Try to extract a version, and warn if unsuccessful.
375 -- Try to extract a version, and warn if unsuccessful.
377 tryExtractVersion' :: (PackageName, Text) -> PrepareM (Maybe (PackageName, Version))
376 tryExtractVersion' :: (PackageName, Text) -> PrepareM (Maybe (PackageName, Version))
@@ -406,6 +405,6 @@ getPackageName fp = do
406 let xs = splitOn [pathSeparator] fp
405 let xs = splitOn [pathSeparator] fp
407 ys <- stripPrefix ["bower_components"] xs
406 ys <- stripPrefix ["bower_components"] xs
408 y <- headMay ys
407 y <- headMay ys
409− case Bower.mkPackageName y of
408+ case Bower.mkPackageName (T.pack y) of
410 Right name -> Just name
409 Right name -> Just name
411 Left _ -> Nothing
410 Left _ -> Nothing
src/Language/PureScript/Publish/BoxesHelpers.hs+5
@@ -6,6 +6,8 @@ module Language.PureScript.Publish.BoxesHelpers
6
6
7import Prelude.Compat
7import Prelude.Compat
8
8
9+import Data.Text (Text)
10+import qualified Data.Text as T
9import System.IO (hPutStr, stderr)
11import System.IO (hPutStr, stderr)
10
12
11import qualified Text.PrettyPrint.Boxes as Boxes
13import qualified Text.PrettyPrint.Boxes as Boxes
@@ -37,6 +39,9 @@ spacer = Boxes.emptyBox 1 1
37bulletedList :: (a -> String) -> [a] -> [Boxes.Box]
39bulletedList :: (a -> String) -> [a] -> [Boxes.Box]
38bulletedList f = map (indented . para . ("* " ++) . f)
40bulletedList f = map (indented . para . ("* " ++) . f)
39
41
42+bulletedListT :: (a -> Text) -> [a] -> [Boxes.Box]
43+bulletedListT f = bulletedList (T.unpack . f)
44+
40printToStderr :: Boxes.Box -> IO ()
45printToStderr :: Boxes.Box -> IO ()
41printToStderr = hPutStr stderr . Boxes.render
46printToStderr = hPutStr stderr . Boxes.render
42
47
src/Language/PureScript/Publish/ErrorsWarnings.hs+7−7
@@ -65,7 +65,7 @@ data UserError
65
65
66data RepositoryFieldError
66data RepositoryFieldError
67 = RepositoryFieldMissing
67 = RepositoryFieldMissing
68− | BadRepositoryType String
68+ | BadRepositoryType Text
69 | NotOnGithub
69 | NotOnGithub
70 deriving (Show)
70 deriving (Show)
71
71
@@ -213,7 +213,7 @@ displayUserError e = case e of
213 , "installed:"
213 , "installed:"
214 ])
214 ])
215 ] ++
215 ] ++
216− bulletedList runPackageName (NonEmpty.toList pkgs)
216+ bulletedListT runPackageName (NonEmpty.toList pkgs)
217 ++
217 ++
218 [ spacer
218 [ spacer
219 , para (concat
219 , para (concat
@@ -263,7 +263,7 @@ displayRepositoryError err = case err of
263 BadRepositoryType ty ->
263 BadRepositoryType ty ->
264 para (concat
264 para (concat
265 [ "In your bower.json file, the repository type is currently listed as "
265 [ "In your bower.json file, the repository type is currently listed as "
266− , "\"" ++ ty ++ "\". Currently, only git repositories are supported. "
266+ , "\"" ++ T.unpack ty ++ "\". Currently, only git repositories are supported. "
267 , "Please publish your code in a git repository, and then update the "
267 , "Please publish your code in a git repository, and then update the "
268 , "repository type in your bower.json file to \"git\"."
268 , "repository type in your bower.json file to \"git\"."
269 ])
269 ])
@@ -361,7 +361,7 @@ warnNoResolvedVersions pkgNames =
361 ["The following ", packages, " did not appear to have a resolved "
361 ["The following ", packages, " did not appear to have a resolved "
362 , "version:"])
362 , "version:"])
363 ] ++
363 ] ++
364− bulletedList runPackageName (NonEmpty.toList pkgNames)
364+ bulletedListT runPackageName (NonEmpty.toList pkgNames)
365 ++
365 ++
366 [ spacer
366 [ spacer
367 , para (concat
367 , para (concat
@@ -385,7 +385,7 @@ warnUndeclaredDependencies pkgNames =
385 [ "The following Bower ", packages, " ", are, " installed, but not "
385 [ "The following Bower ", packages, " ", are, " installed, but not "
386 , "declared as ", dependencies, " in your bower.json file:"
386 , "declared as ", dependencies, " in your bower.json file:"
387 ])
387 ])
388− : bulletedList runPackageName (NonEmpty.toList pkgNames)
388+ : bulletedListT runPackageName (NonEmpty.toList pkgNames)
389
389
390warnUnacceptableVersions :: NonEmpty (PackageName, Text) -> Box
390warnUnacceptableVersions :: NonEmpty (PackageName, Text) -> Box
391warnUnacceptableVersions pkgs =
391warnUnacceptableVersions pkgs =
@@ -403,7 +403,7 @@ warnUnacceptableVersions pkgs =
403 , "not be parsed:"
403 , "not be parsed:"
404 ])
404 ])
405 ] ++
405 ] ++
406− bulletedList showTuple (NonEmpty.toList pkgs)
406+ bulletedListT showTuple (NonEmpty.toList pkgs)
407 ++
407 ++
408 [ spacer
408 [ spacer
409 , para (concat
409 , para (concat
@@ -414,7 +414,7 @@ warnUnacceptableVersions pkgs =
414 ])
414 ])
415 ]
415 ]
416 where
416 where
417− showTuple (pkgName, tag) = runPackageName pkgName ++ "#" ++ T.unpack tag
417+ showTuple (pkgName, tag) = runPackageName pkgName <> "#" <> tag
418
418
419warnDirtyWorkingTree :: Box
419warnDirtyWorkingTree :: Box
420warnDirtyWorkingTree =
420warnDirtyWorkingTree =
stack-ghc-8.0.yaml+1
@@ -5,3 +5,4 @@ extra-deps:
5- pipes-http-1.0.2
5- pipes-http-1.0.2
6- wai-websockets-3.0.0.9
6- wai-websockets-3.0.0.9
7- websockets-0.9.6.2
7- websockets-0.9.6.2
8+- bower-json-1.0.0.1
stack.yaml+2−4
@@ -1,7 +1,5 @@
1−resolver: lts-7.9
1+resolver: lts-6.25
2packages:
2packages:
3- '.'
3- '.'
4extra-deps:
4extra-deps:
5−- pipes-http-1.0.2
5+- bower-json-1.0.0.1
6−- wai-websockets-3.0.0.9
7−- websockets-0.9.6.2