on master help sign in
.github/CONTRIBUTING.md+18−20
since splitsnapshots
unifiedsplit
@@ -4,10 +4,15 @@ Thanks helping with the development of Elm! This document describes the basic
4standards for opening pull requests and making the review process as smooth as
4standards for opening pull requests and making the review process as smooth as
5possible.
5possible.
6
6
7−## Licensing
8
7
9−You need to sign the [contributor agreement](ContributorAgreement.pdf)
8+## Expectations
10−and send it to <info@elm-lang.org> before opening your pull request.
9+
10+- Pull requests are reviewed in [batches](https://github.com/elm/expectations/blob/master/batching.md), so it can take some time to get a response.
11+- Smaller pull requests are easier to review. To fix nine typos, nine specific issues will always go faster than one big one. Learn why [here](https://github.com/elm/expectations/blob/master/small-pull-requests.md).
12+- Reviewers may not know as much as you about certain situations, so add links to supporting evidence for important claims, especially regarding standards for CSS, HTTP, URI, etc.
13+
14+Finally, please be patient with the core team. They are trying their best with limited resources!
15+
11
16
12## Style Guide
17## Style Guide
13
18
@@ -17,27 +22,20 @@ and send it to <info@elm-lang.org> before opening your pull request.
17[haskell]: https://gist.github.com/evancz/0a1f3717c92fe71702be
22[haskell]: https://gist.github.com/evancz/0a1f3717c92fe71702be
18[js]: https://google.github.io/styleguide/javascriptguide.xml
23[js]: https://google.github.io/styleguide/javascriptguide.xml
19
24
20−## Branches
21
25
22− * [The master branch][master] is the home of the next release of the compiler
26+## Branches
23− so new features and improvements get merged there. Most pull requests
24− should target this branch!
25
27
26− * [The stable branch][stable] is for tagging releases and critical bug fixes.
28+[The master branch][master] is the home of the next release of the compiler
27− This branch is handy for folks who want to build the most recent public
29+so new features and improvements get merged there. Most pull requests
28− release from source.
30+should target this branch!
29
31
30[master]: http://github.com/elm-lang/elm/tree/master
32[master]: http://github.com/elm-lang/elm/tree/master
31−[stable]: http://github.com/elm-lang/elm/tree/stable
32
33
33−If you are working on a fairly large feature, we will probably want to merge it
34−in as its own branch and do some testing before bringing it into the master
35−branch. This way we can keep releases of the master branch independent of new
36−features.
37
34
38−Note that the master branch of the compiler should always be in sync with the
35+## Licensing
39−master branch of the [website][], and the stable branch of the compiler should
36+
40−always be in sync with the stable branch of the [website][]. Make sure that
37+Nothing extra to do for this. The default on GitHub described [here](https://docs.github.com/en/github/site-policy/github-terms-of-service#6-contributions-under-repository-license) is that:
41−your changes maintain this compatibility.
38+
39+> Whenever you add Content to a repository containing notice of a license, you license that Content under the same terms, and you agree that you have the right to license that Content under those terms. If you have a separate agreement to license that Content under different terms, such as a contributor license agreement, that agreement will supersede.
40+
42
41
43−[website]: https://github.com/elm-lang/elm-lang.org
.github/workflows/set-issue-expectations.ymlnew file+21
@@ -0,0 +1,21 @@
1+name: Set Issue Expectations
2+on:
3+ issues:
4+ types: [opened]
5+jobs:
6+ comment-on-issue:
7+ name: Comment On Issue
8+ runs-on: ubuntu-latest
9+ steps:
10+ - uses: actions/github@v1.0.0
11+ env:
12+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+ with:
14+ args: |
15+ comment "Thanks for reporting this! To set expectations:
16+
17+ - Issues are reviewed in [batches](https://github.com/elm/expectations/blob/master/batching.md), so it can take some time to get a response.
18+ - Ask questions in a [community forum](https://elm-lang.org/community). You will get an answer quicker that way!
19+ - If you experience something similar, open a new issue. [We like duplicates](https://github.com/elm/expectations/blob/master/duplicates.md).
20+
21+ Finally, please be patient with the core team. They are trying their best with limited resources."
.github/workflows/set-pull-expectations.ymlnew file+19
@@ -0,0 +1,19 @@
1+on:
2+ pull_request_target:
3+ types: [opened]
4+
5+jobs:
6+ comment-on-pull:
7+ name: Comment On Pull
8+ runs-on: ubuntu-latest
9+ steps:
10+ - uses: actions/github-script@v3
11+ with:
12+ github-token: ${{secrets.GITHUB_TOKEN}}
13+ script: |
14+ github.issues.createComment({
15+ issue_number: context.issue.number,
16+ owner: context.repo.owner,
17+ repo: context.repo.repo,
18+ body: "Thanks for suggesting these code changes. To set expectations:\n\n- Pull requests are reviewed in [batches](https://github.com/elm/expectations/blob/master/batching.md), so it can take some time to get a response.\n- Smaller pull requests are easier to review. To fix nine typos, nine specific issues will always go faster than one big one. Learn why [here](https://github.com/elm/expectations/blob/master/small-pull-requests.md).\n- Reviewers may not know as much as you about certain situations, so add links to supporting evidence for important claims, especially regarding standards for CSS, HTTP, URI, etc.\n\nFinally, please be patient with the core team. They are trying their best with limited resources."
19+ })
.gitignore+1
@@ -5,3 +5,4 @@ cabal-dev
5cabal.sandbox.config
5cabal.sandbox.config
6.DS_Store
6.DS_Store
7*~
7*~
8+travis.log
.travis.ymlnew file+28
@@ -0,0 +1,28 @@
1+language: minimal
2+services: docker
3+
4+env:
5+ global:
6+ - LINUX_ARCHIVE=binary-for-linux-64-bit.gz
7+
8+before_install:
9+ - docker build -t elm -f installers/linux/Dockerfile .
10+ - docker cp $(docker create elm):/usr/local/bin/elm .
11+ - gzip -9 -c elm > $LINUX_ARCHIVE
12+
13+deploy:
14+ provider: releases
15+ api_key:
16+ secure: Yz2Lo4u9rZQ7Ee7ohAsrZpkqsYDUerCSMdSQIH8ryrf7phHhiloPEkTKsM+NupHqU/LEAVsunxbau4QrCEjA2vPavAPVk8cKomRUWK/YjbXHKa24hPkal2c+A2bnMQ6w3qYk/PjL9rW+Goq++/SNLcYZwHBV0Chl2blivMwWCSA=
17+ file: $LINUX_ARCHIVE
18+ skip_cleanup: true
19+ on:
20+ branch: master
21+ tags: true
22+
23+notifications:
24+ email:
25+ recipients:
26+ - rlefevre@dmy.fr
27+ on_success: change
28+ on_failure: change
ContributorAgreement.pdfdeleted

Binary file not shown.

README.md+10−5
@@ -1,17 +1,22 @@
1−# The Elm Compiler
1+# Elm
2
2
3−Learn about the Elm programming language at [elm-lang.org](http://elm-lang.org/).
3+A delightful language for reliable webapps.
4
4
5+Check out the [Home Page](http://elm-lang.org/), [Try Online](http://elm-lang.org/try), or [The Official Guide](http://guide.elm-lang.org/)
6+
7+
8+<br>
5
9
6## Install
10## Install
7
11
8−Follow [these instructions][installer]!
12+✨ [Install](https://guide.elm-lang.org/install/elm.html) ✨
9
13
10− [installer]: https://guide.elm-lang.org/install.html
14+For multiple versions, previous versions, and uninstallation, see the instructions [here](https://github.com/elm/compiler/blob/master/installers/README.md).
11
15
16+<br>
12
17
13## Help
18## Help
14
19
15If you are stuck, ask around on [the Elm slack channel][slack]. Folks are friendly and happy to help with questions!
20If you are stuck, ask around on [the Elm slack channel][slack]. Folks are friendly and happy to help with questions!
16
21
17−[slack]: http://elmlang.herokuapp.com/
22+[slack]: http://elmlang.herokuapp.com/
builder/src/Build.hs+89−89
@@ -2,15 +2,15 @@
2{-# LANGUAGE BangPatterns, GADTs, OverloadedStrings #-}
2{-# LANGUAGE BangPatterns, GADTs, OverloadedStrings #-}
3module Build
3module Build
4 ( fromExposed
4 ( fromExposed
5− , fromMains
5+ , fromPaths
6 , fromRepl
6 , fromRepl
7 , Artifacts(..)
7 , Artifacts(..)
8− , Main(..)
8+ , Root(..)
9 , Module(..)
9 , Module(..)
10 , CachedInterface(..)
10 , CachedInterface(..)
11 , ReplArtifacts(..)
11 , ReplArtifacts(..)
12 , DocsGoal(..)
12 , DocsGoal(..)
13− , getMainNames
13+ , getRootNames
14 )
14 )
15 where
15 where
16
16
@@ -164,14 +164,14 @@ fromExposed style root details docsGoal exposed@(NE.List e es) =
164
164
165
165
166
166
167−-- FROM MAINS
167+-- FROM PATHS
168
168
169
169
170data Artifacts =
170data Artifacts =
171 Artifacts
171 Artifacts
172 { _name :: Pkg.Name
172 { _name :: Pkg.Name
173 , _deps :: Dependencies
173 , _deps :: Dependencies
174− , _mains :: NE.List Main
174+ , _roots :: NE.List Root
175 , _modules :: [Module]
175 , _modules :: [Module]
176 }
176 }
177
177
@@ -185,25 +185,25 @@ type Dependencies =
185 Map.Map ModuleName.Canonical I.DependencyInterface
185 Map.Map ModuleName.Canonical I.DependencyInterface
186
186
187
187
188−fromMains :: Reporting.Style -> FilePath -> Details.Details -> NE.List FilePath -> IO (Either Exit.BuildProblem Artifacts)
188+fromPaths :: Reporting.Style -> FilePath -> Details.Details -> NE.List FilePath -> IO (Either Exit.BuildProblem Artifacts)
189−fromMains style root details paths =
189+fromPaths style root details paths =
190 Reporting.trackBuild style $ \key ->
190 Reporting.trackBuild style $ \key ->
191 do env <- makeEnv key root details
191 do env <- makeEnv key root details
192
192
193− elmains <- findMains env paths
193+ elroots <- findRoots env paths
194− case elmains of
194+ case elroots of
195 Left problem ->
195 Left problem ->
196 return (Left (Exit.BuildProjectProblem problem))
196 return (Left (Exit.BuildProjectProblem problem))
197
197
198− Right lmains ->
198+ Right lroots ->
199 do -- crawl
199 do -- crawl
200 dmvar <- Details.loadInterfaces root details
200 dmvar <- Details.loadInterfaces root details
201 smvar <- newMVar Map.empty
201 smvar <- newMVar Map.empty
202− smainMVars <- traverse (fork . crawlMain env smvar) lmains
202+ srootMVars <- traverse (fork . crawlRoot env smvar) lroots
203− smains <- traverse readMVar smainMVars
203+ sroots <- traverse readMVar srootMVars
204 statuses <- traverse readMVar =<< readMVar smvar
204 statuses <- traverse readMVar =<< readMVar smvar
205
205
206− midpoint <- checkMainsMidpoint dmvar statuses smains
206+ midpoint <- checkMidpointAndRoots dmvar statuses sroots
207 case midpoint of
207 case midpoint of
208 Left problem ->
208 Left problem ->
209 return (Left (Exit.BuildProjectProblem problem))
209 return (Left (Exit.BuildProjectProblem problem))
@@ -213,24 +213,24 @@ fromMains style root details paths =
213 rmvar <- newEmptyMVar
213 rmvar <- newEmptyMVar
214 resultsMVars <- forkWithKey (checkModule env foreigns rmvar) statuses
214 resultsMVars <- forkWithKey (checkModule env foreigns rmvar) statuses
215 putMVar rmvar resultsMVars
215 putMVar rmvar resultsMVars
216− rmainMVars <- traverse (fork . checkMain env resultsMVars) smains
216+ rrootMVars <- traverse (fork . checkRoot env resultsMVars) sroots
217 results <- traverse readMVar resultsMVars
217 results <- traverse readMVar resultsMVars
218 writeDetails root details results
218 writeDetails root details results
219− toArtifacts env foreigns results <$> traverse readMVar rmainMVars
219+ toArtifacts env foreigns results <$> traverse readMVar rrootMVars
220
220
221
221
222
222
223−-- GET MAIN NAMES
223+-- GET ROOT NAMES
224
224
225
225
226−getMainNames :: Artifacts -> NE.List ModuleName.Raw
226+getRootNames :: Artifacts -> NE.List ModuleName.Raw
227−getMainNames (Artifacts _ _ mains _) =
227+getRootNames (Artifacts _ _ roots _) =
228− fmap getMainName mains
228+ fmap getRootName roots
229
229
230
230
231−getMainName :: Main -> ModuleName.Raw
231+getRootName :: Root -> ModuleName.Raw
232−getMainName main =
232+getRootName root =
233− case main of
233+ case root of
234 Inside name -> name
234 Inside name -> name
235 Outside name _ _ -> name
235 Outside name _ _ -> name
236
236
@@ -585,11 +585,11 @@ checkMidpoint dmvar statuses =
585 return (Left (Exit.BP_Cycle name names))
585 return (Left (Exit.BP_Cycle name names))
586
586
587
587
588−checkMainsMidpoint :: MVar (Maybe Dependencies) -> Map.Map ModuleName.Raw Status -> NE.List MainStatus -> IO (Either Exit.BuildProjectProblem Dependencies)
588+checkMidpointAndRoots :: MVar (Maybe Dependencies) -> Map.Map ModuleName.Raw Status -> NE.List RootStatus -> IO (Either Exit.BuildProjectProblem Dependencies)
589−checkMainsMidpoint dmvar statuses smains =
589+checkMidpointAndRoots dmvar statuses sroots =
590 case checkForCycles statuses of
590 case checkForCycles statuses of
591 Nothing ->
591 Nothing ->
592− case checkUniqueMains statuses smains of
592+ case checkUniqueRoots statuses sroots of
593 Nothing ->
593 Nothing ->
594 do maybeForeigns <- readMVar dmvar
594 do maybeForeigns <- readMVar dmvar
595 case maybeForeigns of
595 case maybeForeigns of
@@ -651,14 +651,14 @@ addToGraph name status graph =
651
651
652
652
653
653
654−-- CHECK UNIQUE MAINS
654+-- CHECK UNIQUE ROOTS
655
655
656
656
657−checkUniqueMains :: Map.Map ModuleName.Raw Status -> NE.List MainStatus -> Maybe Exit.BuildProjectProblem
657+checkUniqueRoots :: Map.Map ModuleName.Raw Status -> NE.List RootStatus -> Maybe Exit.BuildProjectProblem
658−checkUniqueMains insides smains =
658+checkUniqueRoots insides sroots =
659 let
659 let
660 outsidesDict =
660 outsidesDict =
661− Map.fromListWith OneOrMore.more (Maybe.mapMaybe mainStatusToNamePathPair (NE.toList smains))
661+ Map.fromListWith OneOrMore.more (Maybe.mapMaybe rootStatusToNamePathPair (NE.toList sroots))
662 in
662 in
663 case Map.traverseWithKey checkOutside outsidesDict of
663 case Map.traverseWithKey checkOutside outsidesDict of
664 Left problem ->
664 Left problem ->
@@ -670,9 +670,9 @@ checkUniqueMains insides smains =
670 Left problem -> Just problem
670 Left problem -> Just problem
671
671
672
672
673−mainStatusToNamePathPair :: MainStatus -> Maybe (ModuleName.Raw, OneOrMore.OneOrMore FilePath)
673+rootStatusToNamePathPair :: RootStatus -> Maybe (ModuleName.Raw, OneOrMore.OneOrMore FilePath)
674−mainStatusToNamePathPair smain =
674+rootStatusToNamePathPair sroot =
675− case smain of
675+ case sroot of
676 SInside _ -> Nothing
676 SInside _ -> Nothing
677 SOutsideOk (Details.Local path _ _ _ _ _) _ modul -> Just (Src.getName modul, OneOrMore.one path)
677 SOutsideOk (Details.Local path _ _ _ _ _) _ modul -> Just (Src.getName modul, OneOrMore.one path)
678 SOutsideErr _ -> Nothing
678 SOutsideErr _ -> Nothing
@@ -682,14 +682,14 @@ checkOutside :: ModuleName.Raw -> OneOrMore.OneOrMore FilePath -> Either Exit.Bu
682checkOutside name paths =
682checkOutside name paths =
683 case OneOrMore.destruct NE.List paths of
683 case OneOrMore.destruct NE.List paths of
684 NE.List p [] -> Right p
684 NE.List p [] -> Right p
685− NE.List p1 (p2:_) -> Left (Exit.BP_MainNameDuplicate name p1 p2)
685+ NE.List p1 (p2:_) -> Left (Exit.BP_RootNameDuplicate name p1 p2)
686
686
687
687
688checkInside :: ModuleName.Raw -> FilePath -> Status -> Either Exit.BuildProjectProblem ()
688checkInside :: ModuleName.Raw -> FilePath -> Status -> Either Exit.BuildProjectProblem ()
689checkInside name p1 status =
689checkInside name p1 status =
690 case status of
690 case status of
691− SCached (Details.Local p2 _ _ _ _ _) -> Left (Exit.BP_MainNameDuplicate name p1 p2)
691+ SCached (Details.Local p2 _ _ _ _ _) -> Left (Exit.BP_RootNameDuplicate name p1 p2)
692− SChanged (Details.Local p2 _ _ _ _ _) _ _ _ -> Left (Exit.BP_MainNameDuplicate name p1 p2)
692+ SChanged (Details.Local p2 _ _ _ _ _) _ _ _ -> Left (Exit.BP_RootNameDuplicate name p1 p2)
693 SBadImport _ -> Right ()
693 SBadImport _ -> Right ()
694 SBadSyntax _ _ _ _ -> Right ()
694 SBadSyntax _ _ _ _ -> Right ()
695 SForeign _ -> Right ()
695 SForeign _ -> Right ()
@@ -964,25 +964,25 @@ finalizeReplArtifacts env@(Env _ root projectType _ _ _ _) source modul@(Src.Mod
964
964
965
965
966
966
967−-- FIND MAIN
967+-- FIND ROOT
968
968
969
969
970−data MainLocation
970+data RootLocation
971 = LInside ModuleName.Raw
971 = LInside ModuleName.Raw
972 | LOutside FilePath
972 | LOutside FilePath
973
973
974
974
975−findMains :: Env -> NE.List FilePath -> IO (Either Exit.BuildProjectProblem (NE.List MainLocation))
975+findRoots :: Env -> NE.List FilePath -> IO (Either Exit.BuildProjectProblem (NE.List RootLocation))
976−findMains env paths =
976+findRoots env paths =
977− do mvars <- traverse (fork . findLocation env) paths
977+ do mvars <- traverse (fork . getRootInfo env) paths
978− elocs <- traverse readMVar mvars
978+ einfos <- traverse readMVar mvars
979− return $ checkLocations =<< sequence elocs
979+ return $ checkRoots =<< sequence einfos
980
980
981
981
982−checkLocations :: NE.List Location -> Either Exit.BuildProjectProblem (NE.List MainLocation)
982+checkRoots :: NE.List RootInfo -> Either Exit.BuildProjectProblem (NE.List RootLocation)
983−checkLocations locations =
983+checkRoots infos =
984 let
984 let
985− toOneOrMore loc@(Location absolute _ _) =
985+ toOneOrMore loc@(RootInfo absolute _ _) =
986 (absolute, OneOrMore.one loc)
986 (absolute, OneOrMore.one loc)
987
987
988 fromOneOrMore loc locs =
988 fromOneOrMore loc locs =
@@ -990,33 +990,33 @@ checkLocations locations =
990 [] -> Right ()
990 [] -> Right ()
991 loc2:_ -> Left (Exit.BP_MainPathDuplicate (_relative loc) (_relative loc2))
991 loc2:_ -> Left (Exit.BP_MainPathDuplicate (_relative loc) (_relative loc2))
992 in
992 in
993− fmap (\_ -> fmap _location locations) $
993+ fmap (\_ -> fmap _location infos) $
994 traverse (OneOrMore.destruct fromOneOrMore) $
994 traverse (OneOrMore.destruct fromOneOrMore) $
995− Map.fromListWith OneOrMore.more $ map toOneOrMore (NE.toList locations)
995+ Map.fromListWith OneOrMore.more $ map toOneOrMore (NE.toList infos)
996
996
997
997
998
998
999−-- LOCATIONS
999+-- ROOT INFO
1000
1000
1001
1001
1002−data Location =
1002+data RootInfo =
1003− Location
1003+ RootInfo
1004 { _absolute :: FilePath
1004 { _absolute :: FilePath
1005 , _relative :: FilePath
1005 , _relative :: FilePath
1006− , _location :: MainLocation
1006+ , _location :: RootLocation
1007 }
1007 }
1008
1008
1009
1009
1010−findLocation :: Env -> FilePath -> IO (Either Exit.BuildProjectProblem Location)
1010+getRootInfo :: Env -> FilePath -> IO (Either Exit.BuildProjectProblem RootInfo)
1011−findLocation env path =
1011+getRootInfo env path =
1012 do exists <- File.exists path
1012 do exists <- File.exists path
1013 if exists
1013 if exists
1014− then findLoc env path =<< Dir.canonicalizePath path
1014+ then getRootInfoHelp env path =<< Dir.canonicalizePath path
1015 else return (Left (Exit.BP_PathUnknown path))
1015 else return (Left (Exit.BP_PathUnknown path))
1016
1016
1017
1017
1018−findLoc :: Env -> FilePath -> FilePath -> IO (Either Exit.BuildProjectProblem Location)
1018+getRootInfoHelp :: Env -> FilePath -> FilePath -> IO (Either Exit.BuildProjectProblem RootInfo)
1019−findLoc (Env _ root _ srcDirs _ _ _) path absolutePath =
1019+getRootInfoHelp (Env _ _ _ srcDirs _ _ _) path absolutePath =
1020 let
1020 let
1021 (dirs, file) = FP.splitFileName absolutePath
1021 (dirs, file) = FP.splitFileName absolutePath
1022 (final, ext) = FP.splitExtension file
1022 (final, ext) = FP.splitExtension file
@@ -1030,7 +1030,7 @@ findLoc (Env _ root _ srcDirs _ _ _) path absolutePath =
1030 in
1030 in
1031 case Maybe.mapMaybe (isInsideSrcDirByPath absoluteSegments) srcDirs of
1031 case Maybe.mapMaybe (isInsideSrcDirByPath absoluteSegments) srcDirs of
1032 [] ->
1032 [] ->
1033− return $ Right $ Location absolutePath path (LOutside path)
1033+ return $ Right $ RootInfo absolutePath path (LOutside path)
1034
1034
1035 [(_, Right names)] ->
1035 [(_, Right names)] ->
1036 do let name = Name.fromChars (List.intercalate "." names)
1036 do let name = Name.fromChars (List.intercalate "." names)
@@ -1039,13 +1039,13 @@ findLoc (Env _ root _ srcDirs _ _ _) path absolutePath =
1039 d1:d2:_ ->
1039 d1:d2:_ ->
1040 do let p1 = addRelative d1 (FP.joinPath names <.> "elm")
1040 do let p1 = addRelative d1 (FP.joinPath names <.> "elm")
1041 let p2 = addRelative d2 (FP.joinPath names <.> "elm")
1041 let p2 = addRelative d2 (FP.joinPath names <.> "elm")
1042− return $ Left $ Exit.BP_MainNameDuplicate name p1 p2
1042+ return $ Left $ Exit.BP_RootNameDuplicate name p1 p2
1043
1043
1044 _ ->
1044 _ ->
1045− return $ Right $ Location absolutePath path (LInside name)
1045+ return $ Right $ RootInfo absolutePath path (LInside name)
1046
1046
1047 [(s, Left names)] ->
1047 [(s, Left names)] ->
1048− return $ Left $ Exit.BP_MainNameInvalid path s names
1048+ return $ Left $ Exit.BP_RootNameInvalid path s names
1049
1049
1050 (s1,_):(s2,_):_ ->
1050 (s1,_):(s2,_):_ ->
1051 return $ Left $ Exit.BP_WithAmbiguousSrcDir path s1 s2
1051 return $ Left $ Exit.BP_WithAmbiguousSrcDir path s1 s2
@@ -1094,18 +1094,18 @@ dropPrefix roots paths =
1094
1094
1095
1095
1096
1096
1097−-- CRAWL MAINS
1097+-- CRAWL ROOTS
1098
1098
1099
1099
1100−data MainStatus
1100+data RootStatus
1101 = SInside ModuleName.Raw
1101 = SInside ModuleName.Raw
1102 | SOutsideOk Details.Local B.ByteString Src.Module
1102 | SOutsideOk Details.Local B.ByteString Src.Module
1103 | SOutsideErr Error.Module
1103 | SOutsideErr Error.Module
1104
1104
1105
1105
1106−crawlMain :: Env -> MVar StatusDict -> MainLocation -> IO MainStatus
1106+crawlRoot :: Env -> MVar StatusDict -> RootLocation -> IO RootStatus
1107−crawlMain env@(Env _ _ projectType _ buildID _ _) mvar given =
1107+crawlRoot env@(Env _ _ projectType _ buildID _ _) mvar root =
1108− case given of
1108+ case root of
1109 LInside name ->
1109 LInside name ->
1110 do statusMVar <- newEmptyMVar
1110 do statusMVar <- newEmptyMVar
1111 statusDict <- takeMVar mvar
1111 statusDict <- takeMVar mvar
@@ -1128,19 +1128,19 @@ crawlMain env@(Env _ _ projectType _ buildID _ _) mvar given =
1128
1128
1129
1129
1130
1130
1131−-- CHECK MAINS
1131+-- CHECK ROOTS
1132
1132
1133
1133
1134−data MainResult
1134+data RootResult
1135 = RInside ModuleName.Raw
1135 = RInside ModuleName.Raw
1136 | ROutsideOk ModuleName.Raw I.Interface Opt.LocalGraph
1136 | ROutsideOk ModuleName.Raw I.Interface Opt.LocalGraph
1137 | ROutsideErr Error.Module
1137 | ROutsideErr Error.Module
1138 | ROutsideBlocked
1138 | ROutsideBlocked
1139
1139
1140
1140
1141−checkMain :: Env -> ResultDict -> MainStatus -> IO MainResult
1141+checkRoot :: Env -> ResultDict -> RootStatus -> IO RootResult
1142−checkMain env@(Env _ root _ _ _ _ _) results pendingMain =
1142+checkRoot env@(Env _ root _ _ _ _ _) results rootStatus =
1143− case pendingMain of
1143+ case rootStatus of
1144 SInside name ->
1144 SInside name ->
1145 return (RInside name)
1145 return (RInside name)
1146
1146
@@ -1167,7 +1167,7 @@ checkMain env@(Env _ root _ _ _ _ _) results pendingMain =
1167 Error.BadImports (toImportErrors env results imports problems)
1167 Error.BadImports (toImportErrors env results imports problems)
1168
1168
1169
1169
1170−compileOutside :: Env -> Details.Local -> B.ByteString -> Map.Map ModuleName.Raw I.Interface -> Src.Module -> IO MainResult
1170+compileOutside :: Env -> Details.Local -> B.ByteString -> Map.Map ModuleName.Raw I.Interface -> Src.Module -> IO RootResult
1171compileOutside (Env key _ projectType _ _ _ _) (Details.Local path time _ _ _ _) source ifaces modul =
1171compileOutside (Env key _ projectType _ _ _ _) (Details.Local path time _ _ _ _) source ifaces modul =
1172 let
1172 let
1173 pkg = projectTypeToPkg projectType
1173 pkg = projectTypeToPkg projectType
@@ -1186,35 +1186,35 @@ compileOutside (Env key _ projectType _ _ _ _) (Details.Local path time _ _ _ _)
1186-- TO ARTIFACTS
1186-- TO ARTIFACTS
1187
1187
1188
1188
1189−data Main
1189+data Root
1190 = Inside ModuleName.Raw
1190 = Inside ModuleName.Raw
1191 | Outside ModuleName.Raw I.Interface Opt.LocalGraph
1191 | Outside ModuleName.Raw I.Interface Opt.LocalGraph
1192
1192
1193
1193
1194−toArtifacts :: Env -> Dependencies -> Map.Map ModuleName.Raw Result -> NE.List MainResult -> Either Exit.BuildProblem Artifacts
1194+toArtifacts :: Env -> Dependencies -> Map.Map ModuleName.Raw Result -> NE.List RootResult -> Either Exit.BuildProblem Artifacts
1195−toArtifacts (Env _ root projectType _ _ _ _) foreigns results mainResults =
1195+toArtifacts (Env _ root projectType _ _ _ _) foreigns results rootResults =
1196− case gatherProblemsOrMains results mainResults of
1196+ case gatherProblemsOrMains results rootResults of
1197 Left (NE.List e es) ->
1197 Left (NE.List e es) ->
1198 Left (Exit.BuildBadModules root e es)
1198 Left (Exit.BuildBadModules root e es)
1199
1199
1200− Right mains ->
1200+ Right roots ->
1201− Right $ Artifacts (projectTypeToPkg projectType) foreigns mains $
1201+ Right $ Artifacts (projectTypeToPkg projectType) foreigns roots $
1202− Map.foldrWithKey addInside (foldr addOutside [] mainResults) results
1202+ Map.foldrWithKey addInside (foldr addOutside [] rootResults) results
1203
1203
1204
1204
1205−gatherProblemsOrMains :: Map.Map ModuleName.Raw Result -> NE.List MainResult -> Either (NE.List Error.Module) (NE.List Main)
1205+gatherProblemsOrMains :: Map.Map ModuleName.Raw Result -> NE.List RootResult -> Either (NE.List Error.Module) (NE.List Root)
1206−gatherProblemsOrMains results (NE.List mainResult mainResults) =
1206+gatherProblemsOrMains results (NE.List rootResult rootResults) =
1207 let
1207 let
1208− sortMain result (es, mains) =
1208+ addResult result (es, roots) =
1209 case result of
1209 case result of
1210− RInside n -> ( es, Inside n : mains)
1210+ RInside n -> ( es, Inside n : roots)
1211− ROutsideOk n i o -> ( es, Outside n i o : mains)
1211+ ROutsideOk n i o -> ( es, Outside n i o : roots)
1212− ROutsideErr e -> (e:es, mains)
1212+ ROutsideErr e -> (e:es, roots)
1213− ROutsideBlocked -> ( es, mains)
1213+ ROutsideBlocked -> ( es, roots)
1214
1214
1215 errors = Map.foldr addErrors [] results
1215 errors = Map.foldr addErrors [] results
1216 in
1216 in
1217− case (mainResult, foldr sortMain (errors, []) mainResults) of
1217+ case (rootResult, foldr addResult (errors, []) rootResults) of
1218 (RInside n , ( [], ms)) -> Right (NE.List (Inside n) ms)
1218 (RInside n , ( [], ms)) -> Right (NE.List (Inside n) ms)
1219 (RInside _ , (e:es, _ )) -> Left (NE.List e es)
1219 (RInside _ , (e:es, _ )) -> Left (NE.List e es)
1220 (ROutsideOk n i o, ( [], ms)) -> Right (NE.List (Outside n i o) ms)
1220 (ROutsideOk n i o, ( [], ms)) -> Right (NE.List (Outside n i o) ms)
@@ -1242,9 +1242,9 @@ badInside name =
1242 "Error from `" ++ Name.toChars name ++ "` should have been reported already."
1242 "Error from `" ++ Name.toChars name ++ "` should have been reported already."
1243
1243
1244
1244
1245−addOutside :: MainResult -> [Module] -> [Module]
1245+addOutside :: RootResult -> [Module] -> [Module]
1246−addOutside main modules =
1246+addOutside root modules =
1247− case main of
1247+ case root of
1248 RInside _ -> modules
1248 RInside _ -> modules
1249 ROutsideOk name iface objs -> Fresh name iface objs : modules
1249 ROutsideOk name iface objs -> Fresh name iface objs : modules
1250 ROutsideErr _ -> modules
1250 ROutsideErr _ -> modules
builder/src/Generate.hs+6−6
@@ -99,18 +99,18 @@ checkForDebugUses (Objects _ locals) =
99-- GATHER MAINS
99-- GATHER MAINS
100
100
101
101
102−gatherMains :: Pkg.Name -> Objects -> NE.List Build.Main -> Map.Map ModuleName.Canonical Opt.Main
102+gatherMains :: Pkg.Name -> Objects -> NE.List Build.Root -> Map.Map ModuleName.Canonical Opt.Main
103−gatherMains pkg (Objects _ locals) buildMains =
103+gatherMains pkg (Objects _ locals) roots =
104− Map.fromList $ Maybe.mapMaybe (lookupMain pkg locals) (NE.toList buildMains)
104+ Map.fromList $ Maybe.mapMaybe (lookupMain pkg locals) (NE.toList roots)
105
105
106
106
107−lookupMain :: Pkg.Name -> Map.Map ModuleName.Raw Opt.LocalGraph -> Build.Main -> Maybe (ModuleName.Canonical, Opt.Main)
107+lookupMain :: Pkg.Name -> Map.Map ModuleName.Raw Opt.LocalGraph -> Build.Root -> Maybe (ModuleName.Canonical, Opt.Main)
108−lookupMain pkg locals buildMain =
108+lookupMain pkg locals root =
109 let
109 let
110 toPair name (Opt.LocalGraph maybeMain _ _) =
110 toPair name (Opt.LocalGraph maybeMain _ _) =
111 (,) (ModuleName.Canonical pkg name) <$> maybeMain
111 (,) (ModuleName.Canonical pkg name) <$> maybeMain
112 in
112 in
113− case buildMain of
113+ case root of
114 Build.Inside name -> toPair name =<< Map.lookup name locals
114 Build.Inside name -> toPair name =<< Map.lookup name locals
115 Build.Outside name _ g -> toPair name g
115 Build.Outside name _ g -> toPair name g
116
116
builder/src/Http.hs+1−1
@@ -241,4 +241,4 @@ jsonPart name filePath value =
241
241
242stringPart :: String -> String -> Multi.Part
242stringPart :: String -> String -> Multi.Part
243stringPart name string =
243stringPart name string =
244− Multi.partBS (String.fromString name) (BS.pack string)
244+ Multi.partBS (String.fromString name) (BS.pack string)
builder/src/Reporting/Exit.hs+10−12
@@ -1282,8 +1282,7 @@ toDetailsReport details =
1282 "The dependencies in your elm.json are not compatible."
1282 "The dependencies in your elm.json are not compatible."
1283 [ D.fillSep
1283 [ D.fillSep
1284 ["Did","you","change","them","by","hand?","Try","to","change","it","back!"
1284 ["Did","you","change","them","by","hand?","Try","to","change","it","back!"
1285− ,"It","is","much","more","reliable","to","add","dependencies","with",D.green "elm install"
1285+ ,"It","is","much","more","reliable","to","add","dependencies","with",D.green "elm install" <> "."
1286− ,"or","the","dependency","management","tool","in",D.green "elm reactor" <> "."
1287 ]
1286 ]
1288 , D.reflow $
1287 , D.reflow $
1289 "Please ask for help on the community forums if you try those paths and are still\
1288 "Please ask for help on the community forums if you try those paths and are still\
@@ -1300,8 +1299,7 @@ toDetailsReport details =
1300 \ get access to the registry!"
1299 \ get access to the registry!"
1301 , D.toFancyNote
1300 , D.toFancyNote
1302 ["If","you","changed","your","dependencies","by","hand,","try","to","change","them","back!"
1301 ["If","you","changed","your","dependencies","by","hand,","try","to","change","them","back!"
1303− ,"It","is","much","more","reliable","to","add","dependencies","with",D.green "elm install"
1302+ ,"It","is","much","more","reliable","to","add","dependencies","with",D.green "elm install" <> "."
1304− ,"or","the","dependency","management","tool","in",D.green "elm reactor" <> "."
1305 ]
1303 ]
1306 ]
1304 ]
1307
1305
@@ -1337,8 +1335,7 @@ toDetailsReport details =
1337 \ party tool) leaving them in an invalid state."
1335 \ party tool) leaving them in an invalid state."
1338 [ D.fillSep
1336 [ D.fillSep
1339 ["Try","to","change","them","back","to","what","they","were","before!"
1337 ["Try","to","change","them","back","to","what","they","were","before!"
1340− ,"It","is","much","more","reliable","to","add","dependencies","with",D.green "elm install"
1338+ ,"It","is","much","more","reliable","to","add","dependencies","with",D.green "elm install" <> "."
1341− ,"or","the","dependency","management","tool","in",D.green "elm reactor" <> "."
1342 ]
1339 ]
1343 , D.reflow $
1340 , D.reflow $
1344 "Please ask for help on the community forums if you try those paths and are still\
1341 "Please ask for help on the community forums if you try those paths and are still\
@@ -1525,7 +1522,7 @@ toHttpErrorReport title err context =
1525
1522
1526 Http.BadHttp url httpExceptionContent ->
1523 Http.BadHttp url httpExceptionContent ->
1527 case httpExceptionContent of
1524 case httpExceptionContent of
1528− HTTP.StatusCodeException response _ ->
1525+ HTTP.StatusCodeException response body ->
1529 let
1526 let
1530 (HTTP.Status code message) = HTTP.responseStatus response
1527 (HTTP.Status code message) = HTTP.responseStatus response
1531 in
1528 in
@@ -1533,6 +1530,7 @@ toHttpErrorReport title err context =
1533 [ D.fillSep $
1530 [ D.fillSep $
1534 ["But","it","came","back","as",D.red (D.fromInt code)]
1531 ["But","it","came","back","as",D.red (D.fromInt code)]
1535 ++ map D.fromChars (words (BS_UTF8.toString message))
1532 ++ map D.fromChars (words (BS_UTF8.toString message))
1533+ , D.indent 4 $ D.reflow $ BS_UTF8.toString body
1536 , D.reflow $
1534 , D.reflow $
1537 "This may mean some online endpoint changed in an unexpected way, so if does not\
1535 "This may mean some online endpoint changed in an unexpected way, so if does not\
1538 \ seem like something on your side is causing this (e.g. firewall) please report\
1536 \ seem like something on your side is causing this (e.g. firewall) please report\
@@ -1767,8 +1765,8 @@ data BuildProjectProblem
1767 | BP_WithBadExtension FilePath
1765 | BP_WithBadExtension FilePath
1768 | BP_WithAmbiguousSrcDir FilePath FilePath FilePath
1766 | BP_WithAmbiguousSrcDir FilePath FilePath FilePath
1769 | BP_MainPathDuplicate FilePath FilePath
1767 | BP_MainPathDuplicate FilePath FilePath
1770− | BP_MainNameDuplicate ModuleName.Raw FilePath FilePath
1768+ | BP_RootNameDuplicate ModuleName.Raw FilePath FilePath
1771− | BP_MainNameInvalid FilePath FilePath [String]
1769+ | BP_RootNameInvalid FilePath FilePath [String]
1772 | BP_CannotLoadDependencies
1770 | BP_CannotLoadDependencies
1773 | BP_Cycle ModuleName.Raw [ModuleName.Raw]
1771 | BP_Cycle ModuleName.Raw [ModuleName.Raw]
1774 | BP_MissingExposed (NE.List (ModuleName.Raw, Import.Problem))
1772 | BP_MissingExposed (NE.List (ModuleName.Raw, Import.Problem))
@@ -1835,7 +1833,7 @@ toProjectProblemReport projectProblem =
1835 \ unstuck!"
1833 \ unstuck!"
1836 ]
1834 ]
1837
1835
1838− BP_MainNameDuplicate name outsidePath otherPath ->
1836+ BP_RootNameDuplicate name outsidePath otherPath ->
1839 Help.report "MODULE NAME CLASH" Nothing
1837 Help.report "MODULE NAME CLASH" Nothing
1840 "These two files are causing a module name clash:"
1838 "These two files are causing a module name clash:"
1841 [ D.indent 4 $ D.red $ D.vcat $ map D.fromChars [ outsidePath, otherPath ]
1839 [ D.indent 4 $ D.red $ D.vcat $ map D.fromChars [ outsidePath, otherPath ]
@@ -1846,7 +1844,7 @@ toProjectProblemReport projectProblem =
1846 "Try changing to a different module name in one of them!"
1844 "Try changing to a different module name in one of them!"
1847 ]
1845 ]
1848
1846
1849− BP_MainNameInvalid givenPath srcDir _ ->
1847+ BP_RootNameInvalid givenPath srcDir _ ->
1850 Help.report "UNEXPECTED FILE NAME" Nothing
1848 Help.report "UNEXPECTED FILE NAME" Nothing
1851 "I am having trouble with this file name:"
1849 "I am having trouble with this file name:"
1852 [ D.indent 4 $ D.red $ D.fromChars givenPath
1850 [ D.indent 4 $ D.red $ D.fromChars givenPath
@@ -1970,7 +1968,7 @@ toGenerateReport problem =
1970 "The issue is that --optimize strips out info needed by `Debug` functions.\
1968 "The issue is that --optimize strips out info needed by `Debug` functions.\
1971 \ Here are two examples:"
1969 \ Here are two examples:"
1972 , D.indent 4 $ D.reflow $
1970 , D.indent 4 $ D.reflow $
1973− "(1) It shortens record field names. This makes the generated JavaScript is\
1971+ "(1) It shortens record field names. This makes the generated JavaScript\
1974 \ smaller, but `Debug.toString` cannot know the real field names anymore."
1972 \ smaller, but `Debug.toString` cannot know the real field names anymore."
1975 , D.indent 4 $ D.reflow $
1973 , D.indent 4 $ D.reflow $
1976 "(2) Values like `type Height = Height Float` are unboxed. This reduces\
1974 "(2) Values like `type Height = Height Float` are unboxed. This reduces\
builder/src/Stuff.hs+1−1
@@ -62,7 +62,7 @@ prepublishDir root =
62
62
63compilerVersion :: FilePath
63compilerVersion :: FilePath
64compilerVersion =
64compilerVersion =
65− V.toChars V.compiler ++ "-rc-1"
65+ V.toChars V.compiler
66
66
67
67
68
68
compiler/src/AST/Utils/Type.hs−1
@@ -1,5 +1,4 @@
1{-# OPTIONS_GHC -Wall #-}
1{-# OPTIONS_GHC -Wall #-}
2−{-# LANGUAGE OverloadedStrings #-}
3module AST.Utils.Type
2module AST.Utils.Type
4 ( delambda
3 ( delambda
5 , dealias
4 , dealias
compiler/src/Canonicalize/Environment.hs+50−20
@@ -4,6 +4,8 @@ module Canonicalize.Environment
4 ( Env(..)
4 ( Env(..)
5 , Exposed
5 , Exposed
6 , Qualified
6 , Qualified
7+ , Info(..)
8+ , mergeInfo
7 , Var(..)
9 , Var(..)
8 , Type(..)
10 , Type(..)
9 , Ctor(..)
11 , Ctor(..)
@@ -20,8 +22,8 @@ module Canonicalize.Environment
20
22
21import qualified Data.Map.Merge.Strict as Map
23import qualified Data.Map.Merge.Strict as Map
22import qualified Data.Map.Strict as Map
24import qualified Data.Map.Strict as Map
23−import qualified Data.Map.Strict.Internal as I
24import qualified Data.Name as Name
25import qualified Data.Name as Name
26+import qualified Data.OneOrMore as OneOrMore
25
27
26import qualified AST.Utils.Binop as Binop
28import qualified AST.Utils.Binop as Binop
27import qualified AST.Canonical as Can
29import qualified AST.Canonical as Can
@@ -58,11 +60,34 @@ data Env =
58
60
59
61
60type Exposed a =
62type Exposed a =
61− Map.Map Name.Name (Map.Map ModuleName.Canonical a)
63+ Map.Map Name.Name (Info a)
62
64
63
65
64type Qualified a =
66type Qualified a =
65− Map.Map Name.Name (Map.Map Name.Name (Map.Map ModuleName.Canonical a))
67+ Map.Map Name.Name (Map.Map Name.Name (Info a))
68+
69+
70+
71+-- INFO
72+
73+
74+data Info a
75+ = Specific ModuleName.Canonical a
76+ | Ambiguous ModuleName.Canonical (OneOrMore.OneOrMore ModuleName.Canonical)
77+
78+
79+mergeInfo :: Info a -> Info a -> Info a
80+mergeInfo info1 info2 =
81+ case info1 of
82+ Specific h1 _ ->
83+ case info2 of
84+ Specific h2 _ -> if h1 == h2 then info1 else Ambiguous h1 (OneOrMore.one h2)
85+ Ambiguous h2 hs2 -> Ambiguous h1 (OneOrMore.more (OneOrMore.one h2) hs2)
86+
87+ Ambiguous h1 hs1 ->
88+ case info2 of
89+ Specific h2 _ -> Ambiguous h1 (OneOrMore.more hs1 (OneOrMore.one h2))
90+ Ambiguous h2 hs2 -> Ambiguous h1 (OneOrMore.more hs1 (OneOrMore.more (OneOrMore.one h2) hs2))
66
91
67
92
68
93
@@ -72,7 +97,8 @@ type Qualified a =
72data Var
97data Var
73 = Local A.Region
98 = Local A.Region
74 | TopLevel A.Region
99 | TopLevel A.Region
75− | Foreign (Map.Map ModuleName.Canonical Can.Annotation)
100+ | Foreign ModuleName.Canonical Can.Annotation
101+ | Foreigns ModuleName.Canonical (OneOrMore.OneOrMore ModuleName.Canonical)
76
102
77
103
78
104
@@ -139,7 +165,10 @@ addLocalLeft _ region =
139addLocalBoth :: Name.Name -> A.Region -> Var -> Result i w Var
165addLocalBoth :: Name.Name -> A.Region -> Var -> Result i w Var
140addLocalBoth name region var =
166addLocalBoth name region var =
141 case var of
167 case var of
142− Foreign _ ->
168+ Foreign _ _ ->
169+ Result.ok (Local region)
170+
171+ Foreigns _ _ ->
143 Result.ok (Local region)
172 Result.ok (Local region)
144
173
145 Local parentRegion ->
174 Local parentRegion ->
@@ -150,17 +179,18 @@ addLocalBoth name region var =
150
179
151
180
152
181
182+
153-- FIND TYPE
183-- FIND TYPE
154
184
155
185
156findType :: A.Region -> Env -> Name.Name -> Result i w Type
186findType :: A.Region -> Env -> Name.Name -> Result i w Type
157findType region (Env _ _ ts _ _ _ qts _) name =
187findType region (Env _ _ ts _ _ _ qts _) name =
158 case Map.lookup name ts of
188 case Map.lookup name ts of
159− Just (I.Bin 1 _ tipe _ _) ->
189+ Just (Specific _ tipe) ->
160 Result.ok tipe
190 Result.ok tipe
161
191
162− Just homes ->
192+ Just (Ambiguous h hs) ->
163− Result.throw (Error.AmbiguousType region Nothing name (Map.keys homes))
193+ Result.throw (Error.AmbiguousType region Nothing name h hs)
164
194
165 Nothing ->
195 Nothing ->
166 Result.throw (Error.NotFoundType region Nothing name (toPossibleNames ts qts))
196 Result.throw (Error.NotFoundType region Nothing name (toPossibleNames ts qts))
@@ -171,11 +201,11 @@ findTypeQual region (Env _ _ ts _ _ _ qts _) prefix name =
171 case Map.lookup prefix qts of
201 case Map.lookup prefix qts of
172 Just qualified ->
202 Just qualified ->
173 case Map.lookup name qualified of
203 case Map.lookup name qualified of
174− Just (I.Bin 1 _ tipe _ _) ->
204+ Just (Specific _ tipe) ->
175 Result.ok tipe
205 Result.ok tipe
176
206
177− Just homes ->
207+ Just (Ambiguous h hs) ->
178− Result.throw (Error.AmbiguousType region (Just prefix) name (Map.keys homes))
208+ Result.throw (Error.AmbiguousType region (Just prefix) name h hs)
179
209
180 Nothing ->
210 Nothing ->
181 Result.throw (Error.NotFoundType region (Just prefix) name (toPossibleNames ts qts))
211 Result.throw (Error.NotFoundType region (Just prefix) name (toPossibleNames ts qts))
@@ -191,11 +221,11 @@ findTypeQual region (Env _ _ ts _ _ _ qts _) prefix name =
191findCtor :: A.Region -> Env -> Name.Name -> Result i w Ctor
221findCtor :: A.Region -> Env -> Name.Name -> Result i w Ctor
192findCtor region (Env _ _ _ cs _ _ _ qcs) name =
222findCtor region (Env _ _ _ cs _ _ _ qcs) name =
193 case Map.lookup name cs of
223 case Map.lookup name cs of
194− Just (I.Bin 1 _ ctor _ _) ->
224+ Just (Specific _ ctor) ->
195 Result.ok ctor
225 Result.ok ctor
196
226
197− Just homes ->
227+ Just (Ambiguous h hs) ->
198− Result.throw (Error.AmbiguousVariant region Nothing name (Map.keys homes))
228+ Result.throw (Error.AmbiguousVariant region Nothing name h hs)
199
229
200 Nothing ->
230 Nothing ->
201 Result.throw (Error.NotFoundVariant region Nothing name (toPossibleNames cs qcs))
231 Result.throw (Error.NotFoundVariant region Nothing name (toPossibleNames cs qcs))
@@ -206,11 +236,11 @@ findCtorQual region (Env _ _ _ cs _ _ _ qcs) prefix name =
206 case Map.lookup prefix qcs of
236 case Map.lookup prefix qcs of
207 Just qualified ->
237 Just qualified ->
208 case Map.lookup name qualified of
238 case Map.lookup name qualified of
209− Just (I.Bin 1 _ pattern _ _) ->
239+ Just (Specific _ pattern) ->
210 Result.ok pattern
240 Result.ok pattern
211
241
212− Just homes ->
242+ Just (Ambiguous h hs) ->
213− Result.throw (Error.AmbiguousVariant region (Just prefix) name (Map.keys homes))
243+ Result.throw (Error.AmbiguousVariant region (Just prefix) name h hs)
214
244
215 Nothing ->
245 Nothing ->
216 Result.throw (Error.NotFoundVariant region (Just prefix) name (toPossibleNames cs qcs))
246 Result.throw (Error.NotFoundVariant region (Just prefix) name (toPossibleNames cs qcs))
@@ -226,11 +256,11 @@ findCtorQual region (Env _ _ _ cs _ _ _ qcs) prefix name =
226findBinop :: A.Region -> Env -> Name.Name -> Result i w Binop
256findBinop :: A.Region -> Env -> Name.Name -> Result i w Binop
227findBinop region (Env _ _ _ _ binops _ _ _) name =
257findBinop region (Env _ _ _ _ binops _ _ _) name =
228 case Map.lookup name binops of
258 case Map.lookup name binops of
229− Just (I.Bin 1 _ binop _ _) ->
259+ Just (Specific _ binop) ->
230 Result.ok binop
260 Result.ok binop
231
261
232− Just homes ->
262+ Just (Ambiguous h hs) ->
233− Result.throw (Error.AmbiguousBinop region name (Map.keys homes))
263+ Result.throw (Error.AmbiguousBinop region name h hs)
234
264
235 Nothing ->
265 Nothing ->
236 Result.throw (Error.NotFoundBinop region name (Map.keysSet binops))
266 Result.throw (Error.NotFoundBinop region name (Map.keysSet binops))
compiler/src/Canonicalize/Environment/Dups.hs+1−1
@@ -105,7 +105,7 @@ one name region value =
105
105
106insert :: Name.Name -> A.Region -> a -> Dict a -> Dict a
106insert :: Name.Name -> A.Region -> a -> Dict a -> Dict a
107insert name region value dict =
107insert name region value dict =
108− Map.insertWith OneOrMore.more name (OneOrMore.one (Info region value)) dict
108+ Map.insertWith (\new old -> OneOrMore.more old new) name (OneOrMore.one (Info region value)) dict
109
109
110
110
111union :: Dict a -> Dict a -> Dict a
111union :: Dict a -> Dict a -> Dict a
compiler/src/Canonicalize/Environment/Foreign.hs+42−30
@@ -35,7 +35,14 @@ type Result i w a =
35createInitialEnv :: ModuleName.Canonical -> Map.Map ModuleName.Raw I.Interface -> [Src.Import] -> Result i w Env.Env
35createInitialEnv :: ModuleName.Canonical -> Map.Map ModuleName.Raw I.Interface -> [Src.Import] -> Result i w Env.Env
36createInitialEnv home ifaces imports =
36createInitialEnv home ifaces imports =
37 do (State vs ts cs bs qvs qts qcs) <- foldM (addImport ifaces) emptyState (toSafeImports home imports)
37 do (State vs ts cs bs qvs qts qcs) <- foldM (addImport ifaces) emptyState (toSafeImports home imports)
38− Result.ok (Env.Env home (Map.map Env.Foreign vs) ts cs bs qvs qts qcs)
38+ Result.ok (Env.Env home (Map.map infoToVar vs) ts cs bs qvs qts qcs)
39+
40+
41+infoToVar :: Env.Info Can.Annotation -> Env.Var
42+infoToVar info =
43+ case info of
44+ Env.Specific home tipe -> Env.Foreign home tipe
45+ Env.Ambiguous h hs -> Env.Foreigns h hs
39
46
40
47
41
48
@@ -61,7 +68,7 @@ emptyState =
61
68
62emptyTypes :: Env.Exposed Env.Type
69emptyTypes :: Env.Exposed Env.Type
63emptyTypes =
70emptyTypes =
64− Map.singleton "List" (Map.singleton ModuleName.list (Env.Union 1 ModuleName.list))
71+ Map.singleton "List" (Env.Specific ModuleName.list (Env.Union 1 ModuleName.list))
65
72
66
73
67
74
@@ -102,8 +109,8 @@ addImport ifaces (State vs ts cs bs qvs qts qcs) (Src.Import (A.At _ name) maybe
102 (Map.mapMaybeWithKey (unionToType home) unions)
109 (Map.mapMaybeWithKey (unionToType home) unions)
103 (Map.mapMaybeWithKey (aliasToType home) aliases)
110 (Map.mapMaybeWithKey (aliasToType home) aliases)
104
111
105− !vars = Map.map (Map.singleton home) defs
112+ !vars = Map.map (Env.Specific home) defs
106− !types = Map.map (Map.singleton home . fst) rawTypeInfo
113+ !types = Map.map (Env.Specific home . fst) rawTypeInfo
107 !ctors = Map.foldr (addExposed . snd) Map.empty rawTypeInfo
114 !ctors = Map.foldr (addExposed . snd) Map.empty rawTypeInfo
108
115
109 !qvs2 = addQualified prefix vars qvs
116 !qvs2 = addQualified prefix vars qvs
@@ -129,7 +136,7 @@ addImport ifaces (State vs ts cs bs qvs qts qcs) (Src.Import (A.At _ name) maybe
129
136
130addExposed :: Env.Exposed a -> Env.Exposed a -> Env.Exposed a
137addExposed :: Env.Exposed a -> Env.Exposed a -> Env.Exposed a
131addExposed =
138addExposed =
132− Map.unionWith Map.union
139+ Map.unionWith Env.mergeInfo
133
140
134
141
135addQualified :: Name.Name -> Env.Exposed a -> Env.Qualified a -> Env.Qualified a
142addQualified :: Name.Name -> Env.Exposed a -> Env.Qualified a -> Env.Qualified a
@@ -150,7 +157,7 @@ unionToTypeHelp :: ModuleName.Canonical -> Name.Name -> Can.Union -> (Env.Type,
150unionToTypeHelp home name union@(Can.Union vars ctors _ _) =
157unionToTypeHelp home name union@(Can.Union vars ctors _ _) =
151 let
158 let
152 addCtor dict (Can.Ctor ctor index _ args) =
159 addCtor dict (Can.Ctor ctor index _ args) =
153− Map.insert ctor (Map.singleton home (Env.Ctor home name union index args)) dict
160+ Map.insert ctor (Env.Specific home (Env.Ctor home name union index args)) dict
154 in
161 in
155 ( Env.Union (length vars) home
162 ( Env.Union (length vars) home
156 , List.foldl' addCtor Map.empty ctors
163 , List.foldl' addCtor Map.empty ctors
@@ -181,7 +188,7 @@ aliasToTypeHelp home name (Can.Alias vars tipe) =
181 (Can.TAlias home name avars (Can.Filled tipe))
188 (Can.TAlias home name avars (Can.Filled tipe))
182 (Can.fieldsToList fields)
189 (Can.fieldsToList fields)
183 in
190 in
184− Map.singleton name (Map.singleton home (Env.RecordCtor home vars alias))
191+ Map.singleton name (Env.Specific home (Env.RecordCtor home vars alias))
185
192
186 _ ->
193 _ ->
187 Map.empty
194 Map.empty
@@ -192,9 +199,9 @@ aliasToTypeHelp home name (Can.Alias vars tipe) =
192-- BINOP
199-- BINOP
193
200
194
201
195−binopToBinop :: ModuleName.Canonical -> Name.Name -> I.Binop -> Map.Map ModuleName.Canonical Env.Binop
202+binopToBinop :: ModuleName.Canonical -> Name.Name -> I.Binop -> Env.Info Env.Binop
196binopToBinop home op (I.Binop name annotation associativity precedence) =
203binopToBinop home op (I.Binop name annotation associativity precedence) =
197− Map.singleton home (Env.Binop op home name annotation associativity precedence)
204+ Env.Specific home (Env.Binop op home name annotation associativity precedence)
198
205
199
206
200
207
@@ -214,7 +221,7 @@ addExposedValue home vars types binops (State vs ts cs bs qvs qts qcs) exposed =
214 Src.Lower (A.At region name) ->
221 Src.Lower (A.At region name) ->
215 case Map.lookup name vars of
222 case Map.lookup name vars of
216 Just info ->
223 Just info ->
217− Result.ok (State (Map.insertWith Map.union name info vs) ts cs bs qvs qts qcs)
224+ Result.ok (State (Map.insertWith Env.mergeInfo name info vs) ts cs bs qvs qts qcs)
218
225
219 Nothing ->
226 Nothing ->
220 Result.throw (Error.ImportExposingNotFound region home name (Map.keys vars))
227 Result.throw (Error.ImportExposingNotFound region home name (Map.keys vars))
@@ -227,23 +234,23 @@ addExposedValue home vars types binops (State vs ts cs bs qvs qts qcs) exposed =
227 case tipe of
234 case tipe of
228 Env.Union _ _ ->
235 Env.Union _ _ ->
229 let
236 let
230− !ts2 = Map.insert name (Map.singleton home tipe) ts
237+ !ts2 = Map.insert name (Env.Specific home tipe) ts
231 in
238 in
232 Result.ok (State vs ts2 cs bs qvs qts qcs)
239 Result.ok (State vs ts2 cs bs qvs qts qcs)
233
240
234 Env.Alias _ _ _ _ ->
241 Env.Alias _ _ _ _ ->
235 let
242 let
236− !ts2 = Map.insert name (Map.singleton home tipe) ts
243+ !ts2 = Map.insert name (Env.Specific home tipe) ts
237 !cs2 = addExposed cs ctors
244 !cs2 = addExposed cs ctors
238 in
245 in
239 Result.ok (State vs ts2 cs2 bs qvs qts qcs)
246 Result.ok (State vs ts2 cs2 bs qvs qts qcs)
240
247
241 Nothing ->
248 Nothing ->
242− case Map.lookup name (toCtors types) of
249+ case checkForCtorMistake name types of
243− Just tipe ->
250+ tipe:_ ->
244 Result.throw $ Error.ImportCtorByName region name tipe
251 Result.throw $ Error.ImportCtorByName region name tipe
245
252
246− Nothing ->
253+ [] ->
247 Result.throw $ Error.ImportExposingNotFound region home name (Map.keys types)
254 Result.throw $ Error.ImportExposingNotFound region home name (Map.keys types)
248
255
249 Src.Public dotDotRegion ->
256 Src.Public dotDotRegion ->
@@ -252,7 +259,7 @@ addExposedValue home vars types binops (State vs ts cs bs qvs qts qcs) exposed =
252 case tipe of
259 case tipe of
253 Env.Union _ _ ->
260 Env.Union _ _ ->
254 let
261 let
255− !ts2 = Map.insert name (Map.singleton home tipe) ts
262+ !ts2 = Map.insert name (Env.Specific home tipe) ts
256 !cs2 = addExposed cs ctors
263 !cs2 = addExposed cs ctors
257 in
264 in
258 Result.ok (State vs ts2 cs2 bs qvs qts qcs)
265 Result.ok (State vs ts2 cs2 bs qvs qts qcs)
@@ -275,18 +282,23 @@ addExposedValue home vars types binops (State vs ts cs bs qvs qts qcs) exposed =
275 Result.throw (Error.ImportExposingNotFound region home op (Map.keys binops))
282 Result.throw (Error.ImportExposingNotFound region home op (Map.keys binops))
276
283
277
284
278−
279−toCtors :: Map.Map Name.Name (Env.Type, Env.Exposed Env.Ctor) -> Map.Map Name.Name Name.Name
285+checkForCtorMistake :: Name.Name -> Map.Map Name.Name (Env.Type, Env.Exposed Env.Ctor) -> [Name.Name]
280−toCtors types =
286+checkForCtorMistake givenName types =
281− Map.foldr addCtors Map.empty types
287+ Map.foldr addMatches [] types
282 where
288 where
283− addCtors (_, exposedCtors) dict =
289+ addMatches (_, exposedCtors) matches =
284− Map.foldrWithKey addCtor dict exposedCtors
290+ Map.foldrWithKey addMatch matches exposedCtors
285−
291+
286− addCtor ctorName homes dict =
292+ addMatch ctorName info matches =
293+ if ctorName /= givenName
294+ then matches
295+ else
287− case Map.elems homes of
296+ case info of
288− [Env.Ctor _ tipeName _ _ _] ->
297+ Env.Specific _ (Env.Ctor _ tipeName _ _ _) ->
289− Map.insert ctorName tipeName dict
298+ tipeName : matches
290−
299+
291− _ ->
300+ Env.Specific _ (Env.RecordCtor _ _ _) ->
292− dict
301+ matches
302+
303+ Env.Ambiguous _ _ ->
304+ matches
compiler/src/Canonicalize/Environment/Local.hs+5−5
@@ -110,7 +110,7 @@ addTypes (Src.Module _ _ _ _ _ unions aliases _ _) (Env.Env home vs ts cs bs qvs
110addUnion :: ModuleName.Canonical -> Env.Exposed Env.Type -> A.Located Src.Union -> Result i w (Env.Exposed Env.Type)
110addUnion :: ModuleName.Canonical -> Env.Exposed Env.Type -> A.Located Src.Union -> Result i w (Env.Exposed Env.Type)
111addUnion home types union@(A.At _ (Src.Union (A.At _ name) _ _)) =
111addUnion home types union@(A.At _ (Src.Union (A.At _ name) _ _)) =
112 do arity <- checkUnionFreeVars union
112 do arity <- checkUnionFreeVars union
113− let one = Map.singleton home (Env.Union arity home)
113+ let one = Env.Specific home (Env.Union arity home)
114 Result.ok $ Map.insert name one types
114 Result.ok $ Map.insert name one types
115
115
116
116
@@ -133,7 +133,7 @@ addAlias env@(Env.Env home vs ts cs bs qvs qts qcs) scc =
133 Graph.AcyclicSCC alias@(A.At _ (Src.Alias (A.At _ name) _ tipe)) ->
133 Graph.AcyclicSCC alias@(A.At _ (Src.Alias (A.At _ name) _ tipe)) ->
134 do args <- checkAliasFreeVars alias
134 do args <- checkAliasFreeVars alias
135 ctype <- Type.canonicalize env tipe
135 ctype <- Type.canonicalize env tipe
136− let one = Map.singleton home (Env.Alias (length args) home args ctype)
136+ let one = Env.Specific home (Env.Alias (length args) home args ctype)
137 let ts1 = Map.insert name one ts
137 let ts1 = Map.insert name one ts
138 Result.ok $ Env.Env home vs ts1 cs bs qvs qts qcs
138 Result.ok $ Env.Env home vs ts1 cs bs qvs qts qcs
139
139
@@ -281,7 +281,7 @@ addCtors (Src.Module _ _ _ _ _ unions aliases _ _) env@(Env.Env home vs ts cs bs
281 )
281 )
282
282
283
283
284−type CtorDups = Dups.Dict (Map.Map ModuleName.Canonical Env.Ctor)
284+type CtorDups = Dups.Dict (Env.Info Env.Ctor)
285
285
286
286
287
287
@@ -297,7 +297,7 @@ canonicalizeAlias env@(Env.Env home _ _ _ _ _ _ _) (A.At _ (Src.Alias (A.At regi
297 ,
297 ,
298 case ctipe of
298 case ctipe of
299 Can.TRecord fields Nothing ->
299 Can.TRecord fields Nothing ->
300− Dups.one name region (Map.singleton home (toRecordCtor home name vars fields))
300+ Dups.one name region (Env.Specific home (toRecordCtor home name vars fields))
301
301
302 _ ->
302 _ ->
303 Dups.none
303 Dups.none
@@ -351,5 +351,5 @@ toOpts ctors =
351
351
352toCtor :: ModuleName.Canonical -> Name.Name -> Can.Union -> A.Located Can.Ctor -> CtorDups
352toCtor :: ModuleName.Canonical -> Name.Name -> Can.Union -> A.Located Can.Ctor -> CtorDups
353toCtor home typeName union (A.At region (Can.Ctor name index _ args)) =
353toCtor home typeName union (A.At region (Can.Ctor name index _ args)) =
354− Dups.one name region $ Map.singleton home $
354+ Dups.one name region $ Env.Specific home $
355 Env.Ctor home typeName union index args
355 Env.Ctor home typeName union index args
compiler/src/Canonicalize/Expression.hs+6−7
@@ -14,7 +14,6 @@ import Control.Monad (foldM)
14import qualified Data.Graph as Graph
14import qualified Data.Graph as Graph
15import qualified Data.List as List
15import qualified Data.List as List
16import qualified Data.Map.Strict as Map
16import qualified Data.Map.Strict as Map
17−import qualified Data.Map.Strict.Internal as I
18import qualified Data.Name as Name
17import qualified Data.Name as Name
19
18
20import qualified AST.Canonical as Can
19import qualified AST.Canonical as Can
@@ -696,15 +695,15 @@ findVar region (Env.Env localHome vs _ _ _ qvs _ _) name =
696 Env.TopLevel _ ->
695 Env.TopLevel _ ->
697 logVar name (Can.VarTopLevel localHome name)
696 logVar name (Can.VarTopLevel localHome name)
698
697
699− Env.Foreign (I.Bin 1 home annotation _ _) ->
698+ Env.Foreign home annotation ->
700 Result.ok $
699 Result.ok $
701 if home == ModuleName.debug then
700 if home == ModuleName.debug then
702 Can.VarDebug localHome name annotation
701 Can.VarDebug localHome name annotation
703 else
702 else
704 Can.VarForeign home name annotation
703 Can.VarForeign home name annotation
705
704
706− Env.Foreign homes ->
705+ Env.Foreigns h hs ->
707− Result.throw (Error.AmbiguousVar region Nothing name (Map.keys homes))
706+ Result.throw (Error.AmbiguousVar region Nothing name h hs)
708
707
709 Nothing ->
708 Nothing ->
710 Result.throw (Error.NotFoundVar region Nothing name (toPossibleNames vs qvs))
709 Result.throw (Error.NotFoundVar region Nothing name (toPossibleNames vs qvs))
@@ -715,15 +714,15 @@ findVarQual region (Env.Env localHome vs _ _ _ qvs _ _) prefix name =
715 case Map.lookup prefix qvs of
714 case Map.lookup prefix qvs of
716 Just qualified ->
715 Just qualified ->
717 case Map.lookup name qualified of
716 case Map.lookup name qualified of
718− Just (I.Bin 1 home annotation _ _) ->
717+ Just (Env.Specific home annotation) ->
719 Result.ok $
718 Result.ok $
720 if home == ModuleName.debug then
719 if home == ModuleName.debug then
721 Can.VarDebug localHome name annotation
720 Can.VarDebug localHome name annotation
722 else
721 else
723 Can.VarForeign home name annotation
722 Can.VarForeign home name annotation
724
723
725− Just homes ->
724+ Just (Env.Ambiguous h hs) ->
726− Result.throw (Error.AmbiguousVar region (Just prefix) name (Map.keys homes))
725+ Result.throw (Error.AmbiguousVar region (Just prefix) name h hs)
727
726
728 Nothing ->
727 Nothing ->
729 Result.throw (Error.NotFoundVar region (Just prefix) name (toPossibleNames vs qvs))
728 Result.throw (Error.NotFoundVar region (Just prefix) name (toPossibleNames vs qvs))
compiler/src/Canonicalize/Pattern.hs+3−2
@@ -8,6 +8,7 @@ module Canonicalize.Pattern
8 where
8 where
9
9
10
10
11+import qualified Data.List as List
11import qualified Data.Map.Strict as Map
12import qualified Data.Map.Strict as Map
12import qualified Data.Name as Name
13import qualified Data.Name as Name
13
14
@@ -173,8 +174,8 @@ logVar name region value =
173logFields :: [A.Located Name.Name] -> a -> Result DupsDict w a
174logFields :: [A.Located Name.Name] -> a -> Result DupsDict w a
174logFields fields value =
175logFields fields value =
175 let
176 let
176− addField (A.At region name) dict =
177+ addField dict (A.At region name) =
177 Dups.insert name region region dict
178 Dups.insert name region region dict
178 in
179 in
179 Result.Result $ \bindings warnings _ ok ->
180 Result.Result $ \bindings warnings _ ok ->
180− ok (foldr addField bindings fields) warnings value
181+ ok (List.foldl' addField bindings fields) warnings value
compiler/src/Data/Utf8.hs+3−1
@@ -261,7 +261,9 @@ instance Eq (Utf8 t) where
261
261
262
262
263-- COMPARE
263-- COMPARE
264−
264+--
265+-- TODO: is it fine to sort by length and only compare bytes on length ties?
266+--
265
267
266instance Ord (Utf8 t) where
268instance Ord (Utf8 t) where
267 compare (Utf8 ba1#) (Utf8 ba2#) =
269 compare (Utf8 ba1#) (Utf8 ba2#) =
compiler/src/Elm/ModuleName.hs+2−6
@@ -7,12 +7,13 @@ module Elm.ModuleName
7 --
7 --
8 , encode
8 , encode
9 , decoder
9 , decoder
10+ , parser
10 --
11 --
11 , Canonical(..)
12 , Canonical(..)
12 , basics, char, string
13 , basics, char, string
13 , maybe, result, list, array, dict, tuple
14 , maybe, result, list, array, dict, tuple
14 , platform, cmd, sub
15 , platform, cmd, sub
15− , debug, bitwise
16+ , debug
16 , virtualDom
17 , virtualDom
17 , jsonDecode, jsonEncode
18 , jsonDecode, jsonEncode
18 , webgl, texture, vector2, vector3, vector4, matrix4
19 , webgl, texture, vector2, vector3, vector4, matrix4
@@ -225,11 +226,6 @@ debug :: Canonical
225debug = Canonical Pkg.core Name.debug
226debug = Canonical Pkg.core Name.debug
226
227
227
228
228−{-# NOINLINE bitwise #-}
229−bitwise :: Canonical
230−bitwise = Canonical Pkg.core Name.bitwise
231−
232−
233
229
234-- HTML
230-- HTML
235
231
compiler/src/Generate/JavaScript.hs+2−2
@@ -83,7 +83,7 @@ generateForRepl :: Bool -> L.Localizer -> Opt.GlobalGraph -> ModuleName.Canonica
83generateForRepl ansi localizer (Opt.GlobalGraph graph _) home name (Can.Forall _ tipe) =
83generateForRepl ansi localizer (Opt.GlobalGraph graph _) home name (Can.Forall _ tipe) =
84 let
84 let
85 mode = Mode.Dev Nothing
85 mode = Mode.Dev Nothing
86− debugState = addGlobal mode graph emptyState (Opt.Global ModuleName.debug "toAnsiString")
86+ debugState = addGlobal mode graph emptyState (Opt.Global ModuleName.debug "toString")
87 evalState = addGlobal mode graph debugState (Opt.Global home name)
87 evalState = addGlobal mode graph debugState (Opt.Global home name)
88 in
88 in
89 "process.on('uncaughtException', function(err) { process.stderr.write(err.toString() + '\\n'); process.exit(1); });"
89 "process.on('uncaughtException', function(err) { process.stderr.write(err.toString() + '\\n'); process.exit(1); });"
@@ -119,7 +119,7 @@ generateForReplEndpoint localizer (Opt.GlobalGraph graph _) home maybeName (Can.
119 let
119 let
120 name = maybe Name.replValueToPrint id maybeName
120 name = maybe Name.replValueToPrint id maybeName
121 mode = Mode.Dev Nothing
121 mode = Mode.Dev Nothing
122− debugState = addGlobal mode graph emptyState (Opt.Global ModuleName.debug "toAnsiString")
122+ debugState = addGlobal mode graph emptyState (Opt.Global ModuleName.debug "toString")
123 evalState = addGlobal mode graph debugState (Opt.Global home name)
123 evalState = addGlobal mode graph debugState (Opt.Global home name)
124 in
124 in
125 Functions.functions
125 Functions.functions
compiler/src/Parse/Pattern.hs+1−1
@@ -129,7 +129,7 @@ recordHelp start vars =
129 Space.chompAndCheckIndent E.PRecordSpace E.PRecordIndentEnd
129 Space.chompAndCheckIndent E.PRecordSpace E.PRecordIndentEnd
130 recordHelp start (var:vars)
130 recordHelp start (var:vars)
131 , do word1 0x7D {-}-} E.PRecordEnd
131 , do word1 0x7D {-}-} E.PRecordEnd
132− addEnd start (Src.PRecord vars)
132+ addEnd start (Src.PRecord (reverse vars))
133 ]
133 ]
134
134
135
135
compiler/src/Reporting/Error/Canonicalize.hs+21−16
@@ -14,8 +14,10 @@ module Reporting.Error.Canonicalize
14
14
15
15
16import qualified Data.Char as Char
16import qualified Data.Char as Char
17+import qualified Data.List as List
17import qualified Data.Map as Map
18import qualified Data.Map as Map
18import qualified Data.Name as Name
19import qualified Data.Name as Name
20+import qualified Data.OneOrMore as OneOrMore
19import qualified Data.Set as Set
21import qualified Data.Set as Set
20
22
21import qualified AST.Canonical as Can
23import qualified AST.Canonical as Can
@@ -37,10 +39,10 @@ import qualified Reporting.Suggest as Suggest
37
39
38data Error
40data Error
39 = AnnotationTooShort A.Region Name.Name Index.ZeroBased Int
41 = AnnotationTooShort A.Region Name.Name Index.ZeroBased Int
40− | AmbiguousVar A.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
42+ | AmbiguousVar A.Region (Maybe Name.Name) Name.Name ModuleName.Canonical (OneOrMore.OneOrMore ModuleName.Canonical)
41− | AmbiguousType A.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
43+ | AmbiguousType A.Region (Maybe Name.Name) Name.Name ModuleName.Canonical (OneOrMore.OneOrMore ModuleName.Canonical)
42− | AmbiguousVariant A.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
44+ | AmbiguousVariant A.Region (Maybe Name.Name) Name.Name ModuleName.Canonical (OneOrMore.OneOrMore ModuleName.Canonical)
43− | AmbiguousBinop A.Region Name.Name [ModuleName.Canonical]
45+ | AmbiguousBinop A.Region Name.Name ModuleName.Canonical (OneOrMore.OneOrMore ModuleName.Canonical)
44 | BadArity A.Region BadArityContext Name.Name Int Int
46 | BadArity A.Region BadArityContext Name.Name Int Int
45 | Binop A.Region Name.Name Name.Name
47 | Binop A.Region Name.Name Name.Name
46 | DuplicateDecl Name.Name A.Region A.Region
48 | DuplicateDecl Name.Name A.Region A.Region
@@ -164,17 +166,17 @@ toReport source err =
164 <> " be deleted? Maybe some parentheses are missing?"
166 <> " be deleted? Maybe some parentheses are missing?"
165 )
167 )
166
168
167− AmbiguousVar region maybePrefix name possibleHomes ->
169+ AmbiguousVar region maybePrefix name h hs ->
168− ambiguousName source region maybePrefix name possibleHomes "variable"
170+ ambiguousName source region maybePrefix name h hs "variable"
169
171
170− AmbiguousType region maybePrefix name possibleHomes ->
172+ AmbiguousType region maybePrefix name h hs ->
171− ambiguousName source region maybePrefix name possibleHomes "type"
173+ ambiguousName source region maybePrefix name h hs "type"
172
174
173− AmbiguousVariant region maybePrefix name possibleHomes ->
175+ AmbiguousVariant region maybePrefix name h hs ->
174− ambiguousName source region maybePrefix name possibleHomes "variant"
176+ ambiguousName source region maybePrefix name h hs "variant"
175
177
176− AmbiguousBinop region name possibleHomes ->
178+ AmbiguousBinop region name h hs ->
177− ambiguousName source region Nothing name possibleHomes "operator"
179+ ambiguousName source region Nothing name h hs "operator"
178
180
179 BadArity region badArityContext name expected actual ->
181 BadArity region badArityContext name expected actual ->
180 let
182 let
@@ -677,7 +679,7 @@ toReport source err =
677 "The `" <> Name.toChars name <> "` value is defined directly in terms of itself, causing an infinite loop."
679 "The `" <> Name.toChars name <> "` value is defined directly in terms of itself, causing an infinite loop."
678 ,
680 ,
679 D.stack
681 D.stack
680− [ makeTheory "Are you are trying to mutate a variable?" $
682+ [ makeTheory "Are you trying to mutate a variable?" $
681 "Elm does not have mutation, so when I see " ++ Name.toChars name
683 "Elm does not have mutation, so when I see " ++ Name.toChars name
682 ++ " defined in terms of " ++ Name.toChars name
684 ++ " defined in terms of " ++ Name.toChars name
683 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
685 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
@@ -723,7 +725,7 @@ toReport source err =
723 "The `" <> Name.toChars name <> "` value is defined directly in terms of itself, causing an infinite loop."
725 "The `" <> Name.toChars name <> "` value is defined directly in terms of itself, causing an infinite loop."
724 ,
726 ,
725 D.stack
727 D.stack
726− [ makeTheory "Are you are trying to mutate a variable?" $
728+ [ makeTheory "Are you trying to mutate a variable?" $
727 "Elm does not have mutation, so when I see " ++ Name.toChars name
729 "Elm does not have mutation, so when I see " ++ Name.toChars name
728 ++ " defined in terms of " ++ Name.toChars name
730 ++ " defined in terms of " ++ Name.toChars name
729 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
731 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
@@ -974,8 +976,11 @@ nameClash source r1 r2 messageThatEndsWithPunctuation =
974-- AMBIGUOUS NAME
976-- AMBIGUOUS NAME
975
977
976
978
977−ambiguousName :: Code.Source -> A.Region -> Maybe Name.Name -> Name.Name -> [ModuleName.Canonical] -> String -> Report.Report
979+ambiguousName :: Code.Source -> A.Region -> Maybe Name.Name -> Name.Name -> ModuleName.Canonical -> OneOrMore.OneOrMore ModuleName.Canonical -> String -> Report.Report
978−ambiguousName source region maybePrefix name possibleHomes thing =
980+ambiguousName source region maybePrefix name h hs thing =
981+ let
982+ possibleHomes = List.sort (h : OneOrMore.destruct (:) hs)
983+ in
979 Report.Report "AMBIGUOUS NAME" region [] $
984 Report.Report "AMBIGUOUS NAME" region [] $
980 Code.toSnippet source region Nothing $
985 Code.toSnippet source region Nothing $
981 case maybePrefix of
986 case maybePrefix of
compiler/src/Reporting/Error/Import.hs+1−1
@@ -56,7 +56,7 @@ toReport source (Error region name unimportedModules problem) =
56 D.stack
56 D.stack
57 [
57 [
58 D.reflow $
58 D.reflow $
59− "I checked the \"dependencies\" and \"source-directories\" listend in your elm.json,\
59+ "I checked the \"dependencies\" and \"source-directories\" listed in your elm.json,\
60 \ but I cannot find it! Maybe it is a typo for one of these names?"
60 \ but I cannot find it! Maybe it is a typo for one of these names?"
61 ,
61 ,
62 D.dullyellow $ D.indent 4 $ D.vcat $
62 D.dullyellow $ D.indent 4 $ D.vcat $
compiler/src/Reporting/Error/Pattern.hs+2−2
@@ -41,7 +41,7 @@ toReport source err =
41 Report.Report "UNSAFE PATTERN" region [] $
41 Report.Report "UNSAFE PATTERN" region [] $
42 Code.toSnippet source region Nothing
42 Code.toSnippet source region Nothing
43 (
43 (
44− "This pattern does not cover all possiblities:"
44+ "This pattern does not cover all possibilities:"
45 ,
45 ,
46 D.stack
46 D.stack
47 [ "Other possibilities include:"
47 [ "Other possibilities include:"
@@ -64,7 +64,7 @@ toReport source err =
64 , unhandledPatternsToDocBlock unhandled
64 , unhandledPatternsToDocBlock unhandled
65 , D.reflow $
65 , D.reflow $
66 "I would have to crash if I saw one of those! You can use\
66 "I would have to crash if I saw one of those! You can use\
67− \ `let` to deconstruct values only if there is ONE possiblity.\
67+ \ `let` to deconstruct values only if there is ONE possibility.\
68 \ Switch to a `case` expression to account for all possibilities."
68 \ Switch to a `case` expression to account for all possibilities."
69 , D.toSimpleHint $
69 , D.toSimpleHint $
70 "Are you calling a function that definitely returns values\
70 "Are you calling a function that definitely returns values\
compiler/src/Reporting/Error/Syntax.hs+1−1
@@ -2591,7 +2591,7 @@ toExprReport source context expr startRow startCol =
2591 ,"give","a","more","specific","hint!"
2591 ,"give","a","more","specific","hint!"
2592 ]
2592 ]
2593 , D.toSimpleNote $
2593 , D.toSimpleNote $
2594− "This can also happen if run into reserved words like `let` or `as` unexpectedly.\
2594+ "This can also happen if I run into reserved words like `let` or `as` unexpectedly.\
2595 \ Or if I run into operators in unexpected spots. Point is, there are a\
2595 \ Or if I run into operators in unexpected spots. Point is, there are a\
2596 \ couple ways I can get confused and give sort of weird advice!"
2596 \ couple ways I can get confused and give sort of weird advice!"
2597 ]
2597 ]
docs/elm.json/application.md+2−2
@@ -8,7 +8,7 @@ This is a decent baseline for pretty much any applications made with Elm. You wi
8 "source-directories": [
8 "source-directories": [
9 "src"
9 "src"
10 ],
10 ],
11− "elm-version": "0.19.0",
11+ "elm-version": "0.19.1",
12 "dependencies": {
12 "dependencies": {
13 "direct": {
13 "direct": {
14 "elm/browser": "1.0.0",
14 "elm/browser": "1.0.0",
@@ -48,7 +48,7 @@ A list of directories where Elm code lives. Most projects just use `"src"` for e
48
48
49## `"elm-version"`
49## `"elm-version"`
50
50
51−The exact version of Elm this builds with. Should be `"0.19.0"` for most people!
51+The exact version of Elm this builds with. Should be `"0.19.1"` for most people!
52
52
53<br>
53<br>
54
54
docs/elm.json/package.md+1−1
@@ -49,7 +49,7 @@ A short summary that will appear on [`package.elm-lang.org`](https://package.elm
49
49
50## `"license"`
50## `"license"`
51
51
52−An OSI approved SPDX code like `"BSD-3-Clause"` or `"MIT"`. These are the two most common licenses in the Elm ecosystem, but you can see the full list of options [here](https://spdx.org/licenses/).
52+An OSI approved SPDX code like `"BSD-3-Clause"` or `"MIT"`. These are the two most common licenses in the Elm ecosystem, and BSD-3-Clause is a good default. But you can see the full list of options [here](https://spdx.org/licenses/).
53
53
54<br>
54<br>
55
55
upgrade-docs/0.16.md → docs/upgrade-instructions/0.16.mdrenamed

The content is the same.

upgrade-docs/0.17.md → docs/upgrade-instructions/0.17.mdrenamed

The content is the same.

upgrade-docs/0.18.md → docs/upgrade-instructions/0.18.mdrenamed

The content is the same.

upgrade-docs/0.19.md → docs/upgrade-instructions/0.19.0.mdrenamed

The content is the same.

docs/upgrade-instructions/0.19.1.mdnew file+60
@@ -0,0 +1,60 @@
1+# Upgrading to 0.19.1
2+
3+**There are no language changes**, so once you swap to `"elm-version": "0.19.1"` in your `elm.json`, most users should be able to proceed without any further code changes. **You may run into a handful of bugfixes though!** These cases are outlined below!
4+
5+
6+<br>
7+
8+## Improvements
9+
10+- Parse error message quality (like [this](https://github.com/elm/error-message-catalog/issues/255) and [this](https://github.com/elm/error-message-catalog/issues/225))
11+- Faster compilation, especially for incremental compiles
12+- Uses filelocks so that cached files are not corrupted when plugins run `elm make` multiple times on the same project at the same time. (Still worth avoiding that though!)
13+- More intuitive multiline declarations in REPL
14+- Various bug fixes (e.g. `--debug`, `x /= 0`, `type Height = Height Float` in `--optimize`)
15+
16+
17+<br>
18+
19+## Detectable Bug Fixes
20+
21+There are three known cases where code that compiled with 0.19.0 will not compile with 0.19.1 due to bug fixes:
22+
23+
24+### 1. Ambiguous Imports
25+
26+Say you have an import like this:
27+
28+```elm
29+import Html exposing (min)
30+import Regex exposing (never)
31+
32+x = min
33+y = never
34+```
35+
36+These should be reported as ambiguous usages since the names are also exposed by `Basics`, but there was a regression in 0.19.0 described [here](https://github.com/elm/compiler/issues/1945) such that they weren't caught in specific circumstances.
37+
38+The fix is to use a qualified name like `Html.min` or `Regex.never` to make it unambiguous.
39+
40+We found a couple instances of this in packages and have submitted PRs to the relevant authors in August 2019. You may run into this in your own code as well.
41+
42+For more details on why this is considered a regression, check out the details [here](https://github.com/elm/compiler/issues/1945#issuecomment-507871919) or try it in 0.18.0 to see how it worked before.
43+
44+
45+### 2. Tabs in Comments
46+
47+The 0.19.0 binaries did not catch tab characters in comments. The new parser is better at checking for tabs, so it will object when it finds these.
48+
49+Again, we found this in some packages and reached out to the relevant authors with PRs so patches would be published before the 0.19.1 release.
50+
51+
52+### 3. Port Module with no Ports
53+
54+If you have any files that start with:
55+
56+```elm
57+port module Main exposing (..)
58+```
59+
60+But they do not actually have any `port` declarations, the 0.19.1 binary will ask you to switch to a normal module declaration like `module Main exposing (..)`
upgrade-docs/earlier.md → docs/upgrade-instructions/earlier.mdrenamed

The content is the same.

elm.cabal+6−5
@@ -45,6 +45,7 @@ Executable elm
45 Hs-Source-Dirs:
45 Hs-Source-Dirs:
46 compiler/src
46 compiler/src
47 builder/src
47 builder/src
48+ terminal/impl
48 terminal/src
49 terminal/src
49
50
50 other-extensions:
51 other-extensions:
@@ -64,11 +65,11 @@ Executable elm
64 Repl
65 Repl
65
66
66 -- terminal args
67 -- terminal args
67− Terminal.Args
68+ Terminal
68− Terminal.Args.Chomp
69+ Terminal.Chomp
69− Terminal.Args.Error
70+ Terminal.Error
70− Terminal.Args.Helpers
71+ Terminal.Helpers
71− Terminal.Args.Internal
72+ Terminal.Internal
72
73
73 -- from terminal/
74 -- from terminal/
74 Develop.Generate.Help
75 Develop.Generate.Help
hints/bad-recursion.md+1−1
@@ -10,7 +10,7 @@ There are two problems that will lead you here, both of them pretty tricky:
10
10
11## No Mutation
11## No Mutation
12
12
13−Languages like JavaScript let you “reassign” variables. When you say `x = x + 1` it means: whatever `x` was pointing to, have it point to `x + 1` instead. This called *mutating* a variable. All values are immutable in Elm, so reassigning variables does not make any sense! Okay, so what *should* `x = x + 1` mean in Elm?
13+Languages like JavaScript let you “reassign” variables. When you say `x = x + 1` it means: whatever `x` was pointing to, have it point to `x + 1` instead. This is called *mutating* a variable. All values are immutable in Elm, so reassigning variables does not make any sense! Okay, so what *should* `x = x + 1` mean in Elm?
14
14
15Well, what does it mean with functions? In Elm, we write recursive functions like this:
15Well, what does it mean with functions? In Elm, we write recursive functions like this:
16
16
hints/comparing-custom-types.md+1−1
@@ -54,7 +54,7 @@ add info (Table nextId dict) =
54 )
54 )
55```
55```
56
56
57−There are a couple nice thing about this approach:
57+There are a couple nice things about this approach:
58
58
591. The only way to get a new `User.Id` is to `add` information to a `User.Table`.
591. The only way to get a new `User.Id` is to `add` information to a `User.Table`.
602. All the operations on a `User.Table` are explicit. Does it make sense to remove users? To merge two tables together? Are there any special details to consider in those cases? This will always be captured explicitly in the interface of the `User` module.
602. All the operations on a `User.Table` are explicit. Does it make sense to remove users? To merge two tables together? Are there any special details to consider in those cases? This will always be captured explicitly in the interface of the `User` module.
hints/comparing-records.md+3−3
@@ -7,7 +7,7 @@ This page aims to catalog these scenarios and offer alternative paths that can g
7
7
8## Sorting Records
8## Sorting Records
9
9
10−Say we want a `view` function that can show a list of students sorted by different characterists.
10+Say we want a `view` function that can show a list of students sorted by different characteristics.
11
11
12We could create something like this:
12We could create something like this:
13
13
@@ -23,7 +23,7 @@ type alias Student =
23type Order = Name | Age | GPA
23type Order = Name | Age | GPA
24
24
25viewStudents : Order -> List Student -> Html msg
25viewStudents : Order -> List Student -> Html msg
26−viewStudents order studentns =
26+viewStudents order students =
27 let
27 let
28 orderlyStudents =
28 orderlyStudents =
29 case order of
29 case order of
@@ -54,7 +54,7 @@ type alias Student =
54 }
54 }
55
55
56viewStudents : Order -> List Student -> Html msg
56viewStudents : Order -> List Student -> Html msg
57−viewStudents order studentns =
57+viewStudents order students =
58 let
58 let
59 orderlyStudents =
59 orderlyStudents =
60 case order of
60 case order of
hints/implicit-casts.md+1−4
@@ -16,9 +16,6 @@ Languages that will add in implicit casts for addition include:
16
16
17These languages generally agree that an `Int` may be implicitly cast to a `Float` when necessary. So everyone is doing it, why not Elm?!
17These languages generally agree that an `Int` may be implicitly cast to a `Float` when necessary. So everyone is doing it, why not Elm?!
18
18
19−> **Note:** Ruby does not follow the trend. They implicitly cast a `Float` to an `Int`, truncating all the decimal points!
20−
21−
22## Type Inference + Implicit Casts
19## Type Inference + Implicit Casts
23
20
24Elm comes from the ML-family of languages. Languages in the ML-family that **never** do implicit casts include:
21Elm comes from the ML-family of languages. Languages in the ML-family that **never** do implicit casts include:
@@ -41,7 +38,7 @@ So for any ML-family language designed before Scala, it is safe to assume that i
41
38
42 2. Based on experience reports from Scala users, it seemed like the convenience was not worth the hidden cost. Yes, you can convert `n` in `(n + 1.5)` and everything is nice, but when you are in larger programs that are sparsely annotated, it can be quite difficult to figure out what is going on.
39 2. Based on experience reports from Scala users, it seemed like the convenience was not worth the hidden cost. Yes, you can convert `n` in `(n + 1.5)` and everything is nice, but when you are in larger programs that are sparsely annotated, it can be quite difficult to figure out what is going on.
43
40
44−This user data may be confounded by the fact that Scala allows quite extensive conversions, not just from `Int` to `Float`, but I think it is worth taking seriously nonetheless. So it is _possible_, but it is has tradeoffs.
41+This user data may be confounded by the fact that Scala allows quite extensive conversions, not just from `Int` to `Float`, but I think it is worth taking seriously nonetheless. So it is _possible_, but it has tradeoffs.
45
42
46
43
47## Conclusion
44## Conclusion
hints/import-cycles.md+1−1
@@ -55,7 +55,7 @@ type alias User =
55 }
55 }
56```
56```
57
57
58−Notice that the `Comment` type alias is defined in terms of the `User` type alias and vice versa. Having recursive type aliases like this does not work! That problem is described in depth [here](recursive-alias), but the quick takeaway is that one `type alias` needs to become a `type` to break the recursion. So let’s try again:
58+Notice that the `Comment` type alias is defined in terms of the `User` type alias and vice versa. Having recursive type aliases like this does not work! That problem is described in depth [here](recursive-alias.md), but the quick takeaway is that one `type alias` needs to become a `type` to break the recursion. So let’s try again:
59
59
60```elm
60```elm
61module BadCombination2 exposing (..)
61module BadCombination2 exposing (..)
hints/optimize.md+2−2
@@ -21,7 +21,7 @@ Putting those together, here is how I would optimize `src/Main.elm` with two ter
21
21
22```bash
22```bash
23elm make src/Main.elm --optimize --output=elm.js
23elm make src/Main.elm --optimize --output=elm.js
24−uglifyjs elm.js --compress "pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe" | uglifyjs --mangle --output=elm.min.js
24+uglifyjs elm.js --compress "pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe" | uglifyjs --mangle --output elm.min.js
25```
25```
26
26
27After this you will have an `elm.js` and a significantly smaller `elm.min.js` file!
27After this you will have an `elm.js` and a significantly smaller `elm.min.js` file!
@@ -46,7 +46,7 @@ min="elm.min.js"
46
46
47elm make --optimize --output=$js $@
47elm make --optimize --output=$js $@
48
48
49−uglifyjs $js --compress "pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe" | uglifyjs --mangle --output=$min
49+uglifyjs $js --compress "pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe" | uglifyjs --mangle --output $min
50
50
51echo "Initial size: $(cat $js | wc -c) bytes ($js)"
51echo "Initial size: $(cat $js | wc -c) bytes ($js)"
52echo "Minified size:$(cat $min | wc -c) bytes ($min)"
52echo "Minified size:$(cat $min | wc -c) bytes ($min)"
hints/recursive-alias.md+2−2
@@ -39,7 +39,7 @@ It is much easier to write down `Person` in a type, and then it will just expand
39
39
40## Recursive type aliases?
40## Recursive type aliases?
41
41
42−Okay, so lets say you have some type that may contain itself. In Elm, a common example of this is a comment that might have subcomments:
42+Okay, so let's say you have some type that may contain itself. In Elm, a common example of this is a comment that might have subcomments:
43
43
44```elm
44```elm
45type alias Comment =
45type alias Comment =
@@ -102,7 +102,7 @@ type Comment =
102 }
102 }
103```
103```
104
104
105−Now lets say you want to register an upvote on a comment:
105+Now let's say you want to register an upvote on a comment:
106
106
107```elm
107```elm
108upvote : Comment -> Comment
108upvote : Comment -> Comment
hints/type-annotations.md+1−3
@@ -8,7 +8,7 @@ This document is going to outline the various things that can go wrong and show
8
8
9## Annotation vs. Definition
9## Annotation vs. Definition
10
10
11−The most common issue is with user-defined type variables that are too general. So lets say you have defined a function like this:
11+The most common issue is with user-defined type variables that are too general. So let's say you have defined a function like this:
12
12
13```elm
13```elm
14addPair : (a, a) -> a
14addPair : (a, a) -> a
@@ -58,5 +58,3 @@ filter isOkay list =
58This case is very unfortunate because all the type annotations are correct, but there is a detail of how type inference works right now that **user-defined type variables are not shared between annotations**. This can lead to probably the worst type error messages we have because the problem here is that `a` in the outer annotation does not equal `a` in the inner annotation.
58This case is very unfortunate because all the type annotations are correct, but there is a detail of how type inference works right now that **user-defined type variables are not shared between annotations**. This can lead to probably the worst type error messages we have because the problem here is that `a` in the outer annotation does not equal `a` in the inner annotation.
59
59
60For now the best route is to leave off the inner annotation. It is unfortunate, and hopefully we will be able to do a nicer thing in future releases.
60For now the best route is to leave off the inner annotation. It is unfortunate, and hopefully we will be able to do a nicer thing in future releases.
61−
62−"""
installers/README.mdnew file+32
@@ -0,0 +1,32 @@
1+# Installing Elm
2+
3+The normal path is to work through [the guide](https://guide.elm-lang.org/) until you need to install, but you can skip to installation directly by going [here](https://guide.elm-lang.org/install/terminal.html).
4+
5+
6+<br/>
7+
8+## Installing Multiple Versions
9+
10+The secret is that Elm is just a single executable file. If you are developing a project in `~/Desktop/project/` you can download this file into that directory and run commands like `~/Desktop/project/elm make src/Main.elm` or `./elm make src/Main.elm`. You just run the local copy of the executable file!
11+
12+The instructions for [Mac][mac] and [Linux][lin] explain how to do this in more detail. You can follow the same steps on Windows, but you need to do each step by hand. (E.g. download the file through your browser rather than with a terminal command.)
13+
14+[mac]: https://github.com/elm/compiler/blob/master/installers/mac/README.md
15+[lin]: https://github.com/elm/compiler/blob/master/installers/linux/README.md
16+
17+<br/>
18+
19+## Installing Previous Versions
20+
21+The past binaries for Mac, Linux, and Windows are hosted [here](https://github.com/elm/compiler/releases).
22+
23+You can download the executable files directly and use them locally.
24+
25+
26+<br/>
27+
28+## Uninstall
29+
30+- [Mac](https://github.com/elm/compiler/blob/master/installers/mac/README.md#uninstall)
31+- [Linux](https://github.com/elm/compiler/blob/master/installers/linux/README.md#uninstall)
32+- [Windows](https://github.com/elm/compiler/blob/master/installers/win/README.md#uninstall)
installers/linux/Dockerfile+33−19
@@ -1,25 +1,39 @@
1−# Create: https://gist.github.com/rlefevre/1523f47e75310e28eee243c9c5651ac9
1+# Based initially on https://gist.github.com/rlefevre/1523f47e75310e28eee243c9c5651ac9
2+#
3+# Build Linux x64 binary from elm compiler top-level directory:
4+# $ docker build -t elm -f installers/linux/Dockerfile .
5+#
6+# Retrieve elm Linux binary:
7+# $ docker cp $(docker create elm):/usr/local/bin/elm DESTINATION_DIRECTORY
8+#
9+# Delete docker elm image:
10+# $ docker rmi elm
11+#
12+# Display all images:
13+# $ docker images -a
14+#
15+# Delete all unused docker images:
2−# Delete: docker system prune -a ; docker images -a
16+# $ docker system prune -a
3
17
18+# Use Alpine 3.11 with GHC 8.6.5
4−FROM alpine:3.10
19+FROM alpine:3.11
5
20
6−# branch
21+# Install packages required to build elm
7−ARG branch=master
22+RUN apk add --no-cache ghc cabal wget musl-dev zlib-dev zlib-static ncurses-dev ncurses-static
8−# commit or tag
9−ARG commit=HEAD
10
23
11−# Install required packages
24+WORKDIR /elm
12−RUN apk add --update ghc cabal git musl-dev zlib-dev ncurses-dev ncurses-static wget
13
25
26+# Import source code
27+COPY builder builder
14−# Checkout elm compiler
28+COPY compiler compiler
15−WORKDIR /tmp
29+COPY reactor reactor
16−RUN git clone -b $branch https://github.com/elm/compiler.git
30+COPY terminal terminal
31+COPY cabal.config elm.cabal LICENSE ./
17
32
18−# Build a statically linked elm binary
33+# Build statically linked elm binary
19−WORKDIR /tmp/compiler
20−RUN git checkout $commit
21−RUN rm worker/elm.cabal
22RUN cabal new-update
34RUN cabal new-update
23−RUN cabal new-configure --disable-executable-dynamic --ghc-option=-optl=-static --ghc-option=-optl=-pthread
35+RUN cabal new-build --ghc-option=-optl=-static --ghc-option=-split-sections
24−RUN cabal new-build
25−RUN strip -s ./dist-newstyle/build/x86_64-linux/ghc-8.4.3/elm-0.19.1/x/elm/build/elm/elm
36+RUN cp ./dist-newstyle/build/x86_64-linux/ghc-*/elm-*/x/elm/build/elm/elm /usr/local/bin/elm
37+
38+# Remove debug symbols to optimize the binary size
39+RUN strip -s /usr/local/bin/elm
installers/linux/README.md+25−3
@@ -9,7 +9,7 @@ It should be possible to install it by running the following commands in your te
9#
9#
10cd ~/Desktop/
10cd ~/Desktop/
11
11
12−# Download the 0.19.0 binary for Linux.
12+# Download the 0.19.1 binary for Linux.
13#
13#
14# +-----------+----------------------+
14# +-----------+----------------------+
15# | FLAG | MEANING |
15# | FLAG | MEANING |
@@ -18,7 +18,7 @@ cd ~/Desktop/
18# | -o elm.gz | name the file elm.gz |
18# | -o elm.gz | name the file elm.gz |
19# +-----------+----------------------+
19# +-----------+----------------------+
20#
20#
21−curl -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.0/binary-for-linux-64-bit.gz
21+curl -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz
22
22
23# There should now be a file named `elm.gz` on your Desktop.
23# There should now be a file named `elm.gz` on your Desktop.
24#
24#
@@ -64,8 +64,30 @@ This prints `/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin` on my computer. The d
64
64
65When I run `elm make src/Main.elm`, my terminal starts by searching these five directories for an executable file named `elm`. It finds `/usr/local/bin/elm` and then runs `/usr/local/bin/elm make src/Main.elm` with whatever arguments I gave.
65When I run `elm make src/Main.elm`, my terminal starts by searching these five directories for an executable file named `elm`. It finds `/usr/local/bin/elm` and then runs `/usr/local/bin/elm make src/Main.elm` with whatever arguments I gave.
66
66
67−So the `PATH` environment variable is a convention that allows you to refer to a specific executable file without knowing exactly where it lives on your computer. This is actually how all "terminal commands" work! Commands like `ls` and `cd` are really executable files that live in directories like `/bin` and `/usr/bin` that happen to be listed in your `PATH` variable.
67+So the `PATH` environment variable is a convention that allows you to refer to a specific executable file without knowing exactly where it lives on your computer. This is actually how all "terminal commands" work! Commands like `ls` are really executable files that live in directories listed in your `PATH` variable.
68
68
69So the point of running `sudo mv elm /usr/local/bin/` is to turn the `elm` binary into a terminal command, allowing us to call it just like `ls` and `cd`.
69So the point of running `sudo mv elm /usr/local/bin/` is to turn the `elm` binary into a terminal command, allowing us to call it just like `ls` and `cd`.
70
70
71**Note:** Why do we need to use `sudo` for that one command? Imagine if some program was able to add executables named `ls` or `cd` to `/usr/local/bin` that did something tricky and unexpected. That would be a security problem! Many distributions make this scenario less likely by requiring special permissions to modify the `/usr/local/bin/` directory.
71**Note:** Why do we need to use `sudo` for that one command? Imagine if some program was able to add executables named `ls` or `cd` to `/usr/local/bin` that did something tricky and unexpected. That would be a security problem! Many distributions make this scenario less likely by requiring special permissions to modify the `/usr/local/bin/` directory.
72+
73+
74+<br/>
75+
76+## Uninstall
77+
78+The following commands should remove everything:
79+
80+```bash
81+# Remove the `elm` executable.
82+#
83+sudo rm /usr/local/bin/elm
84+
85+# Remove any cached files. The files here reduce compile times when
86+# starting new projects and make it possible to work offline in more
87+# cases. No need to keep it around if you are uninstalling though!
88+#
89+rm -r ~/.elm/
90+```
91+
92+If you have any Elm projects still on your computer, you can remove their `elm-stuff/` directories as well.
93+
installers/mac/Distribution.xml+5−3
@@ -1,6 +1,6 @@
1<?xml version="1.0" encoding="utf-8" standalone="no"?>
1<?xml version="1.0" encoding="utf-8" standalone="no"?>
2<installer-script minSpecVersion="1.000000" authoringTool="com.apple.PackageMaker" authoringToolVersion="3.0.6" authoringToolBuild="201">
2<installer-script minSpecVersion="1.000000" authoringTool="com.apple.PackageMaker" authoringToolVersion="3.0.6" authoringToolBuild="201">
3− <title>Elm Platform</title>
3+ <title>Elm</title>
4 <options customize="allow" allow-external-scripts="no"/>
4 <options customize="allow" allow-external-scripts="no"/>
5 <domains enable_localSystem="true"/>
5 <domains enable_localSystem="true"/>
6 <volume-check script="pm_volume_check();"/>
6 <volume-check script="pm_volume_check();"/>
@@ -10,7 +10,7 @@
10function pm_volume_check() {
10function pm_volume_check() {
11 if(!(my.target.systemVersion &amp;&amp; /* >= */ system.compareVersions(my.target.systemVersion.ProductVersion, '10.6.0') >= 0)) {
11 if(!(my.target.systemVersion &amp;&amp; /* >= */ system.compareVersions(my.target.systemVersion.ProductVersion, '10.6.0') >= 0)) {
12 my.result.title = 'Failure';
12 my.result.title = 'Failure';
13− my.result.message = 'This version of Elm Platform requires Mac OS X 10.6 or later.';
13+ my.result.message = 'This version of Elm requires Mac OS X 10.6 or later.';
14 my.result.type = 'Fatal';
14 my.result.type = 'Fatal';
15 return false;
15 return false;
16 }
16 }
@@ -18,13 +18,15 @@ function pm_volume_check() {
18}
18}
19
19
20</script>
20</script>
21+ <!--
21 <background file="background.png" alignment="bottomleft" scaling="none" mime-type="image/png"/>
22 <background file="background.png" alignment="bottomleft" scaling="none" mime-type="image/png"/>
23+ -->
22 <welcome mime-type="text/rtf" file="welcome.rtf" />
24 <welcome mime-type="text/rtf" file="welcome.rtf" />
23 <conclusion mime-type="text/rtf" file="conclusion.rtf" />
25 <conclusion mime-type="text/rtf" file="conclusion.rtf" />
24 <choices-outline>
26 <choices-outline>
25 <line choice="choice2"/>
27 <line choice="choice2"/>
26 </choices-outline>
28 </choices-outline>
27− <choice id="choice2" title="Elm Platform ">
29+ <choice id="choice2" title="Elm">
28 <pkg-ref id="org.elm-lang.binaries.pkg"/>
30 <pkg-ref id="org.elm-lang.binaries.pkg"/>
29 </choice>
31 </choice>
30 <pkg-ref id="org.elm-lang.binaries.pkg" installKBytes="19444" version="1" auth="Root">binaries.pkg</pkg-ref>
32 <pkg-ref id="org.elm-lang.binaries.pkg" installKBytes="19444" version="1" auth="Root">binaries.pkg</pkg-ref>
installers/mac/README.mdnew file+93
@@ -0,0 +1,93 @@
1+# Install Instructions
2+
3+The easiest way to install is to to use [the Mac installer](https://github.com/elm/compiler/releases/download/0.19.1/installer-for-mac.pkg)!
4+
5+But it is also possible to install by running the following commands in your terminal:
6+
7+```bash
8+# Move to your Desktop so you can see what is going on easier.
9+#
10+cd ~/Desktop/
11+
12+# Download the 0.19.1 binary for Linux.
13+#
14+# +-----------+----------------------+
15+# | FLAG | MEANING |
16+# +-----------+----------------------+
17+# | -L | follow redirects |
18+# | -o elm.gz | name the file elm.gz |
19+# +-----------+----------------------+
20+#
21+curl -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-mac-64-bit.gz
22+
23+# There should now be a file named `elm.gz` on your Desktop.
24+#
25+# The downloaded file is compressed to make it faster to download.
26+# This next command decompresses it, replacing `elm.gz` with `elm`.
27+#
28+gunzip elm.gz
29+
30+# There should now be a file named `elm` on your Desktop!
31+#
32+# Every file has "permissions" about whether it can be read, written, or executed.
33+# So before we use this file, we need to mark this file as executable:
34+#
35+chmod +x elm
36+
37+# The `elm` file is now executable. That means running `~/Desktop/elm --help`
38+# should work. Saying `./elm --help` works the same.
39+#
40+# But we want to be able to say `elm --help` without specifying the full file
41+# path every time. We can do this by moving the `elm` binary to one of the
42+# directories listed in your `PATH` environment variable:
43+#
44+sudo mv elm /usr/local/bin/
45+
46+# Now it should be possible to run the `elm` binary just by saying its name!
47+#
48+elm --help
49+```
50+
51+<br/>
52+
53+## What is the `PATH` variable?
54+
55+When you run a command like `elm make src/Main.elm`, your computer starts by trying to find an executable file called `elm`.
56+
57+The `PATH` is the list of directories that get searched. You can see these directories by running:
58+
59+```bash
60+echo $PATH
61+```
62+
63+This prints `/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin` on my computer. The directories are separated by a `:` so there are five possibilities listed here.
64+
65+When I run `elm make src/Main.elm`, my terminal starts by searching these five directories for an executable file named `elm`. It finds `/usr/local/bin/elm` and then runs `/usr/local/bin/elm make src/Main.elm` with whatever arguments I gave.
66+
67+So the `PATH` environment variable is a convention that allows you to refer to a specific executable file without knowing exactly where it lives on your computer. This is actually how all "terminal commands" work! Commands like `ls` are really executable files that live in directories listed in your `PATH` variable.
68+
69+So the point of running `sudo mv elm /usr/local/bin/` is to turn the `elm` binary into a terminal command, allowing us to call it just like `ls` and `cd`.
70+
71+**Note:** Why do we need to use `sudo` for that one command? Imagine if some program was able to add executables named `ls` or `cd` to `/usr/local/bin` that did something tricky and unexpected. That would be a security problem! Many distributions make this scenario less likely by requiring special permissions to modify the `/usr/local/bin/` directory.
72+
73+
74+<br/>
75+
76+## Uninstall
77+
78+The following commands should remove everything:
79+
80+```bash
81+# Remove the `elm` executable.
82+#
83+sudo rm /usr/local/bin/elm
84+
85+# Remove any cached files. The files here reduce compile times when
86+# starting new projects and make it possible to work offline in more
87+# cases. No need to keep it around if you are uninstalling though!
88+#
89+rm -r ~/.elm/
90+```
91+
92+If you have any Elm projects still on your computer, you can remove their `elm-stuff/` directories as well.
93+
installers/mac/Resources/en.lproj/background.pngdeleted

Binary file not shown.

installers/mac/Resources/en.lproj/conclusion.rtf+13−6
@@ -1,9 +1,16 @@
1−{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf400
1+{\rtf1\ansi\ansicpg1252\cocoartf2509
2−{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
2+\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fmodern\fcharset0 CourierNewPSMT;}
3{\colortbl;\red255\green255\blue255;}
3{\colortbl;\red255\green255\blue255;}
4+{\*\expandedcolortbl;;}
4−\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
5+\paperw11900\paperh16840\margl1440\margr1440\vieww11180\viewh8400\viewkind0
5−\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
6+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
6
7
7−\f0\fs26 \cf0 A bunch of useful programs were just placed in /usr/local/bin/\
8+\f0\fs28 \cf0 Try opening the terminal and running commands like:\
8\
9\
10+
11+\f1 elm init\
12+elm make src/Main.elm --optimize\
13+elm repl
14+\f0 \
15+\
9−Check out {\field{\*\fldinst HYPERLINK "http://elm-lang.org/Get-Started.elm"}{\fldrslt this tutorial}} to learn how to use them!}
16+Check out {\field{\*\fldinst{HYPERLINK "https://guide.elm-lang.org/"}}{\fldrslt this tutorial}} for more advice!}
installers/mac/Resources/en.lproj/welcome.rtf+9−4
@@ -1,7 +1,12 @@
1−{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf400
1+{\rtf1\ansi\ansicpg1252\cocoartf2509
2−{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
2+\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fmodern\fcharset0 CourierNewPSMT;}
3{\colortbl;\red255\green255\blue255;}
3{\colortbl;\red255\green255\blue255;}
4+{\*\expandedcolortbl;;}
4\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
5\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
5−\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
6+\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
6
7
7−\f0\fs28 \cf0 This package will install Elm on your machine.}
8+\f0\fs28 \cf0 Thank you for trying out Elm!\
9+\
10+This installer makes
11+\f1 elm
12+\f0 available in your terminal.}
installers/mac/helper-scripts/elm-startup.sh+1−1
@@ -1,3 +1,3 @@
1#!/bin/sh
1#!/bin/sh
2
2
3−open 'http://elm-lang.org'
3+open 'http://guide.elm-lang.org'
installers/mac/make-installer.sh+30−3
@@ -29,7 +29,8 @@ cp $(pwd)/preinstall $pkg_scripts
29cp $(pwd)/postinstall $pkg_scripts
29cp $(pwd)/postinstall $pkg_scripts
30
30
31pkgbuild \
31pkgbuild \
32+ --sign "Developer ID Installer: <NAME>" \
32− --identifier org.elm-lang.binaries.pkg \
33+ --identifier org.elm-lang.binary \
33 --install-location $usr_binaries \
34 --install-location $usr_binaries \
34 --scripts $pkg_scripts \
35 --scripts $pkg_scripts \
35 --filter 'Scripts.*' \
36 --filter 'Scripts.*' \
@@ -39,16 +40,42 @@ pkgbuild \
39
40
40#### BUNDLE ASSETS ####
41#### BUNDLE ASSETS ####
41
42
42−rm -f Elm.pkg
43+rm -f installer-for-mac.pkg
43
44
44productbuild \
45productbuild \
46+ --sign "Developer ID Installer: <NAME>" \
47+ --identifier org.elm-lang.installer \
45 --distribution Distribution.xml \
48 --distribution Distribution.xml \
46 --package-path . \
49 --package-path . \
47 --resources Resources \
50 --resources Resources \
48− Elm.pkg
51+ installer-for-mac.pkg
49
52
50
53
51#### CLEAN UP ####
54#### CLEAN UP ####
52
55
53rm binaries.pkg
56rm binaries.pkg
54rm -rf $pkg_root
57rm -rf $pkg_root
58+
59+
60+#### BEGIN NOTARIZATION ####
61+
62+xcrun altool \
63+ --notarize-app \
64+ --primary-bundle-id "org.elm-lang.installer" \
65+ --username "<EMAIL>" \
66+ --password "@keychain:Developer-altool" \
67+ --file "installer-for-mac.pkg"
68+
69+# From https://scriptingosx.com/2019/09/notarize-a-command-line-tool/
70+#
71+#### Check on notarization:
72+#
73+# xcrun altool \
74+# --notarization-info "<RequestUUID>" \
75+# --username "<EMAIL>" \
76+# --password "@keychain:Developer-altool"
77+#
78+#
79+#### Staple Notarization:
80+#
81+# xcrun stapler staple installer-for-mac.pkg
installers/npm/PUBLISHING.md+29−141
@@ -1,171 +1,59 @@
1−# Publishing a new release
1+# Publishing
2
2
3−A new version of Elm came out. Huzzah! Here's how to update the `npm` installer.
3+Here's how to update the `npm` installer.
4
4
5−## 1. Create tarballs of binaries
6
5
7−You can find a list of what binaries we'll need to tar up in `index.js`.
6+## 1. GitHub Release
8
7
9−For example:
8+Create a [GitHub Release](https://github.com/elm/compiler/releases) with the following files:
10
9
11−```javascript
10+1. `binary-for-mac-64-bit.gz`
12−var root =
11+2. `binary-for-windows-64-bit.gz`
13− "https://github.com/elm/compiler/releases/download/" +
12+3. `binary-for-linux-64-bit.gz`
14− binVersion +
15− "/binaries-for-";
16
13
17−module.exports = binwrap({
14+Create each of these by running the `elm` executable for each platform through `gzip elm`.
18− binaries: ["elm"],
19− urls: {
20− "darwin-x64": root + "mac.tar.gz",
21− "win32-x64": root + "windows.tar.gz",
22− "win32-ia32": root + "windows.tar.gz",
23− "linux-x64": root + "linux.tar.gz"
24− }
25−});
26−```
27−
28−If this is the end of your `index.js`, you'll need to create these files:
29
15
30−1. `binaries-for-mac.tar.gz`
31−2. `binaries-for-windows.tar.gz`
32−3. `binaries-for-linux.tar.gz`
33
16
34−Each of these tarballs should have **only the Elm binary** inside them - no
17+## 2. Try a beta release
35−directories!
36
18
37−So create them by making a directory, putting all the binaries in it, `cd`-ing
19+In `package.json`, bump the version to `"0.19.2-beta"`.
38−into that directory, and then running something like this:
39
20
40−```shell
21+```bash
41−$ tar cvzf binaries-for-linux.tar.gz elm
22+npm publish --tag beta
42```
23```
43
24
44−Make sure each tarball contains all the binaries listed in that `binaries:` list
25+To test that it works, run these commands:
45−in `index.js`. (The Windows ones should have `.exe` at the end; `binwrap`
46−expects that they will, for Windows only.)
47−
48−## 2. Update the `bin/` binary wrappers
49−
50−Inside the npm installer's `bin/` directory, there should be a file for each of
51−the binaries that will be included in this release.
52−
53−Each of these must be executable! If you're not sure whether they are,
54−run `chmod +x` on them just to be sure.
55−
56−Their paths must also must all be listed in `package.json` in two places:
57−
58−1. The `"files":` field
59−2. The `"bin":` field
60−
61−If the executables are the same as they were for the last release, great!
62−You can proceed to the next step. If any binaries were removed, make sure to
63−remove them from these lists!
64−
65−## 3. Update `package.json` for a beta release
66−
67−In `package.json`, bump the version to the next applicable release, and add
68−a `"-beta"` suffix to it.
69−
70−For example, if it was on `"0.18.0"` you might bump it to `"0.19.0-beta"`.
71−The version number should match the release of Elm, such that if people do
72−`npm install elm@0.19.0@beta` they get what they would expect.
73−
74−## 4. Tag the beta release
75−
76−Commit this change and tag it with the name of the release **without** the
77−`-beta` suffix. (We will overwrite this tag later.)
78−
79−For example:
80
26
81−```shell
27+```bash
82−$ git tag 0.19.0
28+npm dist-tags ls elm
83−$ git push origin 0.19.0
29+npm install elm@beta --ignore-scripts
84```
30```
85
31
86−Now this tag should exist on GitHub, allowing us to upload binaries to it.
32+The `latest` tag should not be changed, and there should be an additional `beta` tag.
87
33
88−## 5. Upload binaries
34+Try this on Windows, Linux, and Mac.
89
35
90−Visit the [Create a New Release](https://github.com/elm-lang/elm-platform/releases/new)
91−page and use the `Tag version` dropdown to select the tag you just pushed. Give
92−it a title like `0.19.0`. Don't mention the `-beta` in it. The "beta" concept
93−is for `npm` only.
94
36
95−Upload the tarballs you created in step 1.
37+## 3. Publish final release
96
38
97−## 6. Publish beta release
39+Remove the `-beta` suffix from the version in `package.json`. Then run:
98
40
99−Run this to publish the beta release. The `--tag beta` is **crucial** here.
41+```bash
100−Without it, `npm` will by default publish a new top-level release, which would
101−mean that what you just published would become what everyone gets when they
102−`npm install -g elm` without any additional qualifiers.
103−
104−```shell
105−$ npm publish --tag beta
42+npm publish
106```
43```
107
44
108−Afterwards you should be able to do `npm info elm | less` and see something
109−like this in the JSON:
110−
111−```
112−'dist-tags': { latest: '0.18.0', beta: '0.19.0-beta' }
113−```
114
45
115−If you messed this up, and the `latest` tag now points to the beta you just
46+## 4. Tag the `latest-0.19.1` version
116−published, don't panic - it's fixable! `dist-tags` can always be modified after
117−the fact. Read up on `npm` [dist-tags](https://docs.npmjs.com/cli/dist-tag)
118−to learn how to fix things.
119
47
120−## 7. Verify beta installer
48+Many compiler releases have needed multiple `npm` publications. Maybe something does not work on Windows or some dependency becomes insecure. Normal `npm` problems.
121
49
122−Make an empty directory and run `npm init` inside it.
50+The convention for each Elm release is to create a tag the latest one.
123
51
124−Then run this:
52+```bash
125−
53+npm dist-tag add elm@0.19.1-3 latest-0.19.1
126−```shell
127−$ npm install elm@beta --ignore-scripts
128```
54```
129
55
130−This should succeed with an exit code of `0`.
56+That way people who want a specific version can point to `latest-0.19.1` or `latest-0.18.0` instead of knowing the particular names of all the various publications.
131−If it did, look in `node_modules/.bin/` for the binaries you expect.
132−They should be present, and they should also work as expected when you run them.
133−Because you installed them with `--ignore-scripts`, the first thing they should
134−do is to download themselves and then execute whatever command you requested
135−(e.g. `node_modules/.bin/elm make Main.elm`). If you run the same command a
136−second time, it should run faster because it doesn't have to download the binary
137−first.
138−
139−Now try it again with `--ignore-scripts` turned off:
140−
141−```shell
142−$ rm -r node_modules
143−$ npm install elm@beta --ignore-scripts=false
144−```
145−
146−This time it should download the binaries during the installation phase. Once
147−again you should be able to run the binaries from `node_modules/.bin/`, and
148−this time they should be fast from the first run because they're already
149−downloaded.
150−
151−## 8. Publish for real
152−
153−It's a good idea to ask others to try out the beta installer before doing this!
154−Especially on multiple operating systems.
155−
156−To publish the real version:
157−
158−1. Edit `package.json` to remove the `-beta` suffix from the version.
159−2. Commit that change and push it.
160−3. Use `git tag --force` to overwrite the previous tag (e.g. `0.19.0` - whatever you used before).
161−4. Force push the tag, e.g. `git push origin 0.19.0 --force-with-lease`.
162−5. `npm publish`
163
57
164−You're done! Now whenever anyone does `npm install -g elm` they'll get the
58+You can read more about dist-tags [here](https://docs.npmjs.com/cli/dist-tag).
165−version you just uploaded.
166
59
167−The reason we only used the `-beta` suffix for `npm` was so that when we ran
168−tests on the beta version, it was all against the same (non-beta) URLs we'd end
169−up using for the real version. This means there's no opportunity for us to
170−introduce some sort of mismatch between the beta that we verified and the real
171−version.
installers/npm/README.md+26−15
@@ -1,34 +1,45 @@
1−# npm install elm
1+# Elm Installer
2
2
3[Elm](https://elm-lang.org) is a functional programming language that compiles to JavaScript.
3[Elm](https://elm-lang.org) is a functional programming language that compiles to JavaScript.
4
4
5−There are installers for Mac and Windows available [here](https://github.com/elm/compiler/releases/tag/0.19.1). There are also binaries for direct download. These are the most reliable ways to install Elm.
5+Head over to [The Official Guide](https://guide.elm-lang.org/) to start learning Elm!
6
6
7−This package tries to download those binaries with `npm`. It is sometimes used by people intergating Elm into existing projects or workflows.
8
7
9<br/>
8<br/>
10
9
10+## What is this package for?
11
11
12−## Install
12+**Normal installs** ❌
13
13
14−The following command should download the `elm` binary:
14+Use the instructions [here](https://guide.elm-lang.org/install/elm.html) instead.
15
15
16−```
16+**Multiple versions** ✅
17−npm install -g elm
18−```
19
17
20−If this runs successfully, the `elm` binary should be available at:
18+People using Elm at work may use different versions of Elm in different projects. They can run `npm install elm@latest-0.19.1` in each project and use the binary at `./node_modules/.bin/elm` for compilation.
21
19
22−- `/usr/local/bin/elm` on Mac and Linux
20+**Continuous integration** ⚠️
23−- `C:\Users\YOUR_NAME\AppData\Roaming\npm\` on Windows
24
21
25−It should be possible to run `elm` from your terminal after this.
22+This works, but there are usually faster and more reliable options:
23+
24+1. You can download `elm` directly from GitHub with [this script](https://github.com/elm/compiler/blob/master/installers/linux/README.md). This is all the `npm` installer does, but with extra HTTP requests to `npmjs.com` servers, making it slower and adding more failure points.
25+2. Many continuous integration have ways to cache files ([example](https://docs.travis-ci.com/user/caching/)) to make builds faster and more reliable.
26+
27+That said, it will definitely work to use the `npm` installer on CI if you prefer that option.
26
28
27−If you run into trouble, check out [troubleshooting.md](troubleshooting.md).
28
29
29<br/>
30<br/>
30
31
32+## Install Locally
31
33
32−## What is next?
34+The following command should download the latest Elm 0.19.1 binary:
35+
36+```
37+npm install elm@latest-0.19.1
38+```
39+
40+You should be able to run `./node_modules/bin/elm --version` within your project and see `0.19.1`. Now you can compile with `./node_modules/bin/elm make src/Main.elm` and not disrupt other packages.
41+
42+Use `npm install elm@latest-0.19.0` or `npm install elm@latest-0.18.0` for earlier versions.
43+
44+**Note:** The `latest-X.Y.Z` convention is used in case we need to publish patches for the `npm` installer within a given Elm release. For example, say `npm` decides that some transitive dependency is not secure. Nothing is changing about Elm or the binaries, but we need to publish a new `npm` installer that fixes this issue.
33
45
34−Head over to [The Official Guide](https://guide.elm-lang.org/) to start learning Elm!
installers/npm/bin/elm+15−8
@@ -1,13 +1,13 @@
1#!/usr/bin/env node
1#!/usr/bin/env node
2
2
3var child_process = require('child_process');
3var child_process = require('child_process');
4−var package = require('../package.json');
5var path = require('path');
4var path = require('path');
6var fs = require('fs');
5var fs = require('fs');
7
6
8
7
9−// Some npm users enable --ignore-scripts (a good security measure)
8+// Some npm users enable --ignore-scripts (a good security measure) so
10−// They do not run the post-install hook, so install.js does not run.
9+// they do not run the post-install hook and install.js does not run.
10+// Instead they will run this script.
11//
11//
12// On Mac and Linux, we download the elm executable into the exact same
12// On Mac and Linux, we download the elm executable into the exact same
13// location as this file. Since npm uses symlinks on these platforms,
13// location as this file. Since npm uses symlinks on these platforms,
@@ -15,7 +15,7 @@ var fs = require('fs');
15// runs will call the elm binary directly.
15// runs will call the elm binary directly.
16//
16//
17// On Windows, we must download a file named elm.exe for it to run properly.
17// On Windows, we must download a file named elm.exe for it to run properly.
18−// Instead of symlinks, they create two files:
18+// Instead of symlinks, npm creates two files:
19//
19//
20// - node_modules/.bin/elm (a bash file)
20// - node_modules/.bin/elm (a bash file)
21// - node_modules/.bin/elm.cmd (a batch file)
21// - node_modules/.bin/elm.cmd (a batch file)
@@ -27,14 +27,21 @@ var fs = require('fs');
27
27
28// figure out where to put the binary (calls path.resolve() to get path separators right on Windows)
28// figure out where to put the binary (calls path.resolve() to get path separators right on Windows)
29//
29//
30−var binaryPath = path.resolve(__dirname, package.bin) + (process.platform === 'win32' ? '.exe' : '');
30+var binaryPath = path.resolve(__dirname, 'elm') + (process.platform === 'win32' ? '.exe' : '');
31
31
32// Run the command directly if possible, otherwise download and then run.
32// Run the command directly if possible, otherwise download and then run.
33// This check is important for Windows where this file will be run all the time.
33// This check is important for Windows where this file will be run all the time.
34//
34//
35+if (process.platform === 'win32')
36+{
35−fs.existsSync(binaryPath)
37+ fs.existsSync(binaryPath)
36− ? runCommand()
38+ ? runCommand()
37− : require('../download.js')(runCommand);
39+ : require('../download.js')(runCommand);
40+}
41+else
42+{
43+ require('../download.js')(runCommand);
44+}
38
45
39
46
40function runCommand()
47function runCommand()
installers/npm/download.js+54−4
@@ -16,12 +16,22 @@ module.exports = function(callback)
16{
16{
17 // figure out URL of binary
17 // figure out URL of binary
18 var version = package.version.replace(/^(\d+\.\d+\.\d+).*$/, '$1'); // turn '1.2.3-alpha' into '1.2.3'
18 var version = package.version.replace(/^(\d+\.\d+\.\d+).*$/, '$1'); // turn '1.2.3-alpha' into '1.2.3'
19− var os = { 'darwin': 'mac', 'win32': 'windows', 'linux': 'linux' }[process.platform];
19+
20− var arch = { 'x64': '64-bit', 'ia32': '32-bit' }[process.arch];
20+ var platform = {
21+ darwin_x64: 'mac-64-bit',
22+ darwin_arm64: 'mac-64-bit',
23+ win32_x64: 'windows-64-bit',
24+ linux_x64: 'linux-64-bit'
25+ }[process.platform + '_' + process.arch];
26+
27+ verifyPlatform(version, platform);
28+
21− var url = 'https://github.com/elm/compiler/releases/download/' + version + '/binary-for-' + os + '-' + arch + '.gz';
29+ var url = 'https://github.com/elm/compiler/releases/download/' + version + '/binary-for-' + platform + '.gz';
30+
31+ reportDownload(version, url);
22
32
23 // figure out where to put the binary (calls path.resolve() to get path separators right on Windows)
33 // figure out where to put the binary (calls path.resolve() to get path separators right on Windows)
24− var binaryPath = path.resolve(__dirname, package.bin) + (process.platform === 'win32' ? '.exe' : '');
34+ var binaryPath = path.resolve(__dirname, package.bin.elm) + (process.platform === 'win32' ? '.exe' : '');
25
35
26 // set up handler for request failure
36 // set up handler for request failure
27 function reportDownloadFailure(error)
37 function reportDownloadFailure(error)
@@ -48,6 +58,30 @@ module.exports = function(callback)
48
58
49
59
50
60
61+// VERIFY PLATFORM
62+
63+
64+function verifyPlatform(version, platform)
65+{
66+ if (platform) return;
67+
68+ var situation = process.platform + '_' + process.arch;
69+ console.error(
70+ '-- ERROR -----------------------------------------------------------------------\n\n'
71+ + 'I am detecting that your computer (' + situation + ') may not be compatible with any\n'
72+ + 'of the official pre-built binaries.\n\n'
73+ + 'I recommend against using the npm installer for your situation. Check out the\n'
74+ + 'alternative installers at https://github.com/elm/compiler/releases/tag/' + version + '\n'
75+ + 'to see if there is something that will work better for you.\n\n'
76+ + 'From there I recommend asking for guidance on Slack or Discourse to find someone\n'
77+ + 'who can help with your specific situation.\n\n'
78+ + '--------------------------------------------------------------------------------\n'
79+ );
80+ process.exit(1);
81+}
82+
83+
84+
51// EXIT FAILURE
85// EXIT FAILURE
52
86
53
87
@@ -62,3 +96,19 @@ function exitFailure(url, message)
62 );
96 );
63 process.exit(1);
97 process.exit(1);
64}
98}
99+
100+
101+
102+// REPORT DOWNLOAD
103+
104+
105+function reportDownload(version, url)
106+{
107+ console.log(
108+ '--------------------------------------------------------------------------------\n\n'
109+ + 'Downloading Elm ' + version + ' from GitHub.'
110+ + '\n\nNOTE: You can avoid npm entirely by downloading directly from:\n'
111+ + url + '\nAll this package does is download that file and put it somewhere.\n\n'
112+ + '--------------------------------------------------------------------------------\n'
113+ );
114+}
installers/npm/package.json+3−3
@@ -1,6 +1,6 @@
1{
1{
2 "name": "elm",
2 "name": "elm",
3− "version": "0.19.0-no-deps",
3+ "version": "0.19.1-5",
4 "description": "Installer for Elm: just downloads the binary into node_modules",
4 "description": "Installer for Elm: just downloads the binary into node_modules",
5 "preferGlobal": true,
5 "preferGlobal": true,
6 "license": "BSD-3-Clause",
6 "license": "BSD-3-Clause",
@@ -25,7 +25,7 @@
25 "install.js",
25 "install.js",
26 "download.js",
26 "download.js",
27 "bin",
27 "bin",
28− "bin/elm.exe"
28+ "bin/elm"
29 ],
29 ],
30 "keywords": [
30 "keywords": [
31 "bin",
31 "bin",
@@ -35,7 +35,7 @@
35 "install",
35 "install",
36 "installer"
36 "installer"
37 ],
37 ],
38− "bin": "bin/elm",
38+ "bin": { "elm": "bin/elm" },
39 "dependencies": {
39 "dependencies": {
40 "request": "^2.88.0"
40 "request": "^2.88.0"
41 }
41 }
installers/npm/troubleshooting.md+5−4
@@ -16,10 +16,11 @@ The most reliable way to get Elm installed using the official installers for Mac
16You can also download the binaries directly. On Linux, you could do it in the terminal like this:
16You can also download the binaries directly. On Linux, you could do it in the terminal like this:
17
17
18```bash
18```bash
19+cd ~/Desktop/
19−curl -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz
20+curl -L -o elm.gz https://github.com/elm/compiler/releases/download/0.19.1/binary-for-linux-64-bit.gz
20−gunzip elm.gz # unzip the file
21+gunzip elm.gz # unzip the file
21−chmod +x elm # make the file executable
22+chmod +x elm # make the file executable
22−mv elm /usr/local/bin/ # put the executable in a directory likely to be listed in your PATH variable
23+sudo mv elm /usr/local/bin/ # put the executable in a directory likely to be listed in your PATH variable
23```
24```
24
25
25If these exact commands do not work for you, you can try to do the same thing by hand.
26If these exact commands do not work for you, you can try to do the same thing by hand.
installers/win/Nsisfile.nsi+15−15
@@ -75,7 +75,7 @@ Function un.onInit
75FunctionEnd
75FunctionEnd
76
76
77Function LaunchLink
77Function LaunchLink
78− ExecShell "open" "https://elm-lang.org/get-started"
78+ ExecShell "open" "https://guide.elm-lang.org"
79FunctionEnd
79FunctionEnd
80
80
81;--------------------------------
81;--------------------------------
@@ -135,20 +135,20 @@ SectionEnd
135
135
136SectionGroup "Update system settings" SecGr
136SectionGroup "Update system settings" SecGr
137
137
138−Section "Associate with .elm files" SecAssoc
138+;Section "Associate with .elm files" SecAssoc
139−
139+;
140− SectionIn 1
140+; SectionIn 1
141−
141+;
142− ; File associations
142+; ; File associations
143− WriteRegStr HKCR ".elm" "" "elm"
143+; WriteRegStr HKCR ".elm" "" "elm"
144− WriteRegStr HKCR "elm" "" "Elm Source File"
144+; WriteRegStr HKCR "elm" "" "Elm Source File"
145− WriteRegStr HKCR "elm\DefaultIcon" "" "$INSTDIR\file.ico"
145+; WriteRegStr HKCR "elm\DefaultIcon" "" "$INSTDIR\file.ico"
146− ;WriteRegStr HKCR "elm\shell\open\command" "" '"$INSTDIR\bin\elm.exe" "%1"'
146+; WriteRegStr HKCR "elm\shell\open\command" "" '"$INSTDIR\bin\elm.exe" "%1"'
147−
147+;
148− ;Remember that we registered associations
148+; ;Remember that we registered associations
149− WriteRegDWORD HKLM "${PRODUCT_DIR_REG_KEY}" Assocs 0x1
149+; WriteRegDWORD HKLM "${PRODUCT_DIR_REG_KEY}" Assocs 0x1
150−
150+;
151−SectionEnd
151+;SectionEnd
152
152
153Section "Update the PATH environment variable" SecPath
153Section "Update the PATH environment variable" SecPath
154
154
installers/win/README.md+18−3
@@ -1,9 +1,24 @@
1+# Installing on Windows
2+
3+The installer for Windows is available [here](https://guide.elm-lang.org/install.html).
4+
5+
6+<br/>
7+
8+## Uninstall
9+
10+First run the `C:\Program Files (x86)\Elm\0.19\uninstall.exe` file. This will remove Elm stuff from your `PATH`.
11+
12+Then remove the whole `C:\Users\<username>\AppData\Roaming\elm` directory. Elm caches some packages and build artifacts to reduce compile times and to help you work offline. Getting rid of this directory will clear that information out!
13+
14+<br/>
15+
1−# Building Windows installer
16+## Building the Windows installer
2
17
3You will need the [NSIS installer](http://nsis.sourceforge.net/Download) to be installed.
18You will need the [NSIS installer](http://nsis.sourceforge.net/Download) to be installed.
4
19
5Once everything is installed, run something like this command:
20Once everything is installed, run something like this command:
6
21
7− make_installer.cmd 0.19
22+ make_installer.cmd 0.19.0
8
23
9−It will build an installer called `Elm-0.19-setup.exe`.
24+It will build an installer called `Elm-0.19.0-setup.exe`.
installers/win/file.icodeleted

Binary file not shown.

installers/win/inst.dat+1−2
@@ -2,6 +2,5 @@ SetOutPath "$INSTDIR\bin"
2File "${FILES_SOURCE_PATH}\bin\elm.exe"
2File "${FILES_SOURCE_PATH}\bin\elm.exe"
3
3
4SetOutPath "$INSTDIR"
4SetOutPath "$INSTDIR"
5−File "file.ico"
6File "updatepath.vbs"
5File "updatepath.vbs"
7−File "removefrompath.vbs"
6+File "removefrompath.vbs"
installers/win/logo.ico

Binary file not shown.

installers/win/uninst.dat+1−2
@@ -1,7 +1,6 @@
1Delete "$INSTDIR\bin\elm.exe"
1Delete "$INSTDIR\bin\elm.exe"
2RmDir "$INSTDIR\bin"
2RmDir "$INSTDIR\bin"
3
3
4−Delete "$INSTDIR\file.ico"
5Delete "$INSTDIR\updatepath.vbs"
4Delete "$INSTDIR\updatepath.vbs"
6Delete "$INSTDIR\removefrompath.vbs"
5Delete "$INSTDIR\removefrompath.vbs"
7−RmDir "$INSTDIR"
6+RmDir "$INSTDIR"
installers/win/welcome.bmp

Binary file not shown.

roadmap.mdnew file+29
@@ -0,0 +1,29 @@
1+# Roadmap
2+
3+If you like what you see now, that's pretty much what Elm is going to be for a while.
4+
5+I'm currently doing some exploratory work with compiler techniques and targets, but it is still too early to tell which parts of that might work out. I know many readers take "exploring X" as a promise that "X will definitely happen", so I want to be careful in setting expectations low since there is still so much uncertainty in the work. So while there is no real news to share at this point, I can give some expectations about future stability of Elm:
6+
7+**If this exploratory work goes well**, even in the wildest version of success, I wouldn't expect the language or core packages to change very much. Maybe two or three years down the line it could reveal something that'd be good to fix up, but I don't really foresee notable changes right now.
8+
9+**If this exploratory work does not work out**, I have some more conservative projects that are good ideas that I want to circle back to at some point. Things like:
10+
11+- add a constrained type variable `eq` to get rid of the runtime error for `(==)` on functions
12+- try to integrate `elm test` so it can run only tests that changed
13+- try to get `elm format` using the latest parsing infrastructure so it's not a perf bottleneck during development anymore
14+- do another round on perf because I have one last idea that can squeeze out a bit more speed
15+
16+These are all nice quality of life things, but with 0.19.0 and 0.19.1 taking so long, I got pretty burnt out on "incremental improvements that are good ideas, but take a very long time and aren't very exciting to non-Elm users." Without getting too into the details, I really needed to change things up before returning to these particular ideas.
17+
18+If someone has a security issue from the compiler or core libraries, please DM me about it on the Elm Slack. Outside of security issues, I think capacity for more discretionary changes will increase once the lessons from the compiler explorations become more clear. Hopefully the discussion [here](https://discourse.elm-lang.org/t/costs-funding-in-open-source-languages/5722) clarifies the thinking on these capacity questions a bit.
19+
20+<br>
21+<br>
22+
23+**Taking a step back**, I have found that working in this looser style has produced a high baseline of quality, and I think that is an important part of Elm. For example, all the error message work in Elm began as a project to implement the `--report=json` flag. That work happened to reveal some cool ideas on improving error messages, and if I had been using a rigid roadmap, I might have skipped those ideas to meet the publicly-stated arbitrary deadline. We'd have a clearer roadmap, but error messages no different than other type-inferred languages.
24+
25+So I think having more flexibility in planning is a competitive advantage for Elm in certain ways, but it is obviously a trade off that does not work for everyone. If someone needs more certainty, I generally recommend looking into other languages to see if they have a balance that works better for their needs. For example, languages made by big corporations are generally "less risky" on things like this, but I think you see the fruits of that kind of process in the design decisions as well. Trade offs!
26+
27+Anyway, like I said at the beginning, if you like what you see now, that's what it's going to be for a while. Even in the best case scenario with my current explorations!
28+
29+I hope this is helpful information, and I hope you have a good experience with Elm, even if you ultimately find a different language that works better for you!
terminal/src/Terminal/Args.hs → terminal/impl/Terminal.hsrenamed+30−27
@@ -1,8 +1,7 @@
1−module Terminal.Args
1+module Terminal
2− ( simple
2+ ( app
3− , Interface(..)
3+ , Command(..)
4 , Summary(..)
4 , Summary(..)
5− , complex
6 , Flags, noFlags, flags, (|--)
5 , Flags, noFlags, flags, (|--)
7 , Flag, flag, onOff
6 , Flag, flag, onOff
8 , Parser(..)
7 , Parser(..)
@@ -26,22 +25,22 @@ import qualified Text.PrettyPrint.ANSI.Leijen as P
26import qualified Text.Read as Read
25import qualified Text.Read as Read
27
26
28import qualified Elm.Version as V
27import qualified Elm.Version as V
29−import Terminal.Args.Internal
28+import Terminal.Internal
30−import qualified Terminal.Args.Chomp as Chomp
29+import qualified Terminal.Chomp as Chomp
31−import qualified Terminal.Args.Error as Error
30+import qualified Terminal.Error as Error
32
31
33
32
34
33
35−-- GET
34+-- COMMAND
36
35
37
36
38−simple :: String -> P.Doc -> Args args -> Flags flags -> (args -> flags -> IO ()) -> IO ()
37+_command :: String -> P.Doc -> Args args -> Flags flags -> (args -> flags -> IO ()) -> IO ()
39−simple details example args_ flags_ callback =
38+_command details example args_ flags_ callback =
40 do setLocaleEncoding utf8
39 do setLocaleEncoding utf8
41 argStrings <- Env.getArgs
40 argStrings <- Env.getArgs
42 case argStrings of
41 case argStrings of
43 ["--version"] ->
42 ["--version"] ->
44− do hPutStrLn stdout (V.toChars V.compiler ++ "-rc-1")
43+ do hPutStrLn stdout (V.toChars V.compiler)
45 Exit.exitSuccess
44 Exit.exitSuccess
46
45
47 chunks ->
46 chunks ->
@@ -57,34 +56,38 @@ simple details example args_ flags_ callback =
57 Error.exitWithError err
56 Error.exitWithError err
58
57
59
58
59+
60+-- APP
61+
62+
60−complex :: P.Doc -> P.Doc -> [Interface] -> IO ()
63+app :: P.Doc -> P.Doc -> [Command] -> IO ()
61−complex intro outro interfaces =
64+app intro outro commands =
62 do setLocaleEncoding utf8
65 do setLocaleEncoding utf8
63 argStrings <- Env.getArgs
66 argStrings <- Env.getArgs
64 case argStrings of
67 case argStrings of
65 [] ->
68 [] ->
66− Error.exitWithOverview intro outro interfaces
69+ Error.exitWithOverview intro outro commands
67
70
68 ["--help"] ->
71 ["--help"] ->
69− Error.exitWithOverview intro outro interfaces
72+ Error.exitWithOverview intro outro commands
70
73
71 ["--version"] ->
74 ["--version"] ->
72− do hPutStrLn stdout (V.toChars V.compiler ++ "-rc-1")
75+ do hPutStrLn stdout (V.toChars V.compiler)
73 Exit.exitSuccess
76 Exit.exitSuccess
74
77
75 command : chunks ->
78 command : chunks ->
76− do case List.find (\iface -> toName iface == command) interfaces of
79+ do case List.find (\cmd -> toName cmd == command) commands of
77 Nothing ->
80 Nothing ->
78− Error.exitWithUnknown command (map toName interfaces)
81+ Error.exitWithUnknown command (map toName commands)
79
82
80− Just (Interface _ _ details example args_ flags_ callback) ->
83+ Just (Command _ _ details example args_ flags_ callback) ->
81 if elem "--help" chunks then
84 if elem "--help" chunks then
82 Error.exitWithHelp (Just command) details example args_ flags_
85 Error.exitWithHelp (Just command) details example args_ flags_
83
86
84 else
87 else
85 case snd $ Chomp.chomp Nothing chunks args_ flags_ of
88 case snd $ Chomp.chomp Nothing chunks args_ flags_ of
86− Right (argsValue, flagValue) ->
89+ Right (argsValue, flagsValue) ->
87− callback argsValue flagValue
90+ callback argsValue flagsValue
88
91
89 Left err ->
92 Left err ->
90 Error.exitWithError err
93 Error.exitWithError err
@@ -159,21 +162,21 @@ findIndex index point chunks =
159 findIndex (index + 1) point cs
162 findIndex (index + 1) point cs
160
163
161
164
162−_complexSuggest :: [Interface] -> Int -> [String] -> IO [String]
165+_complexSuggest :: [Command] -> Int -> [String] -> IO [String]
163−_complexSuggest interfaces index strings =
166+_complexSuggest commands index strings =
164 case strings of
167 case strings of
165 [] ->
168 [] ->
166− return (map toName interfaces)
169+ return (map toName commands)
167
170
168 command : chunks ->
171 command : chunks ->
169 if index == 1 then
172 if index == 1 then
170− return (filter (List.isPrefixOf command) (map toName interfaces))
173+ return (filter (List.isPrefixOf command) (map toName commands))
171 else
174 else
172− case List.find (\iface -> toName iface == command) interfaces of
175+ case List.find (\cmd -> toName cmd == command) commands of
173 Nothing ->
176 Nothing ->
174 return []
177 return []
175
178
176− Just (Interface _ _ _ _ args_ flags_ _) ->
179+ Just (Command _ _ _ _ args_ flags_ _) ->
177 fst $ Chomp.chomp (Just (index-1)) chunks args_ flags_
180 fst $ Chomp.chomp (Just (index-1)) chunks args_ flags_
178
181
179
182
terminal/src/Terminal/Args/Chomp.hs → terminal/impl/Terminal/Chomp.hsrenamed+4−5
@@ -1,6 +1,5 @@
1−{-# LANGUAGE GADTs #-}
1+{-# LANGUAGE GADTs, Rank2Types #-}
2−{-# LANGUAGE Rank2Types #-}
3−module Terminal.Args.Chomp
2+module Terminal.Chomp
4 ( chomp
3 ( chomp
5 )
4 )
6 where
5 where
@@ -8,8 +7,8 @@ module Terminal.Args.Chomp
8
7
9import qualified Data.List as List
8import qualified Data.List as List
10
9
11−import Terminal.Args.Error
10+import Terminal.Error
12−import Terminal.Args.Internal
11+import Terminal.Internal
13
12
14
13
15
14
terminal/src/Terminal/Args/Error.hs → terminal/impl/Terminal/Error.hsrenamed+12−13
@@ -1,6 +1,5 @@
1−{-# LANGUAGE GADTs #-}
2−{-# LANGUAGE OverloadedStrings #-}
1+{-# LANGUAGE GADTs, OverloadedStrings #-}
3−module Terminal.Args.Error
2+module Terminal.Error
4 ( Error(..)
3 ( Error(..)
5 , ArgError(..)
4 , ArgError(..)
6 , FlagError(..)
5 , FlagError(..)
@@ -24,7 +23,7 @@ import System.IO (hPutStrLn, stderr)
24import qualified Text.PrettyPrint.ANSI.Leijen as P
23import qualified Text.PrettyPrint.ANSI.Leijen as P
25
24
26import Reporting.Suggest as Suggest
25import Reporting.Suggest as Suggest
27−import Terminal.Args.Internal
26+import Terminal.Internal
28
27
29
28
30
29
@@ -187,22 +186,22 @@ flagsToDocs flags docs =
187-- OVERVIEW
186-- OVERVIEW
188
187
189
188
190−exitWithOverview :: P.Doc -> P.Doc -> [Interface] -> IO a
189+exitWithOverview :: P.Doc -> P.Doc -> [Command] -> IO a
191−exitWithOverview intro outro interfaces =
190+exitWithOverview intro outro commands =
192 do exeName <- getExeName
191 do exeName <- getExeName
193 exitSuccess
192 exitSuccess
194 [ intro
193 [ intro
195 , "The most common commands are:"
194 , "The most common commands are:"
196− , P.indent 4 $ stack $ Maybe.mapMaybe (toSummary exeName) interfaces
195+ , P.indent 4 $ stack $ Maybe.mapMaybe (toSummary exeName) commands
197 , "There are a bunch of other commands as well though. Here is a full list:"
196 , "There are a bunch of other commands as well though. Here is a full list:"
198− , P.indent 4 $ P.dullcyan $ toCommandList exeName interfaces
197+ , P.indent 4 $ P.dullcyan $ toCommandList exeName commands
199 , "Adding the --help flag gives a bunch of additional details about each one."
198 , "Adding the --help flag gives a bunch of additional details about each one."
200 , outro
199 , outro
201 ]
200 ]
202
201
203
202
204−toSummary :: String -> Interface -> Maybe P.Doc
203+toSummary :: String -> Command -> Maybe P.Doc
205−toSummary exeName (Interface name summary _ _ (Args args) _ _) =
204+toSummary exeName (Command name summary _ _ (Args args) _ _) =
206 case summary of
205 case summary of
207 Uncommon ->
206 Uncommon ->
208 Nothing
207 Nothing
@@ -215,10 +214,10 @@ toSummary exeName (Interface name summary _ _ (Args args) _ _) =
215 ]
214 ]
216
215
217
216
218−toCommandList :: String -> [Interface] -> P.Doc
217+toCommandList :: String -> [Command] -> P.Doc
219−toCommandList exeName interfaces =
218+toCommandList exeName commands =
220 let
219 let
221− names = map toName interfaces
220+ names = map toName commands
222 width = maximum (map length names)
221 width = maximum (map length names)
223
222
224 toExample name =
223 toExample name =
terminal/src/Terminal/Args/Helpers.hs → terminal/impl/Terminal/Helpers.hsrenamed+2−2
@@ -1,5 +1,5 @@
1{-# LANGUAGE OverloadedStrings #-}
1{-# LANGUAGE OverloadedStrings #-}
2−module Terminal.Args.Helpers
2+module Terminal.Helpers
3 ( version
3 ( version
4 , elmFile
4 , elmFile
5 , package
5 , package
@@ -14,7 +14,7 @@ import qualified Data.Map as Map
14import qualified Data.Utf8 as Utf8
14import qualified Data.Utf8 as Utf8
15import qualified System.FilePath as FP
15import qualified System.FilePath as FP
16
16
17−import Terminal.Args (Parser(..))
17+import Terminal (Parser(..))
18import qualified Deps.Registry as Registry
18import qualified Deps.Registry as Registry
19import qualified Elm.Package as Pkg
19import qualified Elm.Package as Pkg
20import qualified Elm.Version as V
20import qualified Elm.Version as V
terminal/src/Terminal/Args/Internal.hs → terminal/impl/Terminal/Internal.hsrenamed+8−8
@@ -1,6 +1,6 @@
1{-# LANGUAGE GADTs #-}
1{-# LANGUAGE GADTs #-}
2−module Terminal.Args.Internal
2+module Terminal.Internal
3− ( Interface(..)
3+ ( Command(..)
4 , toName
4 , toName
5 , Summary(..)
5 , Summary(..)
6 , Flags(..)
6 , Flags(..)
@@ -17,11 +17,11 @@ import Text.PrettyPrint.ANSI.Leijen (Doc)
17
17
18
18
19
19
20−-- INTERFACE
20+-- COMMAND
21
21
22
22
23−data Interface where
23+data Command where
24− Interface
24+ Command
25 :: String
25 :: String
26 -> Summary
26 -> Summary
27 -> String
27 -> String
@@ -29,11 +29,11 @@ data Interface where
29 -> Args args
29 -> Args args
30 -> Flags flags
30 -> Flags flags
31 -> (args -> flags -> IO ())
31 -> (args -> flags -> IO ())
32− -> Interface
32+ -> Command
33
33
34
34
35−toName :: Interface -> String
35+toName :: Command -> String
36−toName (Interface name _ _ _ _ _ _) =
36+toName (Command name _ _ _ _ _ _) =
37 name
37 name
38
38
39
39
terminal/src/Develop.hs+2−2
@@ -159,9 +159,9 @@ compile path =
159 Just root ->
159 Just root ->
160 BW.withScope $ \scope -> Stuff.withRootLock root $ Task.run $
160 BW.withScope $ \scope -> Stuff.withRootLock root $ Task.run $
161 do details <- Task.eio Exit.ReactorBadDetails $ Details.load Reporting.silent scope root
161 do details <- Task.eio Exit.ReactorBadDetails $ Details.load Reporting.silent scope root
162− artifacts <- Task.eio Exit.ReactorBadBuild $ Build.fromMains Reporting.silent root details (NE.List path [])
162+ artifacts <- Task.eio Exit.ReactorBadBuild $ Build.fromPaths Reporting.silent root details (NE.List path [])
163 javascript <- Task.mapError Exit.ReactorBadGenerate $ Generate.dev root details artifacts
163 javascript <- Task.mapError Exit.ReactorBadGenerate $ Generate.dev root details artifacts
164− let (NE.List name _) = Build.getMainNames artifacts
164+ let (NE.List name _) = Build.getRootNames artifacts
165 return $ Html.sandwich name javascript
165 return $ Html.sandwich name javascript
166
166
167
167
terminal/src/Develop/StaticFiles/Build.hs+3−3
@@ -42,13 +42,13 @@ buildReactorFrontEnd =
42 do root <- Dir.getCurrentDirectory
42 do root <- Dir.getCurrentDirectory
43 runTaskUnsafe $
43 runTaskUnsafe $
44 do details <- Task.eio Exit.ReactorBadDetails $ Details.load Reporting.silent scope root
44 do details <- Task.eio Exit.ReactorBadDetails $ Details.load Reporting.silent scope root
45− artifacts <- Task.eio Exit.ReactorBadBuild $ Build.fromMains Reporting.silent root details mains
45+ artifacts <- Task.eio Exit.ReactorBadBuild $ Build.fromPaths Reporting.silent root details paths
46 javascript <- Task.mapError Exit.ReactorBadGenerate $ Generate.prod root details artifacts
46 javascript <- Task.mapError Exit.ReactorBadGenerate $ Generate.prod root details artifacts
47 return (LBS.toStrict (B.toLazyByteString javascript))
47 return (LBS.toStrict (B.toLazyByteString javascript))
48
48
49
49
50−mains :: NE.List FilePath
50+paths :: NE.List FilePath
51−mains =
51+paths =
52 NE.List
52 NE.List
53 ("src" </> "NotFound.elm")
53 ("src" </> "NotFound.elm")
54 [ "src" </> "Errors.elm"
54 [ "src" </> "Errors.elm"
terminal/src/Main.hs+19−19
@@ -12,8 +12,8 @@ import Text.PrettyPrint.ANSI.Leijen ((<>))
12import Text.Read (readMaybe)
12import Text.Read (readMaybe)
13
13
14import qualified Elm.Version as V
14import qualified Elm.Version as V
15−import Terminal.Args
15+import Terminal
16−import Terminal.Args.Helpers
16+import Terminal.Helpers
17
17
18import qualified Bump
18import qualified Bump
19import qualified Develop
19import qualified Develop
@@ -31,7 +31,7 @@ import qualified Repl
31
31
32main :: IO ()
32main :: IO ()
33main =
33main =
34− complex intro outro
34+ Terminal.app intro outro
35 [ repl
35 [ repl
36 , init
36 , init
37 , reactor
37 , reactor
@@ -72,7 +72,7 @@ outro =
72-- INIT
72-- INIT
73
73
74
74
75−init :: Interface
75+init :: Terminal.Command
76init =
76init =
77 let
77 let
78 summary =
78 summary =
@@ -87,14 +87,14 @@ init =
87 "It will ask permission to create an elm.json file, the one thing common\
87 "It will ask permission to create an elm.json file, the one thing common\
88 \ to all Elm projects. It also provides a link explaining what to do from there."
88 \ to all Elm projects. It also provides a link explaining what to do from there."
89 in
89 in
90− Interface "init" (Common summary) details example noArgs noFlags Init.run
90+ Terminal.Command "init" (Common summary) details example noArgs noFlags Init.run
91
91
92
92
93
93
94-- REPL
94-- REPL
95
95
96
96
97−repl :: Interface
97+repl :: Terminal.Command
98repl =
98repl =
99 let
99 let
100 summary =
100 summary =
@@ -115,7 +115,7 @@ repl =
115 |-- flag "interpreter" interpreter "Path to a alternate JS interpreter, like node or nodejs."
115 |-- flag "interpreter" interpreter "Path to a alternate JS interpreter, like node or nodejs."
116 |-- onOff "no-colors" "Turn off the colors in the REPL. This can help if you are having trouble reading the values. Some terminals use a custom color scheme that diverges significantly from the standard ANSI colors, so another path may be to pick a more standard color scheme."
116 |-- onOff "no-colors" "Turn off the colors in the REPL. This can help if you are having trouble reading the values. Some terminals use a custom color scheme that diverges significantly from the standard ANSI colors, so another path may be to pick a more standard color scheme."
117 in
117 in
118− Interface "repl" (Common summary) details example noArgs replFlags Repl.run
118+ Terminal.Command "repl" (Common summary) details example noArgs replFlags Repl.run
119
119
120
120
121interpreter :: Parser String
121interpreter :: Parser String
@@ -133,7 +133,7 @@ interpreter =
133-- REACTOR
133-- REACTOR
134
134
135
135
136−reactor :: Interface
136+reactor :: Terminal.Command
137reactor =
137reactor =
138 let
138 let
139 summary =
139 summary =
@@ -154,7 +154,7 @@ reactor =
154 flags Develop.Flags
154 flags Develop.Flags
155 |-- flag "port" port_ "The port of the server (default: 8000)"
155 |-- flag "port" port_ "The port of the server (default: 8000)"
156 in
156 in
157− Interface "reactor" (Common summary) details example noArgs reactorFlags Develop.run
157+ Terminal.Command "reactor" (Common summary) details example noArgs reactorFlags Develop.run
158
158
159
159
160port_ :: Parser Int
160port_ :: Parser Int
@@ -172,7 +172,7 @@ port_ =
172-- MAKE
172-- MAKE
173
173
174
174
175−make :: Interface
175+make :: Terminal.Command
176make =
176make =
177 let
177 let
178 details =
178 details =
@@ -196,14 +196,14 @@ make =
196 |-- flag "report" Make.reportType "You can say --report=json to get error messages as JSON. This is only really useful if you are an editor plugin. Humans should avoid it!"
196 |-- flag "report" Make.reportType "You can say --report=json to get error messages as JSON. This is only really useful if you are an editor plugin. Humans should avoid it!"
197 |-- flag "docs" Make.docsFile "Generate a JSON file of documentation for a package. Eventually it will be possible to preview docs with `reactor` because it is quite hard to deal with these JSON files directly."
197 |-- flag "docs" Make.docsFile "Generate a JSON file of documentation for a package. Eventually it will be possible to preview docs with `reactor` because it is quite hard to deal with these JSON files directly."
198 in
198 in
199− Interface "make" Uncommon details example (zeroOrMore elmFile) makeFlags Make.run
199+ Terminal.Command "make" Uncommon details example (zeroOrMore elmFile) makeFlags Make.run
200
200
201
201
202
202
203-- INSTALL
203-- INSTALL
204
204
205
205
206−install :: Interface
206+install :: Terminal.Command
207install =
207install =
208 let
208 let
209 details =
209 details =
@@ -232,14 +232,14 @@ install =
232 , require1 Install.Install package
232 , require1 Install.Install package
233 ]
233 ]
234 in
234 in
235− Interface "install" Uncommon details example installArgs noFlags Install.run
235+ Terminal.Command "install" Uncommon details example installArgs noFlags Install.run
236
236
237
237
238
238
239-- PUBLISH
239-- PUBLISH
240
240
241
241
242−publish :: Interface
242+publish :: Terminal.Command
243publish =
243publish =
244 let
244 let
245 details =
245 details =
@@ -269,14 +269,14 @@ publish =
269 "Check out <https://package.elm-lang.org/help/design-guidelines> for guidance on how to create great packages!"
269 "Check out <https://package.elm-lang.org/help/design-guidelines> for guidance on how to create great packages!"
270 ]
270 ]
271 in
271 in
272− Interface "publish" Uncommon details example noArgs noFlags Publish.run
272+ Terminal.Command "publish" Uncommon details example noArgs noFlags Publish.run
273
273
274
274
275
275
276-- BUMP
276-- BUMP
277
277
278
278
279−bump :: Interface
279+bump :: Terminal.Command
280bump =
280bump =
281 let
281 let
282 details =
282 details =
@@ -289,14 +289,14 @@ bump =
289 \ it is a MAJOR change, and bump your version number to 2.0.0. I do this with\
289 \ it is a MAJOR change, and bump your version number to 2.0.0. I do this with\
290 \ all packages, so there cannot be MAJOR changes hiding in PATCH releases in Elm!"
290 \ all packages, so there cannot be MAJOR changes hiding in PATCH releases in Elm!"
291 in
291 in
292− Interface "bump" Uncommon details example noArgs noFlags Bump.run
292+ Terminal.Command "bump" Uncommon details example noArgs noFlags Bump.run
293
293
294
294
295
295
296-- DIFF
296-- DIFF
297
297
298
298
299−diff :: Interface
299+diff :: Terminal.Command
300diff =
300diff =
301 let
301 let
302 details =
302 details =
@@ -321,7 +321,7 @@ diff =
321 , require3 Diff.GlobalInquiry package version version
321 , require3 Diff.GlobalInquiry package version version
322 ]
322 ]
323 in
323 in
324− Interface "diff" Uncommon details example diffArgs noFlags Diff.run
324+ Terminal.Command "diff" Uncommon details example diffArgs noFlags Diff.run
325
325
326
326
327
327
terminal/src/Make.hs+16−16
@@ -29,7 +29,7 @@ import qualified Reporting
29import qualified Reporting.Exit as Exit
29import qualified Reporting.Exit as Exit
30import qualified Reporting.Task as Task
30import qualified Reporting.Task as Task
31import qualified Stuff
31import qualified Stuff
32−import Terminal.Args (Parser(..))
32+import Terminal (Parser(..))
33
33
34
34
35
35
@@ -107,7 +107,7 @@ runHelp root paths style (Flags debug optimize maybeOutput _ maybeDocs) =
107 case getNoMains artifacts of
107 case getNoMains artifacts of
108 [] ->
108 [] ->
109 do builder <- toBuilder root details desiredMode artifacts
109 do builder <- toBuilder root details desiredMode artifacts
110− generate style target builder (Build.getMainNames artifacts)
110+ generate style target builder (Build.getRootNames artifacts)
111
111
112 name:names ->
112 name:names ->
113 Task.throw (Exit.MakeNonMainFilesIntoJavaScript name names)
113 Task.throw (Exit.MakeNonMainFilesIntoJavaScript name names)
@@ -166,7 +166,7 @@ buildExposed style root details maybeDocs exposed =
166buildPaths :: Reporting.Style -> FilePath -> Details.Details -> NE.List FilePath -> Task Build.Artifacts
166buildPaths :: Reporting.Style -> FilePath -> Details.Details -> NE.List FilePath -> Task Build.Artifacts
167buildPaths style root details paths =
167buildPaths style root details paths =
168 Task.eio Exit.MakeCannotBuild $
168 Task.eio Exit.MakeCannotBuild $
169− Build.fromMains style root details paths
169+ Build.fromPaths style root details paths
170
170
171
171
172
172
@@ -174,13 +174,13 @@ buildPaths style root details paths =
174
174
175
175
176getMains :: Build.Artifacts -> [ModuleName.Raw]
176getMains :: Build.Artifacts -> [ModuleName.Raw]
177−getMains (Build.Artifacts _ _ mains modules) =
177+getMains (Build.Artifacts _ _ roots modules) =
178− Maybe.mapMaybe (getMain modules) (NE.toList mains)
178+ Maybe.mapMaybe (getMain modules) (NE.toList roots)
179
179
180
180
181−getMain :: [Build.Module] -> Build.Main -> Maybe ModuleName.Raw
181+getMain :: [Build.Module] -> Build.Root -> Maybe ModuleName.Raw
182−getMain modules main =
182+getMain modules root =
183− case main of
183+ case root of
184 Build.Inside name ->
184 Build.Inside name ->
185 if any (isMain name) modules
185 if any (isMain name) modules
186 then Just name
186 then Just name
@@ -207,9 +207,9 @@ isMain targetName modul =
207
207
208
208
209hasOneMain :: Build.Artifacts -> Task ModuleName.Raw
209hasOneMain :: Build.Artifacts -> Task ModuleName.Raw
210−hasOneMain (Build.Artifacts _ _ mains modules) =
210+hasOneMain (Build.Artifacts _ _ roots modules) =
211− case mains of
211+ case roots of
212− NE.List main [] -> Task.mio Exit.MakeNoMain (return $ getMain modules main)
212+ NE.List root [] -> Task.mio Exit.MakeNoMain (return $ getMain modules root)
213 NE.List _ (_:_) -> Task.throw Exit.MakeMultipleFilesIntoHtml
213 NE.List _ (_:_) -> Task.throw Exit.MakeMultipleFilesIntoHtml
214
214
215
215
@@ -218,13 +218,13 @@ hasOneMain (Build.Artifacts _ _ mains modules) =
218
218
219
219
220getNoMains :: Build.Artifacts -> [ModuleName.Raw]
220getNoMains :: Build.Artifacts -> [ModuleName.Raw]
221−getNoMains (Build.Artifacts _ _ mains modules) =
221+getNoMains (Build.Artifacts _ _ roots modules) =
222− Maybe.mapMaybe (getNoMain modules) (NE.toList mains)
222+ Maybe.mapMaybe (getNoMain modules) (NE.toList roots)
223
223
224
224
225−getNoMain :: [Build.Module] -> Build.Main -> Maybe ModuleName.Raw
225+getNoMain :: [Build.Module] -> Build.Root -> Maybe ModuleName.Raw
226−getNoMain modules main =
226+getNoMain modules root =
227− case main of
227+ case root of
228 Build.Inside name ->
228 Build.Inside name ->
229 if any (isMain name) modules
229 if any (isMain name) modules
230 then Nothing
230 then Nothing
worker/elm.cabal+4
@@ -52,6 +52,7 @@ Executable worker
52 Artifacts
52 Artifacts
53 Cors
53 Cors
54 Endpoint.Compile
54 Endpoint.Compile
55+ Endpoint.Quotes
55 Endpoint.Repl
56 Endpoint.Repl
56
57
57 AST.Canonical
58 AST.Canonical
@@ -169,9 +170,11 @@ Executable worker
169 Type.UnionFind
170 Type.UnionFind
170
171
171 Build-depends:
172 Build-depends:
173+ aeson,
172 ansi-terminal >= 0.8 && < 0.9,
174 ansi-terminal >= 0.8 && < 0.9,
173 ansi-wl-pprint >= 0.6.8 && < 0.7,
175 ansi-wl-pprint >= 0.6.8 && < 0.7,
174 base >=4.11 && <5,
176 base >=4.11 && <5,
177+ base64-bytestring,
175 binary >= 0.8 && < 0.9,
178 binary >= 0.8 && < 0.9,
176 bytestring >= 0.9 && < 0.11,
179 bytestring >= 0.9 && < 0.11,
177 containers >= 0.5.8.2 && < 0.6,
180 containers >= 0.5.8.2 && < 0.6,
@@ -192,6 +195,7 @@ Executable worker
192 network-uri,
195 network-uri,
193 parsec,
196 parsec,
194 process,
197 process,
198+ random,
195 raw-strings-qq,
199 raw-strings-qq,
196 scientific,
200 scientific,
197 SHA,
201 SHA,
worker/elm.jsonnew file+26
@@ -0,0 +1,26 @@
1+{
2+ "type": "application",
3+ "source-directories": [
4+ "src"
5+ ],
6+ "elm-version": "0.19.1",
7+ "dependencies": {
8+ "direct": {
9+ "elm/browser": "1.0.1",
10+ "elm/core": "1.0.2",
11+ "elm/html": "1.0.0",
12+ "elm/json": "1.1.3",
13+ "elm/project-metadata-utils": "1.0.0"
14+ },
15+ "indirect": {
16+ "elm/parser": "1.1.0",
17+ "elm/time": "1.0.0",
18+ "elm/url": "1.0.0",
19+ "elm/virtual-dom": "1.0.2"
20+ }
21+ },
22+ "test-dependencies": {
23+ "direct": {},
24+ "indirect": {}
25+ }
26+}
worker/outlines/compile/elm.json+1−1
@@ -1,7 +1,7 @@
1{
1{
2 "type": "application",
2 "type": "application",
3 "source-directories": [
3 "source-directories": [
4− "src"
4+ "../../src"
5 ],
5 ],
6 "elm-version": "0.19.1",
6 "elm-version": "0.19.1",
7 "dependencies": {
7 "dependencies": {
worker/outlines/repl/elm.json+4−2
@@ -1,14 +1,16 @@
1{
1{
2 "type": "application",
2 "type": "application",
3 "source-directories": [
3 "source-directories": [
4− "src"
4+ "../../src"
5 ],
5 ],
6 "elm-version": "0.19.1",
6 "elm-version": "0.19.1",
7 "dependencies": {
7 "dependencies": {
8 "direct": {
8 "direct": {
9 "elm/core": "1.0.2"
9 "elm/core": "1.0.2"
10 },
10 },
11− "indirect": {}
11+ "indirect": {
12+ "elm/json": "1.1.3"
13+ }
12 },
14 },
13 "test-dependencies": {
15 "test-dependencies": {
14 "direct": {},
16 "direct": {},
worker/src/Artifacts.hs+67−3
@@ -3,22 +3,32 @@ module Artifacts
3 ( Artifacts(..)
3 ( Artifacts(..)
4 , loadCompile
4 , loadCompile
5 , loadRepl
5 , loadRepl
6+ , toDepsInfo
6 )
7 )
7 where
8 where
8
9
9
10
10import Control.Concurrent (readMVar)
11import Control.Concurrent (readMVar)
11import Control.Monad (liftM2)
12import Control.Monad (liftM2)
13+import qualified Data.ByteString as BS
14+import qualified Data.ByteString.Builder as B
15+import qualified Data.ByteString.Lazy as LBS
12import qualified Data.Map as Map
16import qualified Data.Map as Map
17+import qualified Data.Name as N
13import qualified Data.OneOrMore as OneOrMore
18import qualified Data.OneOrMore as OneOrMore
14import qualified System.Directory as Dir
19import qualified System.Directory as Dir
15import System.FilePath ((</>))
20import System.FilePath ((</>))
16
21
22+import qualified AST.Canonical as Can
17import qualified AST.Optimized as Opt
23import qualified AST.Optimized as Opt
18import qualified BackgroundWriter as BW
24import qualified BackgroundWriter as BW
19import qualified Elm.Details as Details
25import qualified Elm.Details as Details
20import qualified Elm.Interface as I
26import qualified Elm.Interface as I
21import qualified Elm.ModuleName as ModuleName
27import qualified Elm.ModuleName as ModuleName
28+import qualified Elm.Package as Pkg
29+import Json.Encode ((==>))
30+import qualified Json.Encode as E
31+import qualified Json.String as Json
22import qualified Reporting
32import qualified Reporting
23
33
24
34
@@ -50,12 +60,13 @@ loadRepl =
50load :: FilePath -> IO Artifacts
60load :: FilePath -> IO Artifacts
51load dir =
61load dir =
52 BW.withScope $ \scope ->
62 BW.withScope $ \scope ->
63+ do putStrLn $ "Loading " ++ dir </> "elm.json"
53− do style <- Reporting.terminal
64+ style <- Reporting.terminal
54 root <- fmap (</> dir) Dir.getCurrentDirectory
65 root <- fmap (</> dir) Dir.getCurrentDirectory
55 result <- Details.load style scope root
66 result <- Details.load style scope root
56 case result of
67 case result of
57 Left _ ->
68 Left _ ->
58− error "Ran into some problem loading elm.json details"
69+ error $ "Ran into some problem loading elm.json\nTry running `elm make` in: " ++ dir
59
70
60 Right details ->
71 Right details ->
61 do omvar <- Details.loadObjects root details
72 do omvar <- Details.loadObjects root details
@@ -64,7 +75,7 @@ load dir =
64 mobjs <- readMVar omvar
75 mobjs <- readMVar omvar
65 case liftM2 (,) mdeps mobjs of
76 case liftM2 (,) mdeps mobjs of
66 Nothing ->
77 Nothing ->
67− error "Ran into some weird problem loading elm.json details"
78+ error $ "Ran into some weird problem loading elm.json\nTry running `elm make` in: " ++ dir
68
79
69 Just (deps, objs) ->
80 Just (deps, objs) ->
70 return $ Artifacts (toInterfaces deps) objs
81 return $ Artifacts (toInterfaces deps) objs
@@ -89,3 +100,56 @@ toUnique oneOrMore =
89 OneOrMore.One value -> Just value
100 OneOrMore.One value -> Just value
90 OneOrMore.More _ _ -> Nothing
101 OneOrMore.More _ _ -> Nothing
91
102
103+
104+
105+-- TO DEPS INFO
106+
107+
108+toDepsInfo :: Artifacts -> BS.ByteString
109+toDepsInfo (Artifacts ifaces _) =
110+ LBS.toStrict $ B.toLazyByteString $ E.encodeUgly $ encode ifaces
111+
112+
113+
114+-- ENCODE
115+
116+
117+encode :: Map.Map ModuleName.Raw I.Interface -> E.Value
118+encode ifaces =
119+ E.dict Json.fromName encodeInterface ifaces
120+
121+
122+encodeInterface :: I.Interface -> E.Value
123+encodeInterface (I.Interface pkg values unions aliases binops) =
124+ E.object
125+ [ "pkg" ==> E.chars (Pkg.toChars pkg)
126+ , "ops" ==> E.list E.name (Map.keys binops)
127+ , "values" ==> E.list E.name (Map.keys values)
128+ , "aliases" ==> E.list E.name (Map.keys (Map.filter isPublicAlias aliases))
129+ , "types" ==> E.dict Json.fromName (E.list E.name) (Map.mapMaybe toPublicUnion unions)
130+ ]
131+
132+
133+isPublicAlias :: I.Alias -> Bool
134+isPublicAlias alias =
135+ case alias of
136+ I.PublicAlias _ -> True
137+ I.PrivateAlias _ -> False
138+
139+
140+toPublicUnion :: I.Union -> Maybe [N.Name]
141+toPublicUnion union =
142+ case union of
143+ I.OpenUnion (Can.Union _ variants _ _) ->
144+ Just (map getVariantName variants)
145+
146+ I.ClosedUnion _ ->
147+ Just []
148+
149+ I.PrivateUnion _ ->
150+ Nothing
151+
152+
153+getVariantName :: Can.Ctor -> N.Name
154+getVariantName (Can.Ctor name _ _ _) =
155+ name
worker/src/Endpoint/Compile.hs+118−23
@@ -1,7 +1,8 @@
1{-# OPTIONS_GHC -Wall #-}
1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
2{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
3module Endpoint.Compile
3module Endpoint.Compile
4− ( endpoint
4+ ( endpoint_V1
5+ , endpoint_V2
5 , loadErrorJS
6 , loadErrorJS
6 )
7 )
7 where
8 where
@@ -63,26 +64,50 @@ allowedOrigins =
63
64
64
65
65
66
67+-- ENDPOINT (V1)
68+
69+
70+endpoint_V1 :: A.Artifacts -> Snap ()
71+endpoint_V1 artifacts =
72+ endpoint artifacts $ \result ->
73+ case result of
74+ Ok name js -> writeBuilder $ Html.sandwich name js
75+ Err report -> writeBuilder $ renderProblem_V1 report
76+
77+
78+
79+-- ENDPOINT (V2)
80+
81+
82+endpoint_V2 :: A.Artifacts -> Snap ()
83+endpoint_V2 artifacts =
84+ endpoint artifacts $ \result ->
85+ case result of
86+ Ok name js -> writeBuilder $ renderSuccess_V2 name js
87+ Err report -> writeBuilder $ renderProblem_V2 report
88+
89+
90+
66-- ENDPOINT
91-- ENDPOINT
67
92
68
93
94+data Result
95+ = Ok N.Name B.Builder
96+ | Err Help.Report
97+
98+
69−endpoint :: A.Artifacts -> Snap ()
99+endpoint :: A.Artifacts -> (Result -> Snap ()) -> Snap ()
70−endpoint artifacts =
100+endpoint artifacts callback =
71 Cors.allow POST allowedOrigins $
101 Cors.allow POST allowedOrigins $
72 do result <- foldMultipart defaultUploadPolicy ignoreFile 0
102 do result <- foldMultipart defaultUploadPolicy ignoreFile 0
73 case result of
103 case result of
74 ([("code",source)], 0) ->
104 ([("code",source)], 0) ->
75 do modifyResponse $ setContentType "text/html; charset=utf-8"
105 do modifyResponse $ setContentType "text/html; charset=utf-8"
106+ callback $
76− case compile artifacts source of
107+ case compile artifacts source of
77− Success builder ->
108+ Success name js -> Ok name js
78− writeBuilder builder
79−
80− NoMain ->
109+ NoMain -> Err noMain
81− writeBuilder $ renderReport noMain
82−
83− BadInput name err ->
84− writeBuilder $ renderReport $
85− Help.compilerReport "/" (Error.Module name "/try" File.zeroTime source err) []
110+ BadInput name err -> Err $ Help.compilerReport "/" (Error.Module name "/try" File.zeroTime source err) []
86
111
87 _ ->
112 _ ->
88 do modifyResponse $ setResponseStatus 400 "Bad Request"
113 do modifyResponse $ setResponseStatus 400 "Bad Request"
@@ -104,7 +129,7 @@ ignoreFile _ _ count =
104
129
105
130
106data Outcome
131data Outcome
107− = Success B.Builder
132+ = Success N.Name B.Builder
108 | NoMain
133 | NoMain
109 | BadInput ModuleName.Raw Error.Error
134 | BadInput ModuleName.Raw Error.Error
110
135
@@ -138,7 +163,7 @@ compile (A.Artifacts interfaces objects) source =
138 mains = Map.singleton home main_
163 mains = Map.singleton home main_
139 graph = Opt.addLocalGraph locals objects
164 graph = Opt.addLocalGraph locals objects
140 in
165 in
141− Success $ Html.sandwich name $ JS.generate mode graph mains
166+ Success name $ JS.generate mode graph mains
142
167
143
168
144checkImports :: Map.Map ModuleName.Raw I.Interface -> [Src.Import] -> Either (NE.List Import.Error) (Map.Map ModuleName.Raw I.Interface)
169checkImports :: Map.Map ModuleName.Raw I.Interface -> [Src.Import] -> Either (NE.List Import.Error) (Map.Map ModuleName.Raw I.Interface)
@@ -163,11 +188,11 @@ checkImports interfaces imports =
163
188
164
189
165
190
166−-- RENDER REPORT
191+-- RENDER PROBLEM (V1)
167
192
168
193
169−renderReport :: Help.Report -> B.Builder
194+renderProblem_V1 :: Help.Report -> B.Builder
170−renderReport report =
195+renderProblem_V1 report =
171 [r|<!DOCTYPE HTML>
196 [r|<!DOCTYPE HTML>
172<html>
197<html>
173<head>
198<head>
@@ -176,7 +201,77 @@ renderReport report =
176 <script src="https://worker.elm-lang.org/compile/errors.js"></script>
201 <script src="https://worker.elm-lang.org/compile/errors.js"></script>
177</head>
202</head>
178<body>
203<body>
204+ <script>
179− <script>Elm.Errors.init({flags:|] <> Encode.encodeUgly (Exit.toJson report) <> [r|});</script>
205+ var app = Elm.Errors.init({flags:|] <> Encode.encodeUgly (Exit.toJson report) <> [r|});
206+ app.ports.jumpTo.subscribe(function(region) {
207+ window.parent.postMessage(JSON.stringify(region), "*");
208+ });
209+ </script>
210+</body>
211+</html>|]
212+
213+
214+
215+-- RENDER SUCCESS (V2)
216+
217+
218+renderSuccess_V2 :: N.Name -> B.Builder -> B.Builder
219+renderSuccess_V2 moduleName javascript =
220+ let name = N.toBuilder moduleName in
221+ [r|<!DOCTYPE HTML>
222+<html>
223+<head>
224+ <meta charset="UTF-8">
225+ <title>|] <> name <> [r|</title>
226+ <style>body { padding: 0; margin: 0; }</style>
227+</head>
228+
229+<body>
230+
231+<pre id="elm"></pre>
232+
233+<script>
234+window.parent.postMessage("SUCCESS", "*");
235+
236+try {
237+|] <> javascript <> [r|
238+
239+ var app = Elm.|] <> name <> [r|.init({ node: document.getElementById("elm") });
240+}
241+catch (e)
242+{
243+ // display initialization errors (e.g. bad flags, infinite recursion)
244+ var header = document.createElement("h1");
245+ header.style.fontFamily = "monospace";
246+ header.innerText = "Initialization Error";
247+ var pre = document.getElementById("elm");
248+ document.body.insertBefore(header, pre);
249+ pre.innerText = e;
250+ throw e;
251+}
252+</script>
253+
254+</body>
255+</html>|]
256+
257+
258+
259+-- RENDER PROBLEM (V2)
260+
261+
262+renderProblem_V2 :: Help.Report -> B.Builder
263+renderProblem_V2 report =
264+ [r|<!DOCTYPE HTML>
265+<html>
266+<head>
267+ <meta charset="UTF-8">
268+ <style>body { padding: 0; margin: 0; display: none; }</style>
269+</head>
270+<body>
271+ <script>
272+ var errors = |] <> Encode.encodeUgly (Exit.toJson report) <> [r|;
273+ window.parent.postMessage(JSON.stringify(errors), "*");
274+ </script>
180</body>
275</body>
181</html>|]
276</html>|]
182
277
@@ -218,11 +313,11 @@ loadErrorJS =
218 do result <- work
313 do result <- work
219 case result of
314 case result of
220 Right a -> return a
315 Right a -> return a
221− Left _ -> error "problem building reactor/src/Errors.elm"
316+ Left _ -> error "problem building src/Errors.elm"
222 in
317 in
223− Dir.withCurrentDirectory "../reactor" $ BW.withScope $ \scope ->
318+ BW.withScope $ \scope ->
224− do let root = "."
319+ do root <- Dir.getCurrentDirectory
225 details <- run $ Details.load Reporting.silent scope root
320 details <- run $ Details.load Reporting.silent scope root
226− artifacts <- run $ Build.fromMains Reporting.silent root details (NE.List "src/Errors.elm" [])
321+ artifacts <- run $ Build.fromPaths Reporting.silent root details (NE.List "src/Errors.elm" [])
227 javascript <- run $ Task.run $ Generate.prod root details artifacts
322 javascript <- run $ Task.run $ Generate.prod root details artifacts
228 return $ LBS.toStrict $ B.toLazyByteString javascript
323 return $ LBS.toStrict $ B.toLazyByteString javascript
worker/src/Endpoint/Quotes.hsnew file+114
@@ -0,0 +1,114 @@
1+{-# LANGUAGE BangPatterns, MagicHash, OverloadedStrings, UnboxedTuples #-}
2+module Endpoint.Quotes
3+ ( endpoint
4+ )
5+ where
6+
7+
8+import Control.Monad.IO.Class (liftIO)
9+import qualified Data.ByteString as BS
10+import GHC.Int (Int(I#))
11+import GHC.Prim
12+import GHC.ST (ST(ST), runST)
13+import qualified System.Random as Random
14+
15+import Snap.Core
16+
17+
18+
19+-- ENDPOINT
20+
21+
22+endpoint :: Snap ()
23+endpoint =
24+ do modifyResponse
25+ $ setContentType "application/json"
26+ . setHeader "Access-Control-Allow-Origin" "*"
27+ writeBS =<< liftIO getQuote
28+
29+
30+getQuote :: IO BS.ByteString
31+getQuote =
32+ let
33+ (Quotes sa#) = quotes
34+ in
35+ do (I# i#) <- Random.randomRIO (0, I# (sizeofSmallArray# sa# -# 1#))
36+ case indexSmallArray# sa# i# of
37+ (# json #) ->
38+ return json
39+
40+
41+
42+-- QUOTES
43+
44+
45+data Quotes =
46+ Quotes (SmallArray# BS.ByteString)
47+
48+
49+quotes :: Quotes
50+quotes =
51+ let
52+ !(I# len#) = length quoteList
53+ in
54+ runST $ ST $ \s ->
55+ case newSmallArray# len# "" s of
56+ (# s, sma# #) ->
57+ case quotesHelp# sma# quoteList s of
58+ s ->
59+ case unsafeFreezeSmallArray# sma# s of
60+ (# s, sa# #) ->
61+ (# s, Quotes sa# #)
62+
63+
64+quotesHelp# :: SmallMutableArray# s a -> [a] -> State# s -> State# s
65+quotesHelp# sma# =
66+ go 0#
67+ where
68+ go i# list s =
69+ case list of
70+ [] ->
71+ s
72+
73+ x:xs ->
74+ case writeSmallArray# sma# i# x s of
75+ s ->
76+ go (i# +# 1#) xs s
77+
78+
79+quoteList :: [BS.ByteString]
80+quoteList =
81+ [ "{\"source\":\"Civilization and its Discontents\",\"author\":\"Sigmund Freud\",\"year\":1902,\"quote\":\"The enormous expansion of communications, due to the world-wide telegraph and telephone networks, has entirely transformed the conditions of trade and commerce. Everything is done in haste, at fever pitch. The night is used for travel, the day for business; even \\u201Choliday trips\\u201D put a strain on the nervous system. Great political, industrial and financial crises carry this excitement into far wider areas of the population than ever before. Interest in political life has become universal: tempers are inflamed by political, religious and social struggles, party politics, electioneering and the immense growth of trade-unionism; people are forced to engage in constant mental activity and robbed of the time the need for relaxation, sleep and rest.\"}"
82+ , "{\"source\":\"A Preface to Politics\",\"author\":\"Walter Lippmann\",\"year\":1913,\"quote\":\"The Economic Man\\u2014that lazy abstraction\\u2014is still paraded in the lecture room.\"}"
83+ , "{\"source\":\"Letters from a Stoic\",\"author\":\"Seneca\",\"year\":54,\"quote\":\"You ask me to say what you should consider it particularly important to avoid. My answer is this: a mass crowd. It is something to which you cannot entrust yourself yet without risk. I at any rate am ready to confess my own frailty in this respect. I never come back home with quite the same moral character as I went out with.\"}"
84+ , "{\"source\":\"Letters from a Stoic\",\"author\":\"Seneca\",\"year\":54,\"quote\":\"December used to be a month but it is now a year\"}"
85+ , "{\"source\":\"Letters from a Stoic\",\"author\":\"Seneca\",\"year\":54,\"quote\":\"But nothing is as ruinous to the character as sitting away one\\u2019s time at a show - for it is then, through the medium of entertainment, that vices creep into one with more than usual ease.\"}"
86+ , "{\"source\":\"Letters from a Stoic\",\"author\":\"Seneca\",\"year\":54,\"quote\":\"All this hurrying from place to place won\\u2019t bring you any relief, for you\\u2019re travelling in the company of your own emotions, followed by your troubles all the way. If only they were really following you! They\\u2019d be farther away from you: as it is they\\u2019re not at your back, but on it! That\\u2019s why they weigh you down with just the same uncomfortable chafing wherever you are. It\\u2019s medicine, not a particular part of the world, that a person needs if he\\u2019s ill. Suppose someone has broken his leg or dislocated a joint; he doesn\\u2019t get into a carriage or board a ship: he calls in a doctor to have the fracture set or the dislocation reduced. Well then, when a person\\u2019s spirit is wrenched or broken at so many points, do you imagine that it can be put right by a change of scenery, that that sort of trouble isn\\u2019t so serious that it can\\u2019t be cured by an outing?\"}"
87+ , "{\"source\":\"Progress and Poverty\",\"author\":\"Henry George\",\"year\":1879,\"quote\":\"The present century has been marked by a prodigious increase in wealth-producing power. The utilization of steam and electricity, the introduction of improved processes and laborsaving machinery, the greater subdivision and grander scale of production, the wonderful facilitation of exchanges, have multiplied enormously the effectiveness of labor. At the beginning of this marvelous era it was natural to expect, and it was expected, that laborsaving inventions would lighten the toil and improve the condition of the laborer; that the enormous increase in the power of producing wealth would make real poverty a thing of the past.\"}"
88+ , "{\"source\":\"Imperialism\",\"author\":\"John Hobson\",\"year\":1902,\"quote\":\"Although the new Imperialism has been bad business for the nation, it has been good business for certain classes and certain trades within the nation. The vast expenditure on armaments, the costly wars, the grave risks and embarrassments of foreign policy, the stoppage of political and social reforms within Great Britain, though fraught with great injury to the nation, have served well the present business interests of certain industries and professions.\"}"
89+ , "{\"source\":\"Neo-Colonialism\",\"author\":\"Kwame Nkrumah\",\"year\":1965,\"quote\":\"The essence of neo-colonialism is that the State which is subject to it is, in theory, independent and has all the outward trappings of international sovereignty. In reality its economic system and thus its political policy is directed from the outside. The methods and form of this direction can take various shapes. For example, in an extreme case the troops of the imperial power may garrison the territory of the neo-colonial State and control the government of it. More often, however, neo-colonialist control is exercised through economic or monetary means. The neo-colonial State may be obliged to take the manufactured products of the imperialist power to the exclusion of competing products from elsewhere. Control over government policy in the neo-colonial State may be secured by payments towards the cost of running the State, by the provision of civil servants in positions where they can dictate policy, and by monetary control over foreign exchange through the imposition of a banking system controlled by the imperial power.\"}"
90+ , "{\"source\":\"Neo-Colonialism\",\"author\":\"Kwame Nkrumah\",\"year\":1965,\"quote\":\"In the end the situation arises that the only type of aid which the neo-colonialist masters consider as safe is \\u2018military aid\\u2019. Once a neo-colonialist territory is brought to such a state of economic chaos and misery that revolt actually breaks out then, and only then, is there no limit to the generosity of the neo-colonial overlord, provided, of course, that the funds supplied are utilised exclusively for military purposes. Military aid in fact marks the last stage of neo-colonialism and its effect is self-destructive. Sooner or later the weapons supplied pass into the hands of the opponents of the neo-colonialist regime and the war itself increases the social misery which originally provoked it.\"}"
91+ , "{\"source\":\"Barnyard in your Backyard\",\"author\":\"Gail Damerow\",\"year\":2002,\"quote\":\"Wild jungle fowl, the ancestors of modern chickens, met their nutritional needs by consuming a variety of plants and insects. Given enough room to roam, some of today\\u2019s breeds remain active foragers.\"}"
92+ , "{\"source\":\"Barnyard in your Backyard\",\"author\":\"Gail Damerow\",\"year\":2002,\"quote\":\"Another way to reduce the cost of feed is to let your chickens roam on a lawn or in a pasture for part of the day. By eating plants, seeds, and insects, they will balance their diet and eat less of the expensive commercial stuff. Take care not to put your chickens on grass or around buildings that have been sprayed with toxins.\"}"
93+ , "{\"source\":\"Co-operation in Danish Agriculture\",\"author\":\"Harald Faber\",\"year\":1918,\"quote\":\"A plan for improving the butter made from the milk from peasant farms by collecting the milk to be worked at one place was submitted to the Royal Agricultural Society of Denmark as early as 1852, and it pointed out that this could be done on co-operative lines, the peasants being the owners of the factory and sharing the proceeds.\"}"
94+ , "{\"source\":\"Co-operation in Danish Agriculture\",\"author\":\"Harald Faber\",\"year\":1918,\"quote\":\"It was the Danish peasants themselves who found a practical way of developing the dairy industry, and they found this by applying the co-operative principles introduced by the Rochdale weavers. They received no support and only lukewarm sympathy from large farmers and estate owners, until later on when the co-operative dairies were doing so well that even owners of estates with two to three hundred cows found it to their advantage to close their private dairies and to join co-operative dairies.\"}"
95+ , "{\"source\":\"Beekeeping: A Practical Guide\",\"author\":\"Richard Bonney\",\"year\":1993,\"quote\":\"How many of you have been in a classroom or a training program where the instructor says at the outset, \\u201CLook at the person on your right; now look at the person on your left. One of you won\\u2019t be here next year.\\u201D Beekeeping is like that. Furthermore, not all beekeepers are truly beekeepers. Some are beehavers.\"}"
96+ , "{\"source\":\"The Rodale Book of Composting\",\"author\":\"Deborah Martin and Grace Gershuny\",\"year\":1992,\"quote\":\"Earthworms. If bacteria are the champion microscopic decomposers, then the heavyweight champion is doubtless the earthworm. Pages of praise have been written to the earthworm, ever since it became known that this creature spends most of its time tilling and enriching the soil.\"}"
97+ , "{\"source\":\"War is a Racket\",\"author\":\"General Smedley Butler\",\"year\":1935,\"quote\":\"There are 40,000,000 men under arms in the world today, and our statesmen and diplomats have the temerity to say that war is not in the making. Hell\\u2019s bells! Are these 40,000,000 men being trained to be dancers?\"}"
98+ , "{\"source\":\"Root Cellaring\",\"author\":\"Mike and Nancy Bubel\",\"year\":1991,\"quote\":\"What is not so widely acknowledged is that the soil in which your plants grow can influence the keeping quality of the vegetables you harvest. According to studies reported in E. P. Shirakov\\u2019s \\u201CPractical Course in Storage and Processing of Fruits and Vegetables\\u201D, abundant potash in the soil promotes long storage life of fruits and vegetables grown on that soil.\"}"
99+ , "{\"source\":\"Angora Goats the Northern Way\",\"author\":\"Susan Black Drummond\",\"year\":1985,\"quote\":\"Because of its long wearing qualities and resistance to soil, mohair was once a major upholstery fabric in this country, and was the seat cover material in many cars and in British Railroad seats. The synthetic fiber craze put an end to mohair use as upholstery fabric here.\"}"
100+ , "{\"source\":\"Making a Newspaper\",\"author\":\"John Given\",\"year\":1912,\"quote\":\"Yellow journalism originated through a desire to gain readers and advertisers, and it produced results. Its original disciples have readers by the hundred thousand and they have about all the advertising that they can well handle.\"}"
101+ , "{\"source\":\"Making a Newspaper\",\"author\":\"John Given\",\"year\":1912,\"quote\":\"With the adding of every new train and the improvement of every new time-table, the building of every new trolley road, and the establishment of every new mail route, the big city papers are enabled to reach out further, and, wherever they reach, the local papers suffer [...] There is not a paper published in any city between New York and Boston that has not in the last ten years been hurt by the papers of these two cities.\"}"
102+ , "{\"source\":\"Muscles: Testing and Function (4th Edition)\",\"author\":\"Florence Kendall, Elizabeth McCreary, Patricia Provance\",\"year\":1993,\"quote\":\"The mechanics of the low back is inseparable from that of the overall posture but especially that of the pelvis and the lower extremities. Pain manifested in the leg may be due to an underlying problem in the back. Conversely, the symptoms appearing in the low back may be due to underlying faulty mechanics of the feet, legs, or pelvis.\"}"
103+ , "{\"source\":\"Farmers of Forty Centuries\",\"author\":\"F. H. King\",\"year\":1911,\"quote\":\"The Sikiang is one of the great rivers of China and indeed of the world. Its width at Wuchow at low water was nearly a mile and our steamer anchored in twenty-four feet of water to a floating dock made fast by huge iron chains reaching three hundred feet up the slop to the city proper, thus providing for a rise of twenty-six feet in the river at its flood stage during the rainy season.\"}"
104+ , "{\"source\":\"How to Grow More Vegetables\",\"author\":\"John Jeavons\",\"year\":1974,\"quote\":\"If you are having trouble with birds eating the berries in your berry patch, you could erect a wren house in the middle of it. Wrens are insectivores, and they will not bother the berries. But they will attack any bird, however large, that comes near their nest.\"}"
105+ , "{\"source\":\"Confidence Men and Painted Women\",\"author\":\"Karen Halttunen\",\"year\":1982,\"quote\":\"Even one\\u2019s neighbor next door, as a visitor to Pittsburgh commented in 1818, might be a stranger: \\u201CA next door neighbor is, with them, frequently unknown, and months and years pass, without their exchanging with each other the ordinary compliments of friendship and goodwill.\\u201D\"}"
106+ , "{\"source\":\"Secondhand Time\",\"author\":\"Svetlana Alexievich\",\"year\":2016,\"quote\":\"I couldn\\u2019t understand what was going on. I remember seeing Gaidar on TV saying, \\u201Clearn how to sell... The market will save us...\\u201D You buy a bottle of mineral water on one corner and sell it on another\\u2014that\\u2019s business. The people listened, bewildered. I would come home, lock the door, and weep.\"}"
107+ , "{\"source\":\"Hiroshima\",\"author\":\"John Hersey\",\"year\":1985,\"quote\":\"At exactly fifteen minutes past eight in the morning, on August 6, 1945, Japanese time, at the moment when the atomic bomb flashed above Hiroshima, Miss Toshiko Sasaki, a clerk in the personnel department of the East Asia Tin Works, had just sat down at her place in the plant office and was turning her head to speak to the girl at the next desk.\"}"
108+ , "{\"source\":\"The Orphan\",\"author\":\"Maxim Gorky\",\"year\":1899,\"quote\":\"On a foggy and rainy day, by the cemetery gate, a small group of people standing in a muddy puddle were bargaining with the cabman. \\u201CFifteen kopeks!\\u201D The tall and heavy-set priest exclaimed in a deep bass, in response to the cabman\\u2019s shouts asking for twenty-five kopecks.\"}"
109+ , "{\"source\":\"Shah of Shahs\",\"author\":\"Ryszard Kapuściński\",\"year\":1982,\"quote\":\"This plane flies out of Teheran every day and lands at Munich at noon. Waiting limousines carry the passengers to elegant restaurants for lunch. After lunch they all fly back to Teheran in the same airplane and eat their suppers at home. Hardly an expensive entertainment, the jaunt costs only two thousand dollars a head. For people in the Shah\\u2019s favor, such a sum is nothing.\"}"
110+ , "{\"source\":\"Introduction to Fortran IV\",\"author\":\"Paul Chirlian\",\"year\":1973,\"quote\":\"There are many programming languages that can be used. We shall discuss a language that is almost universally used, and which is particularly applicable to mathematical and scientific computations. This language is FORTRAN IV.\"}"
111+ ]
112+
113+
114+
worker/src/Endpoint/Repl.hs+37−49
@@ -6,17 +6,17 @@ module Endpoint.Repl
6 where
6 where
7
7
8
8
9+import Data.Aeson ((.:))
10+import qualified Data.Aeson as Aeson
11+import qualified Data.Aeson.Types as Aeson
12+import qualified Data.ByteString as BS
9import qualified Data.ByteString.Builder as B
13import qualified Data.ByteString.Builder as B
10−import qualified Data.ByteString.Internal as BS
11import qualified Data.ByteString.Lazy as LBS
14import qualified Data.ByteString.Lazy as LBS
12−import qualified Data.ByteString.UTF8 as BS_UTF8
13import Data.Map ((!))
15import Data.Map ((!))
14import qualified Data.Map as Map
16import qualified Data.Map as Map
15import qualified Data.Map.Utils as Map
17import qualified Data.Map.Utils as Map
16import qualified Data.Name as N
18import qualified Data.Name as N
17import qualified Data.NonEmptyList as NE
19import qualified Data.NonEmptyList as NE
18−import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
19−import Foreign.Ptr (minusPtr)
20import Snap.Core
20import Snap.Core
21
21
22import qualified Artifacts as A
22import qualified Artifacts as A
@@ -32,10 +32,7 @@ import qualified Elm.Package as Pkg
32import qualified File
32import qualified File
33import qualified Generate.JavaScript as JS
33import qualified Generate.JavaScript as JS
34import qualified Json.Encode as Encode
34import qualified Json.Encode as Encode
35−import qualified Json.Decode as D
36import qualified Parse.Module as Parse
35import qualified Parse.Module as Parse
37−import qualified Parse.Primitives as P
38−import qualified Parse.Variable as Var
39import qualified Repl
36import qualified Repl
40import qualified Reporting.Annotation as A
37import qualified Reporting.Annotation as A
41import qualified Reporting.Error as Error
38import qualified Reporting.Error as Error
@@ -51,8 +48,9 @@ import qualified Reporting.Render.Type.Localizer as L
51
48
52allowedOrigins :: [String]
49allowedOrigins :: [String]
53allowedOrigins =
50allowedOrigins =
54− [ "https://elm-lang.org"
51+ [ "https://guide.elm-lang.org"
55− , "https://guide.elm-lang.org"
52+ , "https://guide.elm-lang.jp"
53+ , "http://localhost:8007"
56 ]
54 ]
57
55
58
56
@@ -63,12 +61,12 @@ allowedOrigins =
63endpoint :: A.Artifacts -> Snap ()
61endpoint :: A.Artifacts -> Snap ()
64endpoint artifacts =
62endpoint artifacts =
65 Cors.allow POST allowedOrigins $
63 Cors.allow POST allowedOrigins $
66− do body <- LBS.toStrict <$> readRequestBody (64 * 1024)
64+ do body <- readRequestBody (64 * 1024)
67− case D.fromByteString decoder body of
65+ case decodeBody body of
68− Right (state, entry) ->
66+ Just (state, entry) ->
69 serveOutcome (toOutcome artifacts state entry)
67 serveOutcome (toOutcome artifacts state entry)
70
68
71− Left _ ->
69+ Nothing ->
72 do modifyResponse $ setResponseStatus 400 "Bad Request"
70 do modifyResponse $ setResponseStatus 400 "Bad Request"
73 modifyResponse $ setContentType "text/html; charset=utf-8"
71 modifyResponse $ setContentType "text/html; charset=utf-8"
74 writeBS "Received unexpected JSON body."
72 writeBS "Received unexpected JSON body."
@@ -83,7 +81,6 @@ data Outcome
83 | NewType N.Name
81 | NewType N.Name
84 | NewWork B.Builder
82 | NewWork B.Builder
85 --
83 --
86− | Reset
87 | Skip
84 | Skip
88 | Indent
85 | Indent
89 | DefStart N.Name
86 | DefStart N.Name
@@ -93,11 +90,11 @@ data Outcome
93 | Failure BS.ByteString Error.Error
90 | Failure BS.ByteString Error.Error
94
91
95
92
96−toOutcome :: A.Artifacts -> Repl.State -> BS.ByteString -> Outcome
93+toOutcome :: A.Artifacts -> Repl.State -> String -> Outcome
97toOutcome artifacts state entry =
94toOutcome artifacts state entry =
98− case reverse (lines (BS_UTF8.toString entry)) of
95+ case reverse (lines entry) of
99 [] ->
96 [] ->
100− Indent
97+ Skip
101
98
102 prev : rev ->
99 prev : rev ->
103 case Repl.categorize (Repl.Lines prev rev) of
100 case Repl.categorize (Repl.Lines prev rev) of
@@ -109,7 +106,7 @@ toOutcome artifacts state entry =
109 Repl.Expr src -> compile artifacts state (ExprEntry src)
106 Repl.Expr src -> compile artifacts state (ExprEntry src)
110 Repl.Port -> NoPorts
107 Repl.Port -> NoPorts
111 Repl.Skip -> Skip
108 Repl.Skip -> Skip
112− Repl.Reset -> Reset
109+ Repl.Reset -> InvalidCommand
113 Repl.Exit -> InvalidCommand
110 Repl.Exit -> InvalidCommand
114 Repl.Help _ -> InvalidCommand
111 Repl.Help _ -> InvalidCommand
115
112
@@ -132,7 +129,6 @@ serveOutcome outcome =
132 NewImport name -> serveString $ "add-import:" <> N.toBuilder name
129 NewImport name -> serveString $ "add-import:" <> N.toBuilder name
133 NewType name -> serveString $ "add-type:" <> N.toBuilder name
130 NewType name -> serveString $ "add-type:" <> N.toBuilder name
134 NewWork js -> serveBuilder "application/javascript" js
131 NewWork js -> serveBuilder "application/javascript" js
135− Reset -> serveString $ "reset"
136 Skip -> serveString $ "skip"
132 Skip -> serveString $ "skip"
137 Indent -> serveString $ "indent"
133 Indent -> serveString $ "indent"
138 DefStart name -> serveString $ "def-start:" <> N.toBuilder name
134 DefStart name -> serveString $ "def-start:" <> N.toBuilder name
@@ -161,15 +157,14 @@ data EntryType
161
157
162
158
163compile :: A.Artifacts -> Repl.State -> EntryType -> Outcome
159compile :: A.Artifacts -> Repl.State -> EntryType -> Outcome
164−compile (A.Artifacts interfaces objects) state entryType =
160+compile (A.Artifacts interfaces objects) state@(Repl.State imports types decls) entryType =
165 let
161 let
166 source =
162 source =
167− Repl.toByteString state $
168− case entryType of
163+ case entryType of
169− ImportEntry _ _ -> Repl.OutputNothing
164+ ImportEntry name src -> Repl.toByteString (state { Repl._imports = Map.insert name (B.byteString src) imports }) Repl.OutputNothing
170− TypeEntry _ _ -> Repl.OutputNothing
165+ TypeEntry name src -> Repl.toByteString (state { Repl._types = Map.insert name (B.byteString src) types }) Repl.OutputNothing
171− DeclEntry name _ -> Repl.OutputDecl name
166+ DeclEntry name src -> Repl.toByteString (state { Repl._decls = Map.insert name (B.byteString src) decls }) (Repl.OutputDecl name)
172− ExprEntry src -> Repl.OutputExpr src
167+ ExprEntry src -> Repl.toByteString state (Repl.OutputExpr src)
173 in
168 in
174 case
169 case
175 do modul <- mapLeft Error.BadSyntax $ Parse.fromByteString Parse.Application source
170 do modul <- mapLeft Error.BadSyntax $ Parse.fromByteString Parse.Application source
@@ -226,31 +221,24 @@ checkImports interfaces imports =
226
221
227
222
228
223
229−-- DECODER
224+-- DECODE BODY
225+
226+
227+decodeBody :: LBS.ByteString -> Maybe ( Repl.State, String )
228+decodeBody body =
229+ Aeson.parseMaybe decodeBodyHelp =<< Aeson.decode' body
230
230
231
231
232−decoder :: D.Decoder () ( Repl.State, BS.ByteString )
232+decodeBodyHelp :: Aeson.Object -> Aeson.Parser ( Repl.State, String )
233−decoder =
233+decodeBodyHelp obj =
234 let
234 let
235− bail _ _ = ()
235+ get key =
236− upper = D.KeyDecoder (Var.upper bail) bail
236+ do dict <- obj .: key
237− lower = D.KeyDecoder (Var.lower bail) bail
237+ let f (k,v) = (N.fromChars k, B.stringUtf8 v)
238− bytes = D.customString bytesParser bail
238+ return $ Map.fromList $ map f $ Map.toList dict
239− builder = B.byteString <$> bytes
240 in
239 in
241− do imports <- D.field "imports" (D.dict upper builder)
240+ do imports <- get "imports"
242− types <- D.field "types" (D.dict upper builder)
241+ types <- get "types"
243− decls <- D.field "decls" (D.dict lower builder)
242+ decls <- get "decls"
244− entry <- D.field "entry" bytes
243+ entry <- obj .: "entry"
245 return ( Repl.State imports types decls, entry )
244 return ( Repl.State imports types decls, entry )
246−
247−
248−bytesParser :: P.Parser x BS.ByteString
249−bytesParser =
250− P.Parser $ \(P.State src pos end indent row col) cok _ _ _ ->
251− let
252− off = minusPtr pos (unsafeForeignPtrToPtr src)
253− len = minusPtr end pos
254− newCol = col + fromIntegral len
255− in
256− cok (BS.PS src off len) (P.State src end end indent row newCol)
worker/src/Errors.elmnew file+217
@@ -0,0 +1,217 @@
1+port module Errors exposing (main)
2+
3+
4+import Browser
5+import Char
6+import Html exposing (..)
7+import Html.Attributes exposing (..)
8+import Html.Events exposing (onClick)
9+import String
10+import Json.Decode as D
11+import Elm.Error as Error
12+
13+
14+
15+-- PORTS
16+
17+
18+port jumpTo : Error.Region -> Cmd msg
19+
20+
21+
22+-- MAIN
23+
24+
25+main =
26+ Browser.document
27+ { init = \flags -> (D.decodeValue Error.decoder flags, Cmd.none)
28+ , update = \region result -> (result, jumpTo region)
29+ , view = view
30+ , subscriptions = \_ -> Sub.none
31+ }
32+
33+
34+type alias Msg = Error.Region
35+
36+
37+
38+-- VIEW
39+
40+
41+view : Result D.Error Error.Error -> Browser.Document Msg
42+view result =
43+ { title = "Problem!"
44+ , body =
45+ case result of
46+ Err err ->
47+ [ text (D.errorToString err) ]
48+
49+ Ok error ->
50+ [ viewError error ]
51+ }
52+
53+
54+viewError : Error.Error -> Html Msg
55+viewError error =
56+ div
57+ [ style "width" "calc(100% - 4em)"
58+ , style "min-height" "calc(100% - 4em)"
59+ , style "font-family" "monospace"
60+ , style "white-space" "pre-wrap"
61+ , style "background-color" "black"
62+ , style "color" "rgb(233,235,235)"
63+ , style "padding" "2em"
64+ ]
65+ (viewErrorHelp error)
66+
67+
68+viewErrorHelp : Error.Error -> List (Html Msg)
69+viewErrorHelp error =
70+ case error of
71+ Error.GeneralProblem { title, message } ->
72+ viewHeader title Nothing :: viewMessage message
73+
74+ Error.ModuleProblems badModules ->
75+ viewBadModules badModules
76+
77+
78+
79+-- VIEW HEADER
80+
81+
82+viewHeader : String -> Maybe Error.Region -> Html Msg
83+viewHeader title maybeRegion =
84+ case maybeRegion of
85+ Nothing ->
86+ span [ style "color" "rgb(51,187,200)" ]
87+ [ text <| "-- " ++ title ++ " "
88+ , text <| String.repeat (76 - String.length title) "-"
89+ , text <| "\n\n"
90+ ]
91+
92+ Just region ->
93+ span [ style "color" "rgb(51,187,200)" ]
94+ [ text <| "-- " ++ title ++ " "
95+ , text <| String.repeat (60 - String.length title) "-"
96+ , text " "
97+ , span
98+ [ style "cursor" "pointer"
99+ , style "text-decoration" "underline"
100+ , onClick region
101+ ]
102+ [ text "Jump To Problem"
103+ ]
104+ , text <| "\n\n"
105+ ]
106+
107+
108+
109+-- VIEW BAD MODULES
110+
111+
112+viewBadModules : List Error.BadModule -> List (Html Msg)
113+viewBadModules badModules =
114+ case badModules of
115+ [] ->
116+ []
117+
118+ [badModule] ->
119+ [viewBadModule badModule]
120+
121+ a :: b :: cs ->
122+ viewBadModule a :: viewSeparator a.name b.name :: viewBadModules (b :: cs)
123+
124+
125+viewBadModule : Error.BadModule -> Html Msg
126+viewBadModule { problems } =
127+ span [] (List.map viewProblem problems)
128+
129+
130+viewProblem : Error.Problem -> Html Msg
131+viewProblem problem =
132+ span [] (viewHeader problem.title (Just problem.region) :: viewMessage problem.message)
133+
134+
135+viewSeparator : String -> String -> Html msg
136+viewSeparator before after =
137+ span [ style "color" "rgb(211,56,211)" ]
138+ [ text <|
139+ String.padLeft 80 ' ' (before ++ " ↑ ") ++ "\n" ++
140+ "====o======================================================================o====\n" ++
141+ " ↓ " ++ after ++ "\n\n\n"
142+ ]
143+
144+
145+
146+-- VIEW MESSAGE
147+
148+
149+viewMessage : List Error.Chunk -> List (Html msg)
150+viewMessage chunks =
151+ case chunks of
152+ [] ->
153+ [ text "\n\n\n" ]
154+
155+ chunk :: others ->
156+ let
157+ htmlChunk =
158+ case chunk of
159+ Error.Unstyled string ->
160+ text string
161+
162+ Error.Styled style string ->
163+ span (styleToAttrs style) [ text string ]
164+ in
165+ htmlChunk :: viewMessage others
166+
167+
168+styleToAttrs : Error.Style -> List (Attribute msg)
169+styleToAttrs { bold, underline, color } =
170+ addBold bold <| addUnderline underline <| addColor color []
171+
172+
173+addBold : Bool -> List (Attribute msg) -> List (Attribute msg)
174+addBold bool attrs =
175+ if bool then
176+ style "font-weight" "bold" :: attrs
177+ else
178+ attrs
179+
180+
181+addUnderline : Bool -> List (Attribute msg) -> List (Attribute msg)
182+addUnderline bool attrs =
183+ if bool then
184+ style "text-decoration" "underline" :: attrs
185+ else
186+ attrs
187+
188+
189+addColor : Maybe Error.Color -> List (Attribute msg) -> List (Attribute msg)
190+addColor maybeColor attrs =
191+ case maybeColor of
192+ Nothing ->
193+ attrs
194+
195+ Just color ->
196+ style "color" (colorToCss color) :: attrs
197+
198+
199+colorToCss : Error.Color -> String
200+colorToCss color =
201+ case color of
202+ Error.Red -> "rgb(194,54,33)"
203+ Error.RED -> "rgb(252,57,31)"
204+ Error.Magenta -> "rgb(211,56,211)"
205+ Error.MAGENTA -> "rgb(249,53,248)"
206+ Error.Yellow -> "rgb(173,173,39)"
207+ Error.YELLOW -> "rgb(234,236,35)"
208+ Error.Green -> "rgb(37,188,36)"
209+ Error.GREEN -> "rgb(49,231,34)"
210+ Error.Cyan -> "rgb(51,187,200)"
211+ Error.CYAN -> "rgb(20,240,240)"
212+ Error.Blue -> "rgb(73,46,225)"
213+ Error.BLUE -> "rgb(88,51,255)"
214+ Error.White -> "rgb(203,204,205)"
215+ Error.WHITE -> "rgb(233,235,235)"
216+ Error.Black -> "rgb(0,0,0)"
217+ Error.BLACK -> "rgb(129,131,131)"
worker/src/Main.hs+24−2
@@ -7,11 +7,14 @@ module Main
7
7
8
8
9import Control.Monad (msum)
9import Control.Monad (msum)
10+import qualified Data.ByteString as BS
10import Snap.Core
11import Snap.Core
11import Snap.Http.Server
12import Snap.Http.Server
12
13
13import qualified Artifacts
14import qualified Artifacts
15+import qualified Cors
14import qualified Endpoint.Compile as Compile
16import qualified Endpoint.Compile as Compile
17+import qualified Endpoint.Quotes as Quotes
15import qualified Endpoint.Repl as Repl
18import qualified Endpoint.Repl as Repl
16
19
17
20
@@ -24,11 +27,16 @@ main =
24 do rArtifacts <- Artifacts.loadRepl
27 do rArtifacts <- Artifacts.loadRepl
25 cArtifacts <- Artifacts.loadCompile
28 cArtifacts <- Artifacts.loadCompile
26 errorJS <- Compile.loadErrorJS
29 errorJS <- Compile.loadErrorJS
30+ let depsInfo = Artifacts.toDepsInfo cArtifacts
31+
27 httpServe config $ msum $
32 httpServe config $ msum $
28 [ ifTop $ status
33 [ ifTop $ status
29 , path "repl" $ Repl.endpoint rArtifacts
34 , path "repl" $ Repl.endpoint rArtifacts
30− , path "compile" $ Compile.endpoint cArtifacts
35+ , path "compile" $ Compile.endpoint_V1 cArtifacts
36+ , path "compile/v2" $ Compile.endpoint_V2 cArtifacts
31− , path "compile/errors.js" $ writeBS errorJS
37+ , path "compile/errors.js" $ serveJavaScript errorJS
38+ , path "compile/deps-info.json" $ serveDepsInfo depsInfo
39+ , path "quotes" $ Quotes.endpoint
32 , notFound
40 , notFound
33 ]
41 ]
34
42
@@ -49,3 +57,17 @@ notFound =
49 do modifyResponse $ setResponseStatus 404 "Not Found"
57 do modifyResponse $ setResponseStatus 404 "Not Found"
50 modifyResponse $ setContentType "text/html; charset=utf-8"
58 modifyResponse $ setContentType "text/html; charset=utf-8"
51 writeBuilder "Not Found"
59 writeBuilder "Not Found"
60+
61+
62+serveJavaScript :: BS.ByteString -> Snap ()
63+serveJavaScript javascript =
64+ do modifyResponse $ setContentType "application/javascript"
65+ writeBS javascript
66+
67+
68+serveDepsInfo :: BS.ByteString -> Snap ()
69+serveDepsInfo json =
70+ Cors.allow GET ["https://elm-lang.org"] $
71+ do modifyResponse $ setContentType "application/json"
72+ writeBS json
73+