git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge branch 'master' into pure11
commit5b5d51785f431a8c54748d5015473e8880f60fc2 authorAndy Arvanitis <andyarvanitis@gmail.com> dateSun 10 Apr 2016, 16:35 (11 years ago) parent3451fc8d490b18
11 files changed+144−224
appveyor.yml+57 bundle/build-stack.sh+41−28 bundle/build.sh−50 bundle/winbuild-stack.sh−46 bundle/winbuild.sh−47 src/Language/PureScript/Errors.hs−6 src/Language/PureScript/Ide/Types.hs+2−2 src/Language/PureScript/Linter/Imports.hs+9−4 src/Language/PureScript/Sugar/Names/Exports.hs+6−10 src/Language/PureScript/Sugar/Names/Imports.hs+23−25 src/Language/PureScript/TypeChecker.hs+6−6
appveyor.ymlnew file+57
@@ -0,0 +1,57 @@
1+platform: x64
2+version: '{build}'
3+environment:
4+ # Keep the path as short as possible, just in case.
5+ STACK_ROOT: c:\s
6+ # Appveyor does not seem to be able to cope with the symbolic link
7+ # stack.yaml, so this is a workaround.
8+ STACK_YAML: stack-lts-5.yaml
9+ RELEASE_USER: purescript
10+ RELEASE_REPO: purescript
11+cache:
12+- c:\s
13+install:
14+- git submodule update --init
15+- ps: Install-Product node 5
16+- npm install -g bower
17+
18+- ps: |
19+ New-Item -ItemType Directory -Force -Path C:\tools
20+ $env:Path += ";C:\tools"
21+ (New-Object Net.WebClient).DownloadFile('https://www.stackage.org/stack/windows-x86_64', 'c:\tools\stack.zip')
22+ pushd c:\tools
23+ 7z x c:\tools\stack.zip stack.exe
24+ popd
25+
26+- stack --no-terminal --verbosity=error setup 1>stack-setup.log 2>&1 || type stack-setup.log
27+
28+build_script:
29+# Override the default build script.
30+- echo ""
31+test_script:
32+- stack -j1 --no-terminal test --pedantic
33+on_success:
34+# this seems to be necessary; if omitted, the bash script fails to find the
35+# tool 'strip'.
36+- copy C:\MinGW\bin\strip.exe C:\tools\strip.exe
37+- ps: |
38+ function UploadFile
39+ {
40+ github-release upload --user $env:RELEASE_USER --repo $env:RELEASE_REPO --tag $env:APPVEYOR_REPO_TAG_NAME --file $args[0] --name $args[0]
41+ }
42+
43+ if ($env:APPVEYOR_REPO_TAG_NAME)
44+ {
45+ bash ./bundle/build-stack.sh win64
46+
47+ (New-Object Net.WebClient).DownloadFile('https://github.com/aktau/github-release/releases/download/v0.6.2/windows-amd64-github-release.zip', 'c:\tools\github-release.zip')
48+ pushd c:\tools
49+ 7z x github-release.zip bin/windows/amd64/github-release.exe
50+ Copy-Item bin/windows/amd64/github-release.exe github-release.exe
51+ popd
52+
53+ pushd bundle
54+ UploadFile win64.tar.gz
55+ UploadFile win64.sha
56+ popd
57+ }
bundle/build-stack.sh+41−28
@@ -1,7 +1,8 @@
1+## This script can be run on any supported OS to create a binary .tar.gz
2+## bundle.
3+## For Windows, msysgit contains all of the pieces needed to run this script.
14set -e
25
3−SCRIPTPATH=$( cd "$(dirname "$0")" ; pwd -P )
4−
56OS=$1
67
78if [ -z $OS ]
@@ -10,39 +11,51 @@ then
1011 exit 1
1112fi
1213
13−pushd ${SCRIPTPATH} > /dev/null
14+pushd $(stack path --project-root)
15+
16+LOCAL_INSTALL_ROOT=$(stack path --local-install-root)
17+
18+if [ "$OS" = "win64" ]
19+then
20+ BIN_EXT=".exe"
21+else
22+ BIN_EXT=""
23+fi
1424
1525# Make the staging directory
16−mkdir -p build/purescript/
17−
18−# Strip the binaries
19−strip ~/.local/bin/psc
20−strip ~/.local/bin/psci
21−strip ~/.local/bin/psc-docs
22−strip ~/.local/bin/psc-publish
23−strip ~/.local/bin/psc-bundle
24−strip ~/.local/bin/psc-ide-server
25−strip ~/.local/bin/psc-ide-client
26−
27−# Copy files to staging directory
28−cp ~/.local/bin/psc build/purescript/
29−cp ~/.local/bin/psci build/purescript/
30−cp ~/.local/bin/psc-docs build/purescript/
31−cp ~/.local/bin/psc-publish build/purescript/
32−cp ~/.local/bin/psc-bundle build/purescript/
33−cp ~/.local/bin/psc-ide-server build/purescript/
34−cp ~/.local/bin/psc-ide-client build/purescript/
35−cp README build/purescript/
36−cp ../LICENSE build/purescript/
37−cp ../INSTALL.md build/purescript/
26+mkdir -p bundle/build/purescript
27+
28+# Strip the binaries, and copy them to the staging directory
29+for BIN in psc psci psc-docs psc-publish psc-bundle psc-ide-server psc-ide-client
30+do
31+ FULL_BIN="$LOCAL_INSTALL_ROOT/bin/${BIN}${BIN_EXT}"
32+ strip "$FULL_BIN" || true # not the end of the world if this fails, and
33+ # AppVeyor can't seem to handle it for some reason
34+ cp "$FULL_BIN" bundle/build/purescript
35+done
36+
37+# Copy extra files to the staging directory
38+cp bundle/README bundle/build/purescript/
39+cp LICENSE bundle/build/purescript/
40+cp INSTALL.md bundle/build/purescript/
41+
42+stack list-dependencies >bundle/build/purescript/dependencies.txt
3843
3944# Make the binary bundle
40−pushd build > /dev/null
41−tar -zcvf ../$OS.tar.gz purescript
45+pushd bundle/build > /dev/null
46+tar -zcvf ../${OS}.tar.gz purescript
4247popd > /dev/null
4348
4449# Calculate the SHA hash
45−shasum $OS.tar.gz > $OS.sha
50+if [ "$OS" = "win64" ]
51+then
52+ # msys/mingw does not include shasum. :(
53+ SHASUM="openssl dgst -sha1"
54+else
55+ SHASUM="shasum"
56+fi
57+
58+$SHASUM bundle/${OS}.tar.gz > bundle/${OS}.sha
4659
4760# Remove the staging directory
4861rm -rf build/
bundle/build.shdeleted−50
@@ -1,50 +0,0 @@
1−set -e
2−
3−SCRIPTPATH=$( cd "$(dirname "$0")" ; pwd -P )
4−
5−OS=$1
6−
7−if [ -z $OS ]
8−then
9− echo "Usage: build.sh osname"
10− exit 1
11−fi
12−
13−pushd ${SCRIPTPATH} > /dev/null
14−
15−# Make the staging directory
16−mkdir -p build/purescript/
17−
18−# Strip the binaries
19−strip ../dist/build/psc/psc
20−strip ../dist/build/psci/psci
21−strip ../dist/build/psc-docs/psc-docs
22−strip ../dist/build/psc-publish/psc-publish
23−strip ../dist/build/psc-bundle/psc-bundle
24−strip ../dist/build/psc-ide-server/psc-ide-server
25−strip ../dist/build/psc-ide-client/psc-ide-client
26−
27−# Copy files to staging directory
28−cp ../dist/build/psc/psc build/purescript/
29−cp ../dist/build/psci/psci build/purescript/
30−cp ../dist/build/psc-docs/psc-docs build/purescript/
31−cp ../dist/build/psc-publish/psc-publish build/purescript/
32−cp ../dist/build/psc-bundle/psc-bundle build/purescript/
33−cp ../dist/build/psc-ide-server/psc-ide-server build/purescript/
34−cp ../dist/build/psc-ide-client/psc-ide-client build/purescript/
35−cp README build/purescript/
36−cp ../LICENSE build/purescript/
37−cp ../INSTALL.md build/purescript/
38−
39−# Make the binary bundle
40−pushd build > /dev/null
41−tar -zcvf ../$OS.tar.gz purescript
42−popd > /dev/null
43−
44−# Calculate the SHA hash
45−shasum $OS.tar.gz > $OS.sha
46−
47−# Remove the staging directory
48−rm -rf build/
49−
50−popd > /dev/null
bundle/winbuild-stack.shdeleted−46
@@ -1,46 +0,0 @@
1−## This Windows-specific version of build.sh can be run in an msys environment
2−## to create a .tar.gz bundle for Windows users.
3−## msysgit contains all of the pieces needed to run this script.
4−
5−set -e
6−
7−SCRIPTPATH=$( cd "$(dirname "$0")" ; pwd -P )
8−
9−pushd ${SCRIPTPATH} > /dev/null
10−
11−# Make the staging directory
12−mkdir -p build/purescript/
13−
14−# Strip the binaries
15−strip $APPDATA/local/bin/psc.exe
16−strip $APPDATA/local/bin/psci.exe
17−strip $APPDATA/local/bin/psc-docs.exe
18−strip $APPDATA/local/bin/psc-publish.exe
19−strip $APPDATA/local/bin/psc-bundle.exe
20−strip $APPDATA/local/bin/psc-ide-server.exe
21−strip $APPDATA/local/bin/psc-ide-client.exe
22−
23−# Copy files to staging directory
24−cp $APPDATA/local/bin/psc.exe build/purescript/
25−cp $APPDATA/local/bin/psci.exe build/purescript/
26−cp $APPDATA/local/bin/psc-docs.exe build/purescript/
27−cp $APPDATA/local/bin/psc-publish.exe build/purescript/
28−cp $APPDATA/local/bin/psc-bundle.exe build/purescript/
29−cp $APPDATA/local/bin/psc-ide-server.exe build/purescript/
30−cp $APPDATA/local/bin/psc-ide-client.exe build/purescript/
31−cp README build/purescript/
32−cp ../LICENSE build/purescript/
33−cp ../INSTALL.md build/purescript/
34−
35−# Make the binary bundle
36−pushd build > /dev/null
37−tar -zcvf ../win64.tar.gz purescript
38−popd > /dev/null
39−
40−# Calculate the MD5 hash
41−md5sum win64.tar.gz > win64.md5
42−
43−# Remove the staging directory
44−rm -rf build/
45−
46−popd > /dev/null
bundle/winbuild.shdeleted−47
@@ -1,47 +0,0 @@
1−## This Windows-specific version of build.sh can be run in an msys environment
2−## to create a .tar.gz bundle for Windows users.
3−## msysgit contains all of the pieces needed to run this script.
4−
5−set -e
6−
7−SCRIPTPATH=$( cd "$(dirname "$0")" ; pwd -P )
8−
9−pushd ${SCRIPTPATH}
10−
11−# Make the staging directory
12−mkdir -p build/purescript/
13−
14−# Strip the binaries
15−strip ../dist/build/psc/psc.exe
16−strip ../dist/build/psci/psci.exe
17−strip ../dist/build/psc-docs/psc-docs.exe
18−strip ../dist/build/psc-publish/psc-publish.exe
19−strip ../dist/build/psc-bundle/psc-bundle.exe
20−strip ../dist/build/psc-ide-server/psc-ide-server.exe
21−strip ../dist/build/psc-ide-client/psc-ide-client.exe
22−
23−# Copy files to staging directory
24−cp ../dist/build/psc/psc.exe build/purescript/
25−cp ../dist/build/psci/psci.exe build/purescript/
26−cp ../dist/build/psc-docs/psc-docs.exe build/purescript/
27−cp ../dist/build/psc-publish/psc-publish.exe build/purescript/
28−cp ../dist/build/psc-bundle/psc-bundle.exe build/purescript/
29−cp ../dist/build/psc-ide-server/psc-ide-server.exe build/purescript/
30−cp ../dist/build/psc-ide-client/psc-ide-client.exe build/purescript/
31−cp README build/purescript/
32−cp ../LICENSE build/purescript/
33−cp ../INSTALL.md build/purescript/
34−
35−# Make the binary bundle
36−pushd build
37−tar -zcvf ../win64.tar.gz purescript
38−popd
39−
40−# Calculate the MD5 hash
41−md5sum win64.tar.gz > win64.md5
42−
43−# Remove the staging directory
44−rm -rf build/
45−
46−popd
47−
src/Language/PureScript/Errors.hs−6
@@ -139,7 +139,6 @@ data SimpleErrorMessage
139139 | DeprecatedQualifiedSyntax ModuleName ModuleName
140140 | DeprecatedClassImport ModuleName (ProperName 'ClassName)
141141 | DeprecatedClassExport (ProperName 'ClassName)
142− | RedundantUnqualifiedImport ModuleName ImportDeclarationType
143142 | DuplicateSelectiveImport ModuleName
144143 | DuplicateImport ModuleName ImportDeclarationType (Maybe ModuleName)
145144 | DuplicateImportRef String
@@ -323,7 +322,6 @@ errorCode em = case unwrapErrorMessage em of
323322 DeprecatedQualifiedSyntax{} -> "DeprecatedQualifiedSyntax"
324323 DeprecatedClassImport{} -> "DeprecatedClassImport"
325324 DeprecatedClassExport{} -> "DeprecatedClassExport"
326− RedundantUnqualifiedImport{} -> "RedundantUnqualifiedImport"
327325 DuplicateSelectiveImport{} -> "DuplicateSelectiveImport"
328326 DuplicateImport{} -> "DuplicateImport"
329327 DuplicateImportRef{} -> "DuplicateImportRef"
@@ -452,7 +450,6 @@ errorSuggestion err = case err of
452450 UnusedImport{} -> emptySuggestion
453451 RedundantEmptyHidingImport{} -> emptySuggestion
454452 DuplicateImport{} -> emptySuggestion
455− RedundantUnqualifiedImport{} -> emptySuggestion
456453 DeprecatedQualifiedSyntax name qualName -> suggest $
457454 "import " ++ runModuleName name ++ " as " ++ runModuleName qualName
458455 UnusedExplicitImport mn _ qual refs -> suggest $ importSuggestion mn refs qual
@@ -944,9 +941,6 @@ prettyPrintSingleError full level showWiki e = flip evalState defaultUnknownMap
944941 , line "The deprecated syntax will be removed in PureScript 0.9."
945942 ]
946943
947− renderSimpleErrorMessage (RedundantUnqualifiedImport name imp) =
948− line $ "Import of " ++ prettyPrintImport name imp Nothing ++ " is redundant due to a whole-module import"
949−
950944 renderSimpleErrorMessage (DuplicateSelectiveImport name) =
951945 line $ "There is an existing import of " ++ runModuleName name ++ ", consider merging the import lists"
952946
src/Language/PureScript/Ide/Types.hs+2−2
@@ -59,9 +59,9 @@ data ExternDecl
5959 [DeclIdent] -- The exported identifiers
6060 -- | A data/newtype declaration
6161 | DataConstructor
62− DeclIdent -- ^ The type name
62+ DeclIdent -- The type name
6363 (P.ProperName 'P.TypeName)
64− P.Type -- ^ The "type"
64+ P.Type -- The "type"
6565 -- | An exported module
6666 | TypeClassDeclaration (P.ProperName 'P.ClassName)
6767 | Export ModuleIdent -- The exported Modules name
src/Language/PureScript/Linter/Imports.hs+9−4
@@ -162,10 +162,15 @@ lintImports (Module _ _ mn mdecls mexports) env usedImps = do
162162 -> [(ModuleName, Name)]
163163 extractByQual k m toName = mapMaybe go (M.toList m)
164164 where
165− go (q@(Qualified mnq _), is) | isUnqualified q || isQualifiedWith k q =
166− case importName (head is) of
167− Qualified (Just mn') name -> Just (mn', toName $ Qualified mnq name)
168− _ -> internalError "unqualified name in extractByQual"
165+ go (q@(Qualified mnq _), is)
166+ | isUnqualified q =
167+ case find (isQualifiedWith k) (map importName is) of
168+ Just (Qualified _ name) -> Just (k, toName $ Qualified mnq name)
169+ _ -> Nothing
170+ | isQualifiedWith k q =
171+ case importName (head is) of
172+ Qualified (Just mn') name -> Just (mn', toName $ Qualified mnq name)
173+ _ -> internalError "unqualified name in extractByQual"
169174 go _ = Nothing
170175
171176lintImportDecl
src/Language/PureScript/Sugar/Names/Exports.hs+6−10
@@ -119,9 +119,10 @@ resolveExports env mn imps exps refs =
119119 extract useQual name render = fmap (map (importName . head . snd)) . go . M.toList
120120 where
121121 go = filterM $ \(name', options) -> do
122− let isMatch = if useQual then eqQual name name' else any (eqQual name . importName) options
122+ let isMatch = if useQual then isQualifiedWith name name' else any (checkUnqual name') options
123123 when (isMatch && length options > 1) $ void $ checkImportConflicts mn render options
124124 return isMatch
125+ checkUnqual name' ir = isUnqualified name' && isQualifiedWith name (importName ir)
125126
126127 -- Check whether a module name refers to a "pseudo module" that came into
127128 -- existence in an import scope due to importing one or more modules as
@@ -134,21 +135,16 @@ resolveExports env mn imps exps refs =
134135 -- value being re-exported belongs to a qualified module, and we test the
135136 -- values if that fails to see whether the value has been imported at all.
136137 testQuals :: (forall a b. M.Map (Qualified a) b -> [Qualified a]) -> ModuleName -> Bool
137− testQuals f mn' = any (eqQual mn') (f (importedTypes imps))
138− || any (eqQual mn') (f (importedDataConstructors imps))
139− || any (eqQual mn') (f (importedTypeClasses imps))
140− || any (eqQual mn') (f (importedValues imps))
138+ testQuals f mn' = any (isQualifiedWith mn') (f (importedTypes imps))
139+ || any (isQualifiedWith mn') (f (importedDataConstructors imps))
140+ || any (isQualifiedWith mn') (f (importedTypeClasses imps))
141+ || any (isQualifiedWith mn') (f (importedValues imps))
141142
142143 -- Check whether a module name refers to a module that has been imported
143144 -- without qualification into an import scope.
144145 isImportedModule :: ModuleName -> Bool
145146 isImportedModule = flip elem (importedModules imps)
146147
147− -- Check whether a module name matches that of a qualified value.
148− eqQual :: ModuleName -> Qualified a -> Bool
149− eqQual mn'' (Qualified (Just mn''') _) = mn'' == mn'''
150− eqQual _ _ = False
151−
152148 -- Constructs a list of types with their data constructors and the original
153149 -- module they were defined in from a list of type and data constructor names.
154150 resolveTypeExports
src/Language/PureScript/Sugar/Names/Imports.hs+23−25
@@ -12,9 +12,10 @@ module Language.PureScript.Sugar.Names.Imports
1212import Prelude ()
1313import Prelude.Compat
1414
15−import Data.List (find, delete, (\\))
16−import Data.Maybe (fromMaybe, isJust, isNothing, fromJust)
1715import Data.Foldable (traverse_, for_)
16+import Data.Function (on)
17+import Data.List (find, sortBy, groupBy, (\\))
18+import Data.Maybe (fromMaybe, isNothing, fromJust)
1819import Data.Traversable (for)
1920
2021import Control.Arrow (first)
@@ -68,29 +69,23 @@ resolveImports env (Module ss coms currentModule decls exps) =
6869
6970 for_ (M.toList imports) $ \(mn, imps) -> do
7071
71− -- Better ordering for the warnings: the list is in last-import-first
72− -- order, but we want the first appearence of an import to be the primary,
73− -- and warnings to appear for later imports
74− let imps' = reverse imps
75−
76− warned <- foldM (checkDuplicateImports mn) [] (selfCartesianSubset imps')
77−
78− let unqual = filter (\(_, _, q) -> isJust q) (imps' \\ warned)
79−
80− warned' <- (warned ++) <$>
81− if (length unqual < 2)
82− then return []
83− else case find (\(_, typ, _) -> isImplicit typ) unqual of
84− Just i ->
85− for (delete i unqual) $ \i'@(pos, typ, _) -> do
86− warn pos $ RedundantUnqualifiedImport mn typ
87− return i'
88− Nothing ->
89− for (tail unqual) $ \i@(pos, _, _) -> do
90− warn pos $ DuplicateSelectiveImport mn
91− return i
92−
93− for_ (imps' \\ warned') $ \(pos, typ, _) ->
72+ warned <- foldM (checkDuplicateImports mn) [] (selfCartesianSubset imps)
73+
74+ let unwarned = imps \\ warned
75+ duplicates
76+ = join
77+ . map tail
78+ . filter ((> 1) . length)
79+ . groupBy ((==) `on` defQual)
80+ . sortBy (compare `on` defQual)
81+ $ unwarned
82+
83+ warned' <-
84+ for duplicates $ \i@(pos, _, _) -> do
85+ warn pos $ DuplicateSelectiveImport mn
86+ return i
87+
88+ for_ (imps \\ (warned ++ warned')) $ \(pos, typ, _) ->
9489 let (dupeRefs, dupeDctors) = findDuplicateRefs $ case typ of
9590 Explicit refs -> refs
9691 Hiding refs -> refs
@@ -105,6 +100,9 @@ resolveImports env (Module ss coms currentModule decls exps) =
105100 return (Module ss coms currentModule decls' exps, resolved)
106101
107102 where
103+ defQual :: ImportDef -> Maybe ModuleName
104+ defQual (_, _, q) = q
105+
108106 selfCartesianSubset :: [a] -> [(a, a)]
109107 selfCartesianSubset (x : xs) = [(x, y) | y <- xs] ++ selfCartesianSubset xs
110108 selfCartesianSubset [] = []
src/Language/PureScript/TypeChecker.hs+6−6
@@ -191,23 +191,19 @@ typeCheckAll moduleName _ ds = traverse go ds <* traverse_ checkFixities ds
191191 go :: Declaration -> m Declaration
192192 go (DataDeclaration dtype name args dctors) = do
193193 warnAndRethrow (addHint (ErrorInTypeConstructor name)) $ do
194− when (dtype == Newtype) $ checkNewtype dctors
194+ when (dtype == Newtype) $ checkNewtype name dctors
195195 checkDuplicateTypeArguments $ map fst args
196196 ctorKind <- kindsOf True moduleName name args (concatMap snd dctors)
197197 let args' = args `withKinds` ctorKind
198198 addDataType moduleName dtype name args' dctors ctorKind
199199 return $ DataDeclaration dtype name args dctors
200− where
201− checkNewtype :: [(ProperName 'ConstructorName, [Type])] -> m ()
202− checkNewtype [(_, [_])] = return ()
203− checkNewtype [(_, _)] = throwError . errorMessage $ InvalidNewtype name
204− checkNewtype _ = throwError . errorMessage $ InvalidNewtype name
205200 go (d@(DataBindingGroupDeclaration tys)) = do
206201 warnAndRethrow (addHint ErrorInDataBindingGroup) $ do
207202 let syns = mapMaybe toTypeSynonym tys
208203 let dataDecls = mapMaybe toDataDecl tys
209204 (syn_ks, data_ks) <- kindsOfAll moduleName syns (map (\(_, name, args, dctors) -> (name, args, concatMap snd dctors)) dataDecls)
210205 for_ (zip dataDecls data_ks) $ \((dtype, name, args, dctors), ctorKind) -> do
206+ when (dtype == Newtype) $ checkNewtype name dctors
211207 checkDuplicateTypeArguments $ map fst args
212208 let args' = args `withKinds` ctorKind
213209 addDataType moduleName dtype name args' dctors ctorKind
@@ -327,6 +323,10 @@ typeCheckAll moduleName _ ds = traverse go ds <* traverse_ checkFixities ds
327323 checkType _ = internalError "Invalid type in instance in checkOrphanInstance"
328324 checkOrphanInstance _ _ _ = internalError "Unqualified class name in checkOrphanInstance"
329325
326+ checkNewtype :: ProperName 'TypeName -> [(ProperName 'ConstructorName, [Type])] -> m ()
327+ checkNewtype _ [(_, [_])] = return ()
328+ checkNewtype name _ = throwError . errorMessage $ InvalidNewtype name
329+
330330 -- |
331331 -- This function adds the argument kinds for a type constructor so that they may appear in the externs file,
332332 -- extracted from the kind of the type constructor itself.