From 20b33d05aff894e8f4dbbfe77583dbc8bc519ce6 Mon Sep 17 00:00:00 2001 From: Decio Ferreira Date: Sun, 28 Sep 2025 08:18:00 +0100 Subject: [PATCH 1/2] Move from elm mentions to guida --- src/Browser/Format.elm | 2 +- src/Browser/Install.elm | 461 ++++++---- src/Browser/Main.elm | 2 +- src/Browser/Make.elm | 16 +- src/Browser/Uninstall.elm | 142 +++- src/Builder/Build.elm | 12 +- src/Builder/Deps/Bump.elm | 4 +- src/Builder/Deps/Diff.elm | 12 +- src/Builder/Deps/Registry.elm | 4 +- src/Builder/Deps/Solver.elm | 535 ++++++++---- src/Builder/Deps/Website.elm | 9 +- src/Builder/File.elm | 4 +- src/Builder/Generate.elm | 28 +- src/Builder/{Elm => Guida}/Details.elm | 267 ++++-- src/Builder/{Elm => Guida}/Outline.elm | 252 ++++-- src/Builder/Http.elm | 4 +- src/Builder/Reporting.elm | 6 +- src/Builder/Reporting/Exit.elm | 568 ++++++++++--- src/Builder/Stuff.elm | 88 +- src/Common/Format/Cheapskate/Parse.elm | 4 +- src/Common/Format/Cheapskate/Types.elm | 2 +- src/Common/Format/ImportInfo.elm | 2 +- src/Common/Format/Render/Box.elm | 120 +-- .../{ElmStructure.elm => GuidaStructure.elm} | 2 +- src/Common/Format/Render/Markdown.elm | 12 +- src/Compiler/AST/Canonical.elm | 2 +- src/Compiler/AST/Optimized.elm | 10 +- src/Compiler/Canonicalize/Effects.elm | 2 +- .../Canonicalize/Environment/Foreign.elm | 6 +- src/Compiler/Canonicalize/Expression.elm | 4 +- src/Compiler/Canonicalize/Module.elm | 6 +- src/Compiler/Canonicalize/Pattern.elm | 2 +- src/Compiler/Compile.elm | 6 +- src/Compiler/Generate/Html.elm | 6 +- src/Compiler/Generate/JavaScript.elm | 8 +- .../Generate/JavaScript/Expression.elm | 28 +- src/Compiler/Generate/JavaScript/Name.elm | 6 +- .../Generate/JavaScript/SourceMap.elm | 2 +- src/Compiler/Generate/Mode.elm | 2 +- .../{Elm => Guida}/Compiler/Imports.elm | 4 +- src/Compiler/{Elm => Guida}/Compiler/Type.elm | 2 +- .../{Elm => Guida}/Compiler/Type/Extract.elm | 8 +- src/Compiler/{Elm => Guida}/Constraint.elm | 28 +- src/Compiler/{Elm => Guida}/Docs.elm | 8 +- src/Compiler/{Elm => Guida}/Interface.elm | 4 +- src/Compiler/{Elm => Guida}/Kernel.elm | 26 +- src/Compiler/{Elm => Guida}/Licenses.elm | 2 +- src/Compiler/{Elm => Guida}/Magnitude.elm | 2 +- src/Compiler/{Elm => Guida}/ModuleName.elm | 4 +- src/Compiler/{Elm => Guida}/Package.elm | 2 +- src/Compiler/{Elm => Guida}/String.elm | 2 +- src/Compiler/{Elm => Guida}/Version.elm | 11 +- src/Compiler/Nitpick/PatternMatches.elm | 2 +- src/Compiler/Optimize/DecisionTree.elm | 2 +- src/Compiler/Optimize/Expression.elm | 2 +- src/Compiler/Optimize/Module.elm | 2 +- src/Compiler/Optimize/Names.elm | 2 +- src/Compiler/Optimize/Port.elm | 2 +- src/Compiler/Parse/Module.elm | 4 +- src/Compiler/Parse/String.elm | 2 +- src/Compiler/Reporting/Doc.elm | 15 +- src/Compiler/Reporting/Error.elm | 2 +- src/Compiler/Reporting/Error/Canonicalize.elm | 38 +- src/Compiler/Reporting/Error/Docs.elm | 2 +- src/Compiler/Reporting/Error/Import.elm | 6 +- src/Compiler/Reporting/Error/Json.elm | 6 +- src/Compiler/Reporting/Error/Main.elm | 4 +- src/Compiler/Reporting/Error/Syntax.elm | 58 +- src/Compiler/Reporting/Error/Type.elm | 14 +- .../Reporting/Render/Type/Localizer.elm | 2 +- src/Compiler/Type/Constrain/Expression.elm | 2 +- src/Compiler/Type/Constrain/Module.elm | 2 +- src/Compiler/Type/Constrain/Pattern.elm | 2 +- src/Compiler/Type/Error.elm | 2 +- src/Compiler/Type/Solve.elm | 2 +- src/Compiler/Type/Type.elm | 2 +- src/Compiler/Type/Unify.elm | 2 +- src/Data/Map.elm | 2 +- src/Node/Format.elm | 2 +- src/System/TypeCheck/IO.elm | 4 +- src/Terminal/Bump.elm | 394 ++++++--- src/Terminal/Diff.elm | 59 +- src/Terminal/Format.elm | 41 +- src/Terminal/Init.elm | 45 +- src/Terminal/Install.elm | 801 ++++++++++++------ src/Terminal/Main.elm | 109 ++- src/Terminal/Make.elm | 18 +- src/Terminal/Publish.elm | 115 ++- src/Terminal/Repl.elm | 60 +- src/Terminal/Terminal.elm | 2 +- src/Terminal/Terminal/Helpers.elm | 6 +- src/Terminal/Test.elm | 232 +++-- src/Terminal/Uninstall.elm | 169 ++-- tests/Common/FormatTests.elm | 2 +- tests/Parse/NumberTests.elm | 110 +-- tests/format.test.js | 11 +- 96 files changed, 3405 insertions(+), 1707 deletions(-) rename src/Builder/{Elm => Guida}/Details.elm (87%) rename src/Builder/{Elm => Guida}/Outline.elm (59%) rename src/Common/Format/Render/{ElmStructure.elm => GuidaStructure.elm} (99%) rename src/Compiler/{Elm => Guida}/Compiler/Imports.elm (94%) rename src/Compiler/{Elm => Guida}/Compiler/Type.elm (99%) rename src/Compiler/{Elm => Guida}/Compiler/Type/Extract.elm (98%) rename src/Compiler/{Elm => Guida}/Constraint.elm (94%) rename src/Compiler/{Elm => Guida}/Docs.elm (99%) rename src/Compiler/{Elm => Guida}/Interface.elm (99%) rename src/Compiler/{Elm => Guida}/Kernel.elm (96%) rename src/Compiler/{Elm => Guida}/Licenses.elm (99%) rename src/Compiler/{Elm => Guida}/Magnitude.elm (94%) rename src/Compiler/{Elm => Guida}/ModuleName.elm (98%) rename src/Compiler/{Elm => Guida}/Package.elm (99%) rename src/Compiler/{Elm => Guida}/String.elm (98%) rename src/Compiler/{Elm => Guida}/Version.elm (93%) diff --git a/src/Browser/Format.elm b/src/Browser/Format.elm index 0688a9716..a44af34e1 100644 --- a/src/Browser/Format.elm +++ b/src/Browser/Format.elm @@ -1,7 +1,7 @@ module Browser.Format exposing (run) import Common.Format -import Compiler.Elm.Package as Pkg +import Compiler.Guida.Package as Pkg import Compiler.Parse.Module as M import Compiler.Parse.SyntaxVersion as SV diff --git a/src/Browser/Install.elm b/src/Browser/Install.elm index 2e50e72db..359ef99fd 100644 --- a/src/Browser/Install.elm +++ b/src/Browser/Install.elm @@ -3,18 +3,18 @@ module Browser.Install exposing (run) import Builder.BackgroundWriter as BW import Builder.Deps.Registry as Registry import Builder.Deps.Solver as Solver -import Builder.Elm.Details as Details -import Builder.Elm.Outline as Outline +import Builder.Guida.Details as Details +import Builder.Guida.Outline as Outline import Builder.Reporting as Reporting import Builder.Reporting.Exit as Exit import Builder.Stuff as Stuff -import Compiler.Elm.Constraint as C -import Compiler.Elm.Package as Pkg -import Compiler.Elm.Version as V +import Compiler.Guida.Constraint as C +import Compiler.Guida.Package as Pkg +import Compiler.Guida.Version as V import Data.Map as Dict exposing (Dict) import System.IO as IO import Task exposing (Task) -import Utils.Main as Utils exposing (FilePath) +import Utils.Main as Utils import Utils.Task.Extra as Task @@ -66,7 +66,7 @@ type Changes vsn | Changes Outline.Outline -attemptChanges : String -> Solver.Env -> Outline.Outline -> (a -> String) -> Changes a -> Task Exit.Install () +attemptChanges : Stuff.Root -> Solver.Env -> Outline.Outline -> (a -> String) -> Changes a -> Task Exit.Install () attemptChanges root env oldOutline _ changes = case changes of AlreadyInstalled -> @@ -82,7 +82,7 @@ attemptChanges root env oldOutline _ changes = attemptChangesHelp root env oldOutline newOutline -attemptChangesHelp : FilePath -> Solver.Env -> Outline.Outline -> Outline.Outline -> Task Exit.Install () +attemptChangesHelp : Stuff.Root -> Solver.Env -> Outline.Outline -> Outline.Outline -> Task Exit.Install () attemptChangesHelp root env oldOutline newOutline = Task.eio Exit.InstallBadDetails <| BW.withScope @@ -108,80 +108,157 @@ attemptChangesHelp root env oldOutline newOutline = makeAppPlan : Solver.Env -> Pkg.Name -> Outline.AppOutline -> Task Exit.Install (Changes V.Version) -makeAppPlan (Solver.Env cache _ connection registry) pkg ((Outline.AppOutline elmVersion sourceDirs direct indirect testDirect testIndirect) as outline) = - if Dict.member identity pkg direct then - Task.pure AlreadyInstalled +makeAppPlan (Solver.Env cache _ connection registry) pkg outline = + case outline of + Outline.GuidaAppOutline guidaVersion sourceDirs direct indirect testDirect testIndirect -> + if Dict.member identity pkg direct then + Task.pure AlreadyInstalled - else - -- is it already indirect? - case Dict.get identity pkg indirect of - Just vsn -> - Task.pure <| - PromoteIndirect <| - Outline.App <| - Outline.AppOutline elmVersion - sourceDirs - (Dict.insert identity pkg vsn direct) - (Dict.remove identity pkg indirect) - testDirect - testIndirect - - Nothing -> - -- is it already a test dependency? - case Dict.get identity pkg testDirect of + else + -- is it already indirect? + case Dict.get identity pkg indirect of Just vsn -> Task.pure <| - PromoteTest <| + PromoteIndirect <| Outline.App <| - Outline.AppOutline elmVersion + Outline.GuidaAppOutline guidaVersion sourceDirs (Dict.insert identity pkg vsn direct) - indirect - (Dict.remove identity pkg testDirect) + (Dict.remove identity pkg indirect) + testDirect testIndirect Nothing -> - -- is it already an indirect test dependency? - case Dict.get identity pkg testIndirect of + -- is it already a test dependency? + case Dict.get identity pkg testDirect of Just vsn -> Task.pure <| PromoteTest <| Outline.App <| - Outline.AppOutline elmVersion + Outline.GuidaAppOutline guidaVersion sourceDirs (Dict.insert identity pkg vsn direct) indirect - testDirect - (Dict.remove identity pkg testIndirect) + (Dict.remove identity pkg testDirect) + testIndirect Nothing -> - -- finally try to add it from scratch - case Registry.getVersions_ pkg registry of - Err suggestions -> - case connection of - Solver.Online _ -> - Task.throw (Exit.InstallUnknownPackageOnline pkg suggestions) - - Solver.Offline -> - Task.throw (Exit.InstallUnknownPackageOffline pkg suggestions) - - Ok _ -> - Task.io (Solver.addToApp cache connection registry pkg outline False) - |> Task.bind - (\result -> - case result of - Solver.SolverOk (Solver.AppSolution _ _ app) -> - Task.pure (Changes (Outline.App app)) + -- is it already an indirect test dependency? + case Dict.get identity pkg testIndirect of + Just vsn -> + Task.pure <| + PromoteTest <| + Outline.App <| + Outline.GuidaAppOutline guidaVersion + sourceDirs + (Dict.insert identity pkg vsn direct) + indirect + testDirect + (Dict.remove identity pkg testIndirect) + + Nothing -> + -- finally try to add it from scratch + case Registry.getVersions_ pkg registry of + Err suggestions -> + case connection of + Solver.Online _ -> + Task.throw (Exit.InstallUnknownPackageOnline pkg suggestions) + + Solver.Offline -> + Task.throw (Exit.InstallUnknownPackageOffline pkg suggestions) + + Ok _ -> + Task.io (Solver.addToApp cache connection registry pkg outline False) + |> Task.bind + (\result -> + case result of + Solver.SolverOk (Solver.AppSolution _ _ app) -> + Task.pure (Changes (Outline.App app)) + + Solver.NoSolution -> + Task.throw (Exit.InstallNoOnlineAppSolution pkg) + + Solver.NoOfflineSolution -> + Task.throw (Exit.InstallNoOfflineAppSolution pkg) + + Solver.SolverErr exit -> + Task.throw (Exit.InstallHadSolverTrouble exit) + ) + + Outline.ElmAppOutline elmVersion sourceDirs direct indirect testDirect testIndirect -> + if Dict.member identity pkg direct then + Task.pure AlreadyInstalled - Solver.NoSolution -> - Task.throw (Exit.InstallNoOnlineAppSolution pkg) + else + -- is it already indirect? + case Dict.get identity pkg indirect of + Just vsn -> + Task.pure <| + PromoteIndirect <| + Outline.App <| + Outline.ElmAppOutline elmVersion + sourceDirs + (Dict.insert identity pkg vsn direct) + (Dict.remove identity pkg indirect) + testDirect + testIndirect - Solver.NoOfflineSolution -> - Task.throw (Exit.InstallNoOfflineAppSolution pkg) + Nothing -> + -- is it already a test dependency? + case Dict.get identity pkg testDirect of + Just vsn -> + Task.pure <| + PromoteTest <| + Outline.App <| + Outline.ElmAppOutline elmVersion + sourceDirs + (Dict.insert identity pkg vsn direct) + indirect + (Dict.remove identity pkg testDirect) + testIndirect - Solver.SolverErr exit -> - Task.throw (Exit.InstallHadSolverTrouble exit) - ) + Nothing -> + -- is it already an indirect test dependency? + case Dict.get identity pkg testIndirect of + Just vsn -> + Task.pure <| + PromoteTest <| + Outline.App <| + Outline.ElmAppOutline elmVersion + sourceDirs + (Dict.insert identity pkg vsn direct) + indirect + testDirect + (Dict.remove identity pkg testIndirect) + + Nothing -> + -- finally try to add it from scratch + case Registry.getVersions_ pkg registry of + Err suggestions -> + case connection of + Solver.Online _ -> + Task.throw (Exit.InstallUnknownPackageOnline pkg suggestions) + + Solver.Offline -> + Task.throw (Exit.InstallUnknownPackageOffline pkg suggestions) + + Ok _ -> + Task.io (Solver.addToApp cache connection registry pkg outline False) + |> Task.bind + (\result -> + case result of + Solver.SolverOk (Solver.AppSolution _ _ app) -> + Task.pure (Changes (Outline.App app)) + + Solver.NoSolution -> + Task.throw (Exit.InstallNoOnlineAppSolution pkg) + + Solver.NoOfflineSolution -> + Task.throw (Exit.InstallNoOfflineAppSolution pkg) + + Solver.SolverErr exit -> + Task.throw (Exit.InstallHadSolverTrouble exit) + ) @@ -189,93 +266,183 @@ makeAppPlan (Solver.Env cache _ connection registry) pkg ((Outline.AppOutline el makePkgPlan : Solver.Env -> Pkg.Name -> Outline.PkgOutline -> Task Exit.Install (Changes C.Constraint) -makePkgPlan (Solver.Env cache _ connection registry) pkg (Outline.PkgOutline name summary license version exposed deps test elmVersion) = - if Dict.member identity pkg deps then - Task.pure AlreadyInstalled +makePkgPlan (Solver.Env cache _ connection registry) pkg outline = + case outline of + Outline.GuidaPkgOutline name summary license version exposed deps test guidaVersion -> + if Dict.member identity pkg deps then + Task.pure AlreadyInstalled - else - -- is already in test dependencies? - case Dict.get identity pkg test of - Just con -> - Task.pure <| - PromoteTest <| - Outline.Pkg <| - Outline.PkgOutline name - summary - license - version - exposed - (Dict.insert identity pkg con deps) - (Dict.remove identity pkg test) - elmVersion - - Nothing -> - -- try to add a new dependency - case Registry.getVersions_ pkg registry of - Err suggestions -> - case connection of - Solver.Online _ -> - Task.throw (Exit.InstallUnknownPackageOnline pkg suggestions) - - Solver.Offline -> - Task.throw (Exit.InstallUnknownPackageOffline pkg suggestions) - - Ok (Registry.KnownVersions _ _) -> - let - old : Dict ( String, String ) Pkg.Name C.Constraint - old = - Dict.union deps test - - cons : Dict ( String, String ) Pkg.Name C.Constraint - cons = - Dict.insert identity pkg C.anything old - in - Task.io (Solver.verify cache connection registry cons) - |> Task.bind - (\result -> - case result of - Solver.SolverOk solution -> - let - (Solver.Details vsn _) = - Utils.find identity pkg solution - - con : C.Constraint - con = - C.untilNextMajor vsn - - new : Dict ( String, String ) Pkg.Name C.Constraint - new = - Dict.insert identity pkg con old - - changes : Dict ( String, String ) Pkg.Name (Change C.Constraint) - changes = - detectChanges old new - - news : Dict ( String, String ) Pkg.Name C.Constraint - news = - Utils.mapMapMaybe identity Pkg.compareName keepNew changes - in - Task.pure <| - Changes <| - Outline.Pkg <| - Outline.PkgOutline name - summary - license - version - exposed - (addNews (Just pkg) news deps) - (addNews Nothing news test) - elmVersion - - Solver.NoSolution -> - Task.throw (Exit.InstallNoOnlinePkgSolution pkg) - - Solver.NoOfflineSolution -> - Task.throw (Exit.InstallNoOfflinePkgSolution pkg) - - Solver.SolverErr exit -> - Task.throw (Exit.InstallHadSolverTrouble exit) - ) + else + -- is already in test dependencies? + case Dict.get identity pkg test of + Just con -> + Task.pure <| + PromoteTest <| + Outline.Pkg <| + Outline.GuidaPkgOutline name + summary + license + version + exposed + (Dict.insert identity pkg con deps) + (Dict.remove identity pkg test) + guidaVersion + + Nothing -> + -- try to add a new dependency + case Registry.getVersions_ pkg registry of + Err suggestions -> + case connection of + Solver.Online _ -> + Task.throw (Exit.InstallUnknownPackageOnline pkg suggestions) + + Solver.Offline -> + Task.throw (Exit.InstallUnknownPackageOffline pkg suggestions) + + Ok (Registry.KnownVersions _ _) -> + let + old : Dict ( String, String ) Pkg.Name C.Constraint + old = + Dict.union deps test + + cons : Dict ( String, String ) Pkg.Name C.Constraint + cons = + Dict.insert identity pkg C.anything old + in + Task.io (Solver.verify cache connection registry cons) + |> Task.bind + (\result -> + case result of + Solver.SolverOk solution -> + let + (Solver.Details vsn _) = + Utils.find identity pkg solution + + con : C.Constraint + con = + C.untilNextMajor vsn + + new : Dict ( String, String ) Pkg.Name C.Constraint + new = + Dict.insert identity pkg con old + + changes : Dict ( String, String ) Pkg.Name (Change C.Constraint) + changes = + detectChanges old new + + news : Dict ( String, String ) Pkg.Name C.Constraint + news = + Utils.mapMapMaybe identity Pkg.compareName keepNew changes + in + Task.pure <| + Changes <| + Outline.Pkg <| + Outline.GuidaPkgOutline name + summary + license + version + exposed + (addNews (Just pkg) news deps) + (addNews Nothing news test) + guidaVersion + + Solver.NoSolution -> + Task.throw (Exit.InstallNoOnlinePkgSolution pkg) + + Solver.NoOfflineSolution -> + Task.throw (Exit.InstallNoOfflinePkgSolution pkg) + + Solver.SolverErr exit -> + Task.throw (Exit.InstallHadSolverTrouble exit) + ) + + Outline.ElmPkgOutline name summary license version exposed deps test elmVersion -> + if Dict.member identity pkg deps then + Task.pure AlreadyInstalled + + else + -- is already in test dependencies? + case Dict.get identity pkg test of + Just con -> + Task.pure <| + PromoteTest <| + Outline.Pkg <| + Outline.ElmPkgOutline name + summary + license + version + exposed + (Dict.insert identity pkg con deps) + (Dict.remove identity pkg test) + elmVersion + + Nothing -> + -- try to add a new dependency + case Registry.getVersions_ pkg registry of + Err suggestions -> + case connection of + Solver.Online _ -> + Task.throw (Exit.InstallUnknownPackageOnline pkg suggestions) + + Solver.Offline -> + Task.throw (Exit.InstallUnknownPackageOffline pkg suggestions) + + Ok (Registry.KnownVersions _ _) -> + let + old : Dict ( String, String ) Pkg.Name C.Constraint + old = + Dict.union deps test + + cons : Dict ( String, String ) Pkg.Name C.Constraint + cons = + Dict.insert identity pkg C.anything old + in + Task.io (Solver.verify cache connection registry cons) + |> Task.bind + (\result -> + case result of + Solver.SolverOk solution -> + let + (Solver.Details vsn _) = + Utils.find identity pkg solution + + con : C.Constraint + con = + C.untilNextMajor vsn + + new : Dict ( String, String ) Pkg.Name C.Constraint + new = + Dict.insert identity pkg con old + + changes : Dict ( String, String ) Pkg.Name (Change C.Constraint) + changes = + detectChanges old new + + news : Dict ( String, String ) Pkg.Name C.Constraint + news = + Utils.mapMapMaybe identity Pkg.compareName keepNew changes + in + Task.pure <| + Changes <| + Outline.Pkg <| + Outline.ElmPkgOutline name + summary + license + version + exposed + (addNews (Just pkg) news deps) + (addNews Nothing news test) + elmVersion + + Solver.NoSolution -> + Task.throw (Exit.InstallNoOnlinePkgSolution pkg) + + Solver.NoOfflineSolution -> + Task.throw (Exit.InstallNoOfflinePkgSolution pkg) + + Solver.SolverErr exit -> + Task.throw (Exit.InstallHadSolverTrouble exit) + ) addNews : Maybe Pkg.Name -> Dict ( String, String ) Pkg.Name C.Constraint -> Dict ( String, String ) Pkg.Name C.Constraint -> Dict ( String, String ) Pkg.Name C.Constraint diff --git a/src/Browser/Main.elm b/src/Browser/Main.elm index 5d0ba9f33..8c339acff 100644 --- a/src/Browser/Main.elm +++ b/src/Browser/Main.elm @@ -5,7 +5,7 @@ import Browser.Install as Install import Browser.Make as Make import Browser.Uninstall as Uninstall import Builder.Reporting.Exit as Exit -import Compiler.Elm.Package as Pkg +import Compiler.Guida.Package as Pkg import Compiler.Json.Encode as E import Compiler.Parse.Primitives as P import Json.Decode as Decode diff --git a/src/Browser/Make.elm b/src/Browser/Make.elm index c3cd3b782..1afa2c054 100644 --- a/src/Browser/Make.elm +++ b/src/Browser/Make.elm @@ -13,14 +13,14 @@ module Browser.Make exposing import Builder.BackgroundWriter as BW import Builder.Build as Build -import Builder.Elm.Details as Details +import Builder.Guida.Details as Details import Builder.Generate as Generate import Builder.Reporting as Reporting import Builder.Reporting.Exit as Exit import Builder.Stuff as Stuff import Compiler.AST.Optimized as Opt import Compiler.Data.NonEmptyList as NE -import Compiler.Elm.ModuleName as ModuleName +import Compiler.Guida.ModuleName as ModuleName import Compiler.Generate.Html as Html import Maybe.Extra as Maybe import Task exposing (Task) @@ -66,11 +66,11 @@ run path flags = ) -runHelp : String -> String -> Flags -> Task Never (Result Exit.Make String) +runHelp : Stuff.Root -> String -> Flags -> Task Never (Result Exit.Make String) runHelp root path (Flags debug optimize withSourceMaps) = BW.withScope (\scope -> - Stuff.withRootLock root <| + Stuff.withRootLock (Stuff.rootPath root) <| Task.run <| (getMode debug optimize |> Task.bind @@ -128,10 +128,10 @@ getMode debug optimize = -- BUILD PROJECTS -buildPaths : Reporting.Style -> FilePath -> Details.Details -> NE.Nonempty FilePath -> Task Exit.Make Build.Artifacts +buildPaths : Reporting.Style -> Stuff.Root -> Details.Details -> NE.Nonempty FilePath -> Task Exit.Make Build.Artifacts buildPaths style root details paths = Task.eio Exit.MakeCannotBuild <| - Build.fromPaths style root details paths + Build.fromPaths style (Stuff.rootPath root) details paths @@ -178,7 +178,7 @@ type DesiredMode | Prod -toBuilder : Bool -> Int -> FilePath -> Details.Details -> DesiredMode -> Build.Artifacts -> Task Exit.Make String +toBuilder : Bool -> Int -> Stuff.Root -> Details.Details -> DesiredMode -> Build.Artifacts -> Task Exit.Make String toBuilder withSourceMaps leadingLines root details desiredMode artifacts = Task.mapError Exit.MakeBadGenerate <| case desiredMode of @@ -221,7 +221,7 @@ output = { singular = "output file" , plural = "output files" , suggest = \_ -> Task.pure [] - , examples = \_ -> Task.pure [ "elm.js", "index.html", "/dev/null" ] + , examples = \_ -> Task.pure [ "guida.js", "index.html", "/dev/null" ] } diff --git a/src/Browser/Uninstall.elm b/src/Browser/Uninstall.elm index 907943a7d..40d9a592c 100644 --- a/src/Browser/Uninstall.elm +++ b/src/Browser/Uninstall.elm @@ -2,18 +2,17 @@ module Browser.Uninstall exposing (run) import Builder.BackgroundWriter as BW import Builder.Deps.Solver as Solver -import Builder.Elm.Details as Details -import Builder.Elm.Outline as Outline +import Builder.Guida.Details as Details +import Builder.Guida.Outline as Outline import Builder.Reporting as Reporting import Builder.Reporting.Exit as Exit import Builder.Stuff as Stuff -import Compiler.Elm.Constraint as C -import Compiler.Elm.Package as Pkg -import Compiler.Elm.Version as V +import Compiler.Guida.Constraint as C +import Compiler.Guida.Package as Pkg +import Compiler.Guida.Version as V import Data.Map as Dict exposing (Dict) import System.IO as IO import Task exposing (Task) -import Utils.Main exposing (FilePath) import Utils.Task.Extra as Task @@ -63,7 +62,7 @@ type Changes vsn | Changes Outline.Outline -attemptChanges : String -> Solver.Env -> Outline.Outline -> Changes a -> Task Exit.Uninstall () +attemptChanges : Stuff.Root -> Solver.Env -> Outline.Outline -> Changes a -> Task Exit.Uninstall () attemptChanges root env oldOutline changes = case changes of AlreadyNotPresent -> @@ -73,7 +72,7 @@ attemptChanges root env oldOutline changes = attemptChangesHelp root env oldOutline newOutline -attemptChangesHelp : FilePath -> Solver.Env -> Outline.Outline -> Outline.Outline -> Task Exit.Uninstall () +attemptChangesHelp : Stuff.Root -> Solver.Env -> Outline.Outline -> Outline.Outline -> Task Exit.Uninstall () attemptChangesHelp root env oldOutline newOutline = Task.eio Exit.UninstallBadDetails <| BW.withScope @@ -99,28 +98,53 @@ attemptChangesHelp root env oldOutline newOutline = makeAppPlan : Solver.Env -> Pkg.Name -> Outline.AppOutline -> Task Exit.Uninstall (Changes V.Version) -makeAppPlan (Solver.Env cache _ connection registry) pkg ((Outline.AppOutline _ _ direct _ testDirect _) as outline) = - case Dict.get identity pkg (Dict.union direct testDirect) of - Just _ -> - Task.io (Solver.removeFromApp cache connection registry pkg outline) - |> Task.bind - (\result -> - case result of - Solver.SolverOk (Solver.AppSolution _ _ app) -> - Task.pure (Changes (Outline.App app)) +makeAppPlan (Solver.Env cache _ connection registry) pkg outline = + case outline of + Outline.GuidaAppOutline _ _ direct _ testDirect _ -> + case Dict.get identity pkg (Dict.union direct testDirect) of + Just _ -> + Task.io (Solver.removeFromApp cache connection registry pkg outline) + |> Task.bind + (\result -> + case result of + Solver.SolverOk (Solver.AppSolution _ _ app) -> + Task.pure (Changes (Outline.App app)) - Solver.NoSolution -> - Task.throw (Exit.UninstallNoOnlineAppSolution pkg) + Solver.NoSolution -> + Task.throw (Exit.UninstallNoOnlineAppSolution pkg) - Solver.NoOfflineSolution -> - Task.throw (Exit.UninstallNoOfflineAppSolution pkg) + Solver.NoOfflineSolution -> + Task.throw (Exit.UninstallNoOfflineAppSolution pkg) - Solver.SolverErr exit -> - Task.throw (Exit.UninstallHadSolverTrouble exit) - ) + Solver.SolverErr exit -> + Task.throw (Exit.UninstallHadSolverTrouble exit) + ) - Nothing -> - Task.pure AlreadyNotPresent + Nothing -> + Task.pure AlreadyNotPresent + + Outline.ElmAppOutline _ _ direct _ testDirect _ -> + case Dict.get identity pkg (Dict.union direct testDirect) of + Just _ -> + Task.io (Solver.removeFromApp cache connection registry pkg outline) + |> Task.bind + (\result -> + case result of + Solver.SolverOk (Solver.AppSolution _ _ app) -> + Task.pure (Changes (Outline.App app)) + + Solver.NoSolution -> + Task.throw (Exit.UninstallNoOnlineAppSolution pkg) + + Solver.NoOfflineSolution -> + Task.throw (Exit.UninstallNoOfflineAppSolution pkg) + + Solver.SolverErr exit -> + Task.throw (Exit.UninstallHadSolverTrouble exit) + ) + + Nothing -> + Task.pure AlreadyNotPresent @@ -128,24 +152,48 @@ makeAppPlan (Solver.Env cache _ connection registry) pkg ((Outline.AppOutline _ makePkgPlan : Pkg.Name -> Outline.PkgOutline -> Task Exit.Uninstall (Changes C.Constraint) -makePkgPlan pkg (Outline.PkgOutline name summary license version exposed deps test elmVersion) = - let - old : Dict ( String, String ) Pkg.Name C.Constraint - old = - Dict.union deps test - in - if Dict.member identity pkg old then - Task.pure <| - Changes <| - Outline.Pkg <| - Outline.PkgOutline name - summary - license - version - exposed - (Dict.remove identity pkg deps) - (Dict.remove identity pkg test) - elmVersion - - else - Task.pure AlreadyNotPresent +makePkgPlan pkg outline = + case outline of + Outline.GuidaPkgOutline name summary license version exposed deps test elmVersion -> + let + old : Dict ( String, String ) Pkg.Name C.Constraint + old = + Dict.union deps test + in + if Dict.member identity pkg old then + Task.pure <| + Changes <| + Outline.Pkg <| + Outline.GuidaPkgOutline name + summary + license + version + exposed + (Dict.remove identity pkg deps) + (Dict.remove identity pkg test) + elmVersion + + else + Task.pure AlreadyNotPresent + + Outline.ElmPkgOutline name summary license version exposed deps test elmVersion -> + let + old : Dict ( String, String ) Pkg.Name C.Constraint + old = + Dict.union deps test + in + if Dict.member identity pkg old then + Task.pure <| + Changes <| + Outline.Pkg <| + Outline.ElmPkgOutline name + summary + license + version + exposed + (Dict.remove identity pkg deps) + (Dict.remove identity pkg test) + elmVersion + + else + Task.pure AlreadyNotPresent diff --git a/src/Builder/Build.elm b/src/Builder/Build.elm index 9b7988d41..027f7927b 100644 --- a/src/Builder/Build.elm +++ b/src/Builder/Build.elm @@ -18,9 +18,9 @@ module Builder.Build exposing ) import Basics.Extra exposing (flip) -import Builder.Elm.Details as Details -import Builder.Elm.Outline as Outline import Builder.File as File +import Builder.Guida.Details as Details +import Builder.Guida.Outline as Outline import Builder.Reporting as Reporting import Builder.Reporting.Exit as Exit import Builder.Stuff as Stuff @@ -32,10 +32,10 @@ import Compiler.Data.Map.Utils as Map import Compiler.Data.Name as Name import Compiler.Data.NonEmptyList as NE import Compiler.Data.OneOrMore as OneOrMore -import Compiler.Elm.Docs as Docs -import Compiler.Elm.Interface as I -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg +import Compiler.Guida.Docs as Docs +import Compiler.Guida.Interface as I +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg import Compiler.Json.Encode as E import Compiler.Parse.Module as Parse import Compiler.Parse.SyntaxVersion as SV diff --git a/src/Builder/Deps/Bump.elm b/src/Builder/Deps/Bump.elm index c35f5e07b..8609cf1e9 100644 --- a/src/Builder/Deps/Bump.elm +++ b/src/Builder/Deps/Bump.elm @@ -1,8 +1,8 @@ module Builder.Deps.Bump exposing (getPossibilities) import Builder.Deps.Registry exposing (KnownVersions(..)) -import Compiler.Elm.Magnitude as M -import Compiler.Elm.Version as V +import Compiler.Guida.Magnitude as M +import Compiler.Guida.Version as V import List.Extra import Utils.Main as Utils diff --git a/src/Builder/Deps/Diff.elm b/src/Builder/Deps/Diff.elm index c19b5b04e..f48089b9c 100644 --- a/src/Builder/Deps/Diff.elm +++ b/src/Builder/Deps/Diff.elm @@ -15,12 +15,12 @@ import Builder.Http as Http import Builder.Reporting.Exit as Exit exposing (DocsProblem(..)) import Builder.Stuff as Stuff import Compiler.Data.Name as Name -import Compiler.Elm.Compiler.Type as Type -import Compiler.Elm.Docs as Docs -import Compiler.Elm.Magnitude as M -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg -import Compiler.Elm.Version as V exposing (Version) +import Compiler.Guida.Compiler.Type as Type +import Compiler.Guida.Docs as Docs +import Compiler.Guida.Magnitude as M +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg +import Compiler.Guida.Version as V exposing (Version) import Compiler.Json.Decode as D import Data.Map as Dict exposing (Dict) import Data.Set as EverySet diff --git a/src/Builder/Deps/Registry.elm b/src/Builder/Deps/Registry.elm index 87e3782fc..96ee7e4f5 100644 --- a/src/Builder/Deps/Registry.elm +++ b/src/Builder/Deps/Registry.elm @@ -17,8 +17,8 @@ import Builder.File as File import Builder.Http as Http import Builder.Reporting.Exit as Exit import Builder.Stuff as Stuff -import Compiler.Elm.Package as Pkg -import Compiler.Elm.Version as V +import Compiler.Guida.Package as Pkg +import Compiler.Guida.Version as V import Compiler.Json.Decode as D import Compiler.Parse.Primitives as P import Data.Map as Dict exposing (Dict) diff --git a/src/Builder/Deps/Solver.elm b/src/Builder/Deps/Solver.elm index e357010ef..232dbece3 100644 --- a/src/Builder/Deps/Solver.elm +++ b/src/Builder/Deps/Solver.elm @@ -17,14 +17,14 @@ module Builder.Deps.Solver exposing import Builder.Deps.Registry as Registry import Builder.Deps.Website as Website -import Builder.Elm.Outline as Outline import Builder.File as File +import Builder.Guida.Outline as Outline import Builder.Http as Http import Builder.Reporting.Exit as Exit import Builder.Stuff as Stuff -import Compiler.Elm.Constraint as C -import Compiler.Elm.Package as Pkg -import Compiler.Elm.Version as V +import Compiler.Guida.Constraint as C +import Compiler.Guida.Package as Pkg +import Compiler.Guida.Version as V import Compiler.Json.Decode as D import Data.Map as Dict exposing (Dict) import Task exposing (Task) @@ -74,7 +74,7 @@ type SolverResult a --- VERIFY -- used by Elm.Details +-- VERIFY -- used by Guida.Details type Details @@ -161,73 +161,143 @@ getTransitive constraints solution unvisited visited = addToApp : Stuff.PackageCache -> Connection -> Registry.Registry -> Pkg.Name -> Outline.AppOutline -> Bool -> Task Never (SolverResult AppSolution) -addToApp cache connection registry pkg (Outline.AppOutline elm srcDirs direct indirect testDirect testIndirect) forTest = - Stuff.withRegistryLock cache <| - let - allIndirects : Dict ( String, String ) Pkg.Name V.Version - allIndirects = - Dict.union indirect testIndirect - - allDirects : Dict ( String, String ) Pkg.Name V.Version - allDirects = - Dict.union direct testDirect - - allDeps : Dict ( String, String ) Pkg.Name V.Version - allDeps = - Dict.union allDirects allIndirects - - attempt : (a -> C.Constraint) -> Dict ( String, String ) Pkg.Name a -> Solver (Dict ( String, String ) Pkg.Name V.Version) - attempt toConstraint deps = - try (Dict.insert identity pkg C.anything (Dict.map (\_ -> toConstraint) deps)) - in - case - oneOf - (attempt C.exactly allDeps) - [ attempt C.exactly allDirects - , attempt C.untilNextMinor allDirects - , attempt C.untilNextMajor allDirects - , attempt (\_ -> C.anything) allDirects - ] - of - Solver solver -> - solver (State cache connection registry Dict.empty) - |> Task.fmap - (\result -> - case result of - ISOk (State _ _ _ constraints) new -> - let - d : Dict ( String, String ) Pkg.Name V.Version - d = - if forTest then - Dict.intersection Pkg.compareName new direct - - else - Dict.intersection Pkg.compareName new (Dict.insert identity pkg V.one direct) - - i : Dict ( String, String ) Pkg.Name V.Version - i = - Dict.diff (getTransitive constraints new (Dict.toList compare d) Dict.empty) d - - td : Dict ( String, String ) Pkg.Name V.Version - td = - if forTest then - Dict.intersection Pkg.compareName new (Dict.insert identity pkg V.one testDirect) - - else - Dict.intersection Pkg.compareName new (Dict.remove identity pkg testDirect) - - ti : Dict ( String, String ) Pkg.Name V.Version - ti = - Dict.diff new (Utils.mapUnions [ d, i, td ]) - in - SolverOk (AppSolution allDeps new (Outline.AppOutline elm srcDirs d i td ti)) +addToApp cache connection registry pkg outline forTest = + case outline of + Outline.GuidaAppOutline guida srcDirs direct indirect testDirect testIndirect -> + Stuff.withRegistryLock cache <| + let + allIndirects : Dict ( String, String ) Pkg.Name V.Version + allIndirects = + Dict.union indirect testIndirect - ISBack _ -> - noSolution connection + allDirects : Dict ( String, String ) Pkg.Name V.Version + allDirects = + Dict.union direct testDirect - ISErr e -> - SolverErr e - ) + allDeps : Dict ( String, String ) Pkg.Name V.Version + allDeps = + Dict.union allDirects allIndirects + + attempt : (a -> C.Constraint) -> Dict ( String, String ) Pkg.Name a -> Solver (Dict ( String, String ) Pkg.Name V.Version) + attempt toConstraint deps = + try (Dict.insert identity pkg C.anything (Dict.map (\_ -> toConstraint) deps)) + in + case + oneOf + (attempt C.exactly allDeps) + [ attempt C.exactly allDirects + , attempt C.untilNextMinor allDirects + , attempt C.untilNextMajor allDirects + , attempt (\_ -> C.anything) allDirects + ] + of + Solver solver -> + solver (State cache connection registry Dict.empty) + |> Task.fmap + (\result -> + case result of + ISOk (State _ _ _ constraints) new -> + let + d : Dict ( String, String ) Pkg.Name V.Version + d = + if forTest then + Dict.intersection Pkg.compareName new direct + + else + Dict.intersection Pkg.compareName new (Dict.insert identity pkg V.one direct) + + i : Dict ( String, String ) Pkg.Name V.Version + i = + Dict.diff (getTransitive constraints new (Dict.toList compare d) Dict.empty) d + + td : Dict ( String, String ) Pkg.Name V.Version + td = + if forTest then + Dict.intersection Pkg.compareName new (Dict.insert identity pkg V.one testDirect) + + else + Dict.intersection Pkg.compareName new (Dict.remove identity pkg testDirect) + + ti : Dict ( String, String ) Pkg.Name V.Version + ti = + Dict.diff new (Utils.mapUnions [ d, i, td ]) + in + SolverOk (AppSolution allDeps new (Outline.GuidaAppOutline guida srcDirs d i td ti)) + + ISBack _ -> + noSolution connection + + ISErr e -> + SolverErr e + ) + + Outline.ElmAppOutline elm srcDirs direct indirect testDirect testIndirect -> + Stuff.withRegistryLock cache <| + let + allIndirects : Dict ( String, String ) Pkg.Name V.Version + allIndirects = + Dict.union indirect testIndirect + + allDirects : Dict ( String, String ) Pkg.Name V.Version + allDirects = + Dict.union direct testDirect + + allDeps : Dict ( String, String ) Pkg.Name V.Version + allDeps = + Dict.union allDirects allIndirects + + attempt : (a -> C.Constraint) -> Dict ( String, String ) Pkg.Name a -> Solver (Dict ( String, String ) Pkg.Name V.Version) + attempt toConstraint deps = + try (Dict.insert identity pkg C.anything (Dict.map (\_ -> toConstraint) deps)) + in + case + oneOf + (attempt C.exactly allDeps) + [ attempt C.exactly allDirects + , attempt C.untilNextMinor allDirects + , attempt C.untilNextMajor allDirects + , attempt (\_ -> C.anything) allDirects + ] + of + Solver solver -> + solver (State cache connection registry Dict.empty) + |> Task.fmap + (\result -> + case result of + ISOk (State _ _ _ constraints) new -> + let + d : Dict ( String, String ) Pkg.Name V.Version + d = + if forTest then + Dict.intersection Pkg.compareName new direct + + else + Dict.intersection Pkg.compareName new (Dict.insert identity pkg V.one direct) + + i : Dict ( String, String ) Pkg.Name V.Version + i = + Dict.diff (getTransitive constraints new (Dict.toList compare d) Dict.empty) d + + td : Dict ( String, String ) Pkg.Name V.Version + td = + if forTest then + Dict.intersection Pkg.compareName new (Dict.insert identity pkg V.one testDirect) + + else + Dict.intersection Pkg.compareName new (Dict.remove identity pkg testDirect) + + ti : Dict ( String, String ) Pkg.Name V.Version + ti = + Dict.diff new (Utils.mapUnions [ d, i, td ]) + in + SolverOk (AppSolution allDeps new (Outline.ElmAppOutline elm srcDirs d i td ti)) + + ISBack _ -> + noSolution connection + + ISErr e -> + SolverErr e + ) @@ -235,65 +305,127 @@ addToApp cache connection registry pkg (Outline.AppOutline elm srcDirs direct in addToTestApp : Stuff.PackageCache -> Connection -> Registry.Registry -> Pkg.Name -> C.Constraint -> Outline.AppOutline -> Task Never (SolverResult AppSolution) -addToTestApp cache connection registry pkg con (Outline.AppOutline elm srcDirs direct indirect testDirect testIndirect) = - Stuff.withRegistryLock cache <| - let - allIndirects : Dict ( String, String ) Pkg.Name V.Version - allIndirects = - Dict.union indirect testIndirect - - allDirects : Dict ( String, String ) Pkg.Name V.Version - allDirects = - Dict.union direct testDirect - - allDeps : Dict ( String, String ) Pkg.Name V.Version - allDeps = - Dict.union allDirects allIndirects - - attempt : (a -> C.Constraint) -> Dict ( String, String ) Pkg.Name a -> Solver (Dict ( String, String ) Pkg.Name V.Version) - attempt toConstraint deps = - try (Dict.insert identity pkg con (Dict.map (\_ -> toConstraint) deps)) - in - case - oneOf - (attempt C.exactly allDeps) - [ attempt C.exactly allDirects - , attempt C.untilNextMinor allDirects - , attempt C.untilNextMajor allDirects - , attempt (\_ -> C.anything) allDirects - ] - of - Solver solver -> - solver (State cache connection registry Dict.empty) - |> Task.fmap - (\result -> - case result of - ISOk (State _ _ _ constraints) new -> - let - d : Dict ( String, String ) Pkg.Name V.Version - d = - Dict.intersection Pkg.compareName new (Dict.insert identity pkg V.one direct) - - i : Dict ( String, String ) Pkg.Name V.Version - i = - Dict.diff (getTransitive constraints new (Dict.toList compare d) Dict.empty) d - - td : Dict ( String, String ) Pkg.Name V.Version - td = - Dict.intersection Pkg.compareName new (Dict.remove identity pkg testDirect) - - ti : Dict ( String, String ) Pkg.Name V.Version - ti = - Dict.diff new (Utils.mapUnions [ d, i, td ]) - in - SolverOk (AppSolution allDeps new (Outline.AppOutline elm srcDirs d i td ti)) +addToTestApp cache connection registry pkg con outline = + case outline of + Outline.GuidaAppOutline guida srcDirs direct indirect testDirect testIndirect -> + Stuff.withRegistryLock cache <| + let + allIndirects : Dict ( String, String ) Pkg.Name V.Version + allIndirects = + Dict.union indirect testIndirect - ISBack _ -> - noSolution connection + allDirects : Dict ( String, String ) Pkg.Name V.Version + allDirects = + Dict.union direct testDirect - ISErr e -> - SolverErr e - ) + allDeps : Dict ( String, String ) Pkg.Name V.Version + allDeps = + Dict.union allDirects allIndirects + + attempt : (a -> C.Constraint) -> Dict ( String, String ) Pkg.Name a -> Solver (Dict ( String, String ) Pkg.Name V.Version) + attempt toConstraint deps = + try (Dict.insert identity pkg con (Dict.map (\_ -> toConstraint) deps)) + in + case + oneOf + (attempt C.exactly allDeps) + [ attempt C.exactly allDirects + , attempt C.untilNextMinor allDirects + , attempt C.untilNextMajor allDirects + , attempt (\_ -> C.anything) allDirects + ] + of + Solver solver -> + solver (State cache connection registry Dict.empty) + |> Task.fmap + (\result -> + case result of + ISOk (State _ _ _ constraints) new -> + let + d : Dict ( String, String ) Pkg.Name V.Version + d = + Dict.intersection Pkg.compareName new (Dict.insert identity pkg V.one direct) + + i : Dict ( String, String ) Pkg.Name V.Version + i = + Dict.diff (getTransitive constraints new (Dict.toList compare d) Dict.empty) d + + td : Dict ( String, String ) Pkg.Name V.Version + td = + Dict.intersection Pkg.compareName new (Dict.remove identity pkg testDirect) + + ti : Dict ( String, String ) Pkg.Name V.Version + ti = + Dict.diff new (Utils.mapUnions [ d, i, td ]) + in + SolverOk (AppSolution allDeps new (Outline.GuidaAppOutline guida srcDirs d i td ti)) + + ISBack _ -> + noSolution connection + + ISErr e -> + SolverErr e + ) + + Outline.ElmAppOutline elm srcDirs direct indirect testDirect testIndirect -> + Stuff.withRegistryLock cache <| + let + allIndirects : Dict ( String, String ) Pkg.Name V.Version + allIndirects = + Dict.union indirect testIndirect + + allDirects : Dict ( String, String ) Pkg.Name V.Version + allDirects = + Dict.union direct testDirect + + allDeps : Dict ( String, String ) Pkg.Name V.Version + allDeps = + Dict.union allDirects allIndirects + + attempt : (a -> C.Constraint) -> Dict ( String, String ) Pkg.Name a -> Solver (Dict ( String, String ) Pkg.Name V.Version) + attempt toConstraint deps = + try (Dict.insert identity pkg con (Dict.map (\_ -> toConstraint) deps)) + in + case + oneOf + (attempt C.exactly allDeps) + [ attempt C.exactly allDirects + , attempt C.untilNextMinor allDirects + , attempt C.untilNextMajor allDirects + , attempt (\_ -> C.anything) allDirects + ] + of + Solver solver -> + solver (State cache connection registry Dict.empty) + |> Task.fmap + (\result -> + case result of + ISOk (State _ _ _ constraints) new -> + let + d : Dict ( String, String ) Pkg.Name V.Version + d = + Dict.intersection Pkg.compareName new (Dict.insert identity pkg V.one direct) + + i : Dict ( String, String ) Pkg.Name V.Version + i = + Dict.diff (getTransitive constraints new (Dict.toList compare d) Dict.empty) d + + td : Dict ( String, String ) Pkg.Name V.Version + td = + Dict.intersection Pkg.compareName new (Dict.remove identity pkg testDirect) + + ti : Dict ( String, String ) Pkg.Name V.Version + ti = + Dict.diff new (Utils.mapUnions [ d, i, td ]) + in + SolverOk (AppSolution allDeps new (Outline.ElmAppOutline elm srcDirs d i td ti)) + + ISBack _ -> + noSolution connection + + ISErr e -> + SolverErr e + ) @@ -301,53 +433,103 @@ addToTestApp cache connection registry pkg con (Outline.AppOutline elm srcDirs d removeFromApp : Stuff.PackageCache -> Connection -> Registry.Registry -> Pkg.Name -> Outline.AppOutline -> Task Never (SolverResult AppSolution) -removeFromApp cache connection registry pkg (Outline.AppOutline elm srcDirs direct indirect testDirect testIndirect) = - Stuff.withRegistryLock cache <| - let - allDirects : Dict ( String, String ) Pkg.Name V.Version - allDirects = - Dict.union direct testDirect - in - case try (Dict.map (\_ -> C.exactly) (Dict.remove identity pkg allDirects)) of - Solver solver -> - solver (State cache connection registry Dict.empty) - |> Task.fmap - (\result -> - case result of - ISOk (State _ _ _ constraints) new -> - let - allIndirects : Dict ( String, String ) Pkg.Name V.Version - allIndirects = - Dict.union indirect testIndirect - - allDeps : Dict ( String, String ) Pkg.Name V.Version - allDeps = - Dict.union allDirects allIndirects - - d : Dict ( String, String ) Pkg.Name V.Version - d = - Dict.remove identity pkg direct - - i : Dict ( String, String ) Pkg.Name V.Version - i = - Dict.diff (getTransitive constraints new (Dict.toList compare d) Dict.empty) d - - td : Dict ( String, String ) Pkg.Name V.Version - td = - Dict.remove identity pkg testDirect - - ti : Dict ( String, String ) Pkg.Name V.Version - ti = - Dict.diff new (Utils.mapUnions [ d, i, td ]) - in - SolverOk (AppSolution allDeps new (Outline.AppOutline elm srcDirs d i td ti)) +removeFromApp cache connection registry pkg outline = + case outline of + Outline.GuidaAppOutline guida srcDirs direct indirect testDirect testIndirect -> + Stuff.withRegistryLock cache <| + let + allDirects : Dict ( String, String ) Pkg.Name V.Version + allDirects = + Dict.union direct testDirect + in + case try (Dict.map (\_ -> C.exactly) (Dict.remove identity pkg allDirects)) of + Solver solver -> + solver (State cache connection registry Dict.empty) + |> Task.fmap + (\result -> + case result of + ISOk (State _ _ _ constraints) new -> + let + allIndirects : Dict ( String, String ) Pkg.Name V.Version + allIndirects = + Dict.union indirect testIndirect + + allDeps : Dict ( String, String ) Pkg.Name V.Version + allDeps = + Dict.union allDirects allIndirects + + d : Dict ( String, String ) Pkg.Name V.Version + d = + Dict.remove identity pkg direct + + i : Dict ( String, String ) Pkg.Name V.Version + i = + Dict.diff (getTransitive constraints new (Dict.toList compare d) Dict.empty) d + + td : Dict ( String, String ) Pkg.Name V.Version + td = + Dict.remove identity pkg testDirect + + ti : Dict ( String, String ) Pkg.Name V.Version + ti = + Dict.diff new (Utils.mapUnions [ d, i, td ]) + in + SolverOk (AppSolution allDeps new (Outline.GuidaAppOutline guida srcDirs d i td ti)) + + ISBack _ -> + noSolution connection + + ISErr e -> + SolverErr e + ) + + Outline.ElmAppOutline elm srcDirs direct indirect testDirect testIndirect -> + Stuff.withRegistryLock cache <| + let + allDirects : Dict ( String, String ) Pkg.Name V.Version + allDirects = + Dict.union direct testDirect + in + case try (Dict.map (\_ -> C.exactly) (Dict.remove identity pkg allDirects)) of + Solver solver -> + solver (State cache connection registry Dict.empty) + |> Task.fmap + (\result -> + case result of + ISOk (State _ _ _ constraints) new -> + let + allIndirects : Dict ( String, String ) Pkg.Name V.Version + allIndirects = + Dict.union indirect testIndirect - ISBack _ -> - noSolution connection + allDeps : Dict ( String, String ) Pkg.Name V.Version + allDeps = + Dict.union allDirects allIndirects - ISErr e -> - SolverErr e - ) + d : Dict ( String, String ) Pkg.Name V.Version + d = + Dict.remove identity pkg direct + + i : Dict ( String, String ) Pkg.Name V.Version + i = + Dict.diff (getTransitive constraints new (Dict.toList compare d) Dict.empty) d + + td : Dict ( String, String ) Pkg.Name V.Version + td = + Dict.remove identity pkg testDirect + + ti : Dict ( String, String ) Pkg.Name V.Version + ti = + Dict.diff new (Utils.mapUnions [ d, i, td ]) + in + SolverOk (AppSolution allDeps new (Outline.ElmAppOutline elm srcDirs d i td ti)) + + ISBack _ -> + noSolution connection + + ISErr e -> + SolverErr e + ) @@ -490,6 +672,7 @@ getConstraints pkg vsn = path = home ++ "/elm.json" in + -- FIXME extend this to guida! File.exists path |> Task.bind (\outlineExists -> @@ -551,11 +734,15 @@ getConstraints pkg vsn = constraintsDecoder : D.Decoder () Constraints constraintsDecoder = - D.mapError (\_ -> ()) Outline.decoder + -- FIXME extend this to guida! + D.mapError (\_ -> ()) Outline.elmDecoder |> D.bind (\outline -> case outline of - Outline.Pkg (Outline.PkgOutline _ _ _ _ _ deps _ elmConstraint) -> + Outline.Pkg (Outline.GuidaPkgOutline _ _ _ _ _ deps _ elmConstraint) -> + D.pure (Constraints elmConstraint deps) + + Outline.Pkg (Outline.ElmPkgOutline _ _ _ _ _ deps _ elmConstraint) -> D.pure (Constraints elmConstraint deps) Outline.App _ -> diff --git a/src/Builder/Deps/Website.elm b/src/Builder/Deps/Website.elm index 7d2a65269..79f39ff47 100644 --- a/src/Builder/Deps/Website.elm +++ b/src/Builder/Deps/Website.elm @@ -1,11 +1,12 @@ module Builder.Deps.Website exposing - ( metadata + ( domain + , metadata , route ) import Builder.Http as Http -import Compiler.Elm.Package as Pkg -import Compiler.Elm.Version as V +import Compiler.Guida.Package as Pkg +import Compiler.Guida.Version as V import Task exposing (Task) import Utils.Main as Utils import Utils.Task.Extra as Task @@ -14,7 +15,7 @@ import Utils.Task.Extra as Task domain : Task Never String domain = Utils.envLookupEnv "GUIDA_REGISTRY" - |> Task.fmap (Maybe.withDefault "https://package.elm-lang.org") + |> Task.fmap (Maybe.withDefault "https://package.guida-lang.org") route : String -> List ( String, String ) -> Task Never String diff --git a/src/Builder/File.elm b/src/Builder/File.elm index 9e666654d..f4ea3b1dd 100644 --- a/src/Builder/File.elm +++ b/src/Builder/File.elm @@ -79,7 +79,7 @@ readBinary decoder path = , "| Byte Offset: " ++ String.fromInt offset , "| Message: " ++ message , "|" - , "| Please report this to https://github.com/elm/compiler/issues" + , "| Please report this to https://github.com/guida-lang/compiler/issues" , "| Trying to continue anyway." , "+-------------------------------------------------------------------------------" ] @@ -145,7 +145,7 @@ writeEntry destination root entry = String.startsWith "src/" path || (path == "LICENSE") || (path == "README.md") - || (path == "elm.json") + || (path == "guida.json") then if not (String.isEmpty path) && String.endsWith "/" path then Utils.dirCreateDirectoryIfMissing True (Utils.fpCombine destination path) diff --git a/src/Builder/Generate.elm b/src/Builder/Generate.elm index b1580657e..e6d58b494 100644 --- a/src/Builder/Generate.elm +++ b/src/Builder/Generate.elm @@ -6,18 +6,18 @@ module Builder.Generate exposing ) import Builder.Build as Build -import Builder.Elm.Details as Details -import Builder.Elm.Outline as Outline +import Builder.Guida.Details as Details +import Builder.Guida.Outline as Outline import Builder.File as File import Builder.Reporting.Exit as Exit import Builder.Stuff as Stuff import Compiler.AST.Optimized as Opt import Compiler.Data.Name as N import Compiler.Data.NonEmptyList as NE -import Compiler.Elm.Compiler.Type.Extract as Extract -import Compiler.Elm.Interface as I -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg +import Compiler.Guida.Compiler.Type.Extract as Extract +import Compiler.Guida.Interface as I +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg import Compiler.Generate.JavaScript as JS import Compiler.Generate.Mode as Mode import Compiler.Nitpick.Debug as Nitpick @@ -36,12 +36,12 @@ import Utils.Task.Extra as Task -- GENERATORS -debug : Bool -> Int -> FilePath -> Details.Details -> Build.Artifacts -> Task Exit.Generate String +debug : Bool -> Int -> Stuff.Root -> Details.Details -> Build.Artifacts -> Task Exit.Generate String debug withSourceMaps leadingLines root details (Build.Artifacts pkg ifaces roots modules) = - loadObjects root details modules + loadObjects (Stuff.rootPath root) details modules |> Task.bind (\loading -> - loadTypes root ifaces modules + loadTypes (Stuff.rootPath root) ifaces modules |> Task.bind (\types -> finalizeObjects loading @@ -67,9 +67,9 @@ debug withSourceMaps leadingLines root details (Build.Artifacts pkg ifaces roots ) -dev : Bool -> Int -> FilePath -> Details.Details -> Build.Artifacts -> Task Exit.Generate String +dev : Bool -> Int -> Stuff.Root -> Details.Details -> Build.Artifacts -> Task Exit.Generate String dev withSourceMaps leadingLines root details (Build.Artifacts pkg _ roots modules) = - Task.bind finalizeObjects (loadObjects root details modules) + Task.bind finalizeObjects (loadObjects (Stuff.rootPath root) details modules) |> Task.bind (\objects -> let @@ -90,9 +90,9 @@ dev withSourceMaps leadingLines root details (Build.Artifacts pkg _ roots module ) -prod : Bool -> Int -> FilePath -> Details.Details -> Build.Artifacts -> Task Exit.Generate String +prod : Bool -> Int -> Stuff.Root -> Details.Details -> Build.Artifacts -> Task Exit.Generate String prod withSourceMaps leadingLines root details (Build.Artifacts pkg _ roots modules) = - Task.bind finalizeObjects (loadObjects root details modules) + Task.bind finalizeObjects (loadObjects (Stuff.rootPath root) details modules) |> Task.bind (\objects -> checkForDebugUses objects @@ -117,7 +117,7 @@ prod withSourceMaps leadingLines root details (Build.Artifacts pkg _ roots modul ) -prepareSourceMaps : Bool -> FilePath -> Task Exit.Generate JS.SourceMaps +prepareSourceMaps : Bool -> Stuff.Root -> Task Exit.Generate JS.SourceMaps prepareSourceMaps withSourceMaps root = if withSourceMaps then Outline.getAllModulePaths root diff --git a/src/Builder/Elm/Details.elm b/src/Builder/Guida/Details.elm similarity index 87% rename from src/Builder/Elm/Details.elm rename to src/Builder/Guida/Details.elm index d0bc178b5..c542ba7cf 100644 --- a/src/Builder/Elm/Details.elm +++ b/src/Builder/Guida/Details.elm @@ -1,4 +1,4 @@ -module Builder.Elm.Details exposing +module Builder.Guida.Details exposing ( BuildID , Details(..) , Extras @@ -20,8 +20,8 @@ import Builder.BackgroundWriter as BW import Builder.Deps.Registry as Registry import Builder.Deps.Solver as Solver import Builder.Deps.Website as Website -import Builder.Elm.Outline as Outline import Builder.File as File +import Builder.Guida.Outline as Outline import Builder.Http as Http import Builder.Reporting as Reporting import Builder.Reporting.Exit as Exit @@ -33,13 +33,13 @@ import Compiler.Compile as Compile import Compiler.Data.Name as Name import Compiler.Data.NonEmptyList as NE import Compiler.Data.OneOrMore as OneOrMore -import Compiler.Elm.Constraint as Con -import Compiler.Elm.Docs as Docs -import Compiler.Elm.Interface as I -import Compiler.Elm.Kernel as Kernel -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg -import Compiler.Elm.Version as V +import Compiler.Guida.Constraint as Con +import Compiler.Guida.Docs as Docs +import Compiler.Guida.Interface as I +import Compiler.Guida.Kernel as Kernel +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg +import Compiler.Guida.Version as V import Compiler.Json.Decode as D import Compiler.Json.Encode as E import Compiler.Parse.Module as Parse @@ -134,9 +134,9 @@ loadInterfaces root (Details _ _ _ _ _ extras) = -- VERIFY INSTALL -- used by Install -verifyInstall : BW.Scope -> FilePath -> Solver.Env -> Outline.Outline -> Task Never (Result Exit.Details ()) +verifyInstall : BW.Scope -> Stuff.Root -> Solver.Env -> Outline.Outline -> Task Never (Result Exit.Details ()) verifyInstall scope root (Solver.Env cache manager connection registry) outline = - File.getTime (root ++ "/elm.json") + File.getTime (Stuff.rootProjectFilePath root) |> Task.bind (\time -> let @@ -161,12 +161,12 @@ verifyInstall scope root (Solver.Env cache manager connection registry) outline -- LOAD -- used by Make, Repl, Reactor, Test -load : Reporting.Style -> BW.Scope -> FilePath -> Task Never (Result Exit.Details Details) +load : Reporting.Style -> BW.Scope -> Stuff.Root -> Task Never (Result Exit.Details Details) load style scope root = - File.getTime (root ++ "/elm.json") + File.getTime (Stuff.rootProjectFilePath root) |> Task.bind (\newTime -> - File.readBinary detailsDecoder (Stuff.details root) + File.readBinary detailsDecoder (Stuff.details (Stuff.rootPath root)) |> Task.bind (\maybeDetails -> case maybeDetails of @@ -187,7 +187,7 @@ load style scope root = -- GENERATE -generate : Reporting.Style -> BW.Scope -> FilePath -> File.Time -> Task Never (Result Exit.Details Details) +generate : Reporting.Style -> BW.Scope -> Stuff.Root -> File.Time -> Task Never (Result Exit.Details Details) generate style scope root time = Reporting.trackDetails style (\key -> @@ -214,10 +214,10 @@ generate style scope root time = type Env - = Env Reporting.DKey BW.Scope FilePath Stuff.PackageCache Http.Manager Solver.Connection Registry.Registry + = Env Reporting.DKey BW.Scope Stuff.Root Stuff.PackageCache Http.Manager Solver.Connection Registry.Registry -initEnv : Reporting.DKey -> BW.Scope -> FilePath -> Task Never (Result Exit.Details ( Env, Outline.Outline )) +initEnv : Reporting.DKey -> BW.Scope -> Stuff.Root -> Task Never (Result Exit.Details ( Env, Outline.Outline )) initEnv key scope root = fork resultRegistryProblemEnvEncoder Solver.initEnv |> Task.bind @@ -249,59 +249,113 @@ initEnv key scope root = verifyPkg : Env -> File.Time -> Outline.PkgOutline -> Task Exit.Details Details -verifyPkg env time (Outline.PkgOutline pkg _ _ _ exposed direct testDirect elm) = - if Con.goodElm elm then - union identity Pkg.compareName noDups direct testDirect - |> Task.bind (verifyConstraints env) - |> Task.bind - (\solution -> - let - exposedList : List ModuleName.Raw - exposedList = - Outline.flattenExposed exposed - - exactDeps : Dict ( String, String ) Pkg.Name V.Version - exactDeps = - Dict.map (\_ (Solver.Details v _) -> v) solution - - -- for pkg docs in reactor - in - verifyDependencies env time (ValidPkg pkg exposedList exactDeps) solution direct - ) +verifyPkg env time outline = + case outline of + Outline.GuidaPkgOutline pkg _ _ _ exposed direct testDirect guida -> + if Con.goodGuida guida then + union identity Pkg.compareName noGuidaDups direct testDirect + |> Task.bind (verifyConstraints env) + |> Task.bind + (\solution -> + let + exposedList : List ModuleName.Raw + exposedList = + Outline.flattenExposed exposed + + exactDeps : Dict ( String, String ) Pkg.Name V.Version + exactDeps = + -- for pkg docs in reactor + Dict.map (\_ (Solver.Details v _) -> v) solution + in + verifyDependencies env time (ValidPkg pkg exposedList exactDeps) solution direct + ) - else - Task.throw (Exit.DetailsBadElmInPkg elm) + else + Task.throw (Exit.DetailsBadGuidaInPkg guida) + + Outline.ElmPkgOutline pkg _ _ _ exposed direct testDirect elm -> + if Con.goodElm elm then + union identity Pkg.compareName noElmDups direct testDirect + |> Task.bind (verifyConstraints env) + |> Task.bind + (\solution -> + let + exposedList : List ModuleName.Raw + exposedList = + Outline.flattenExposed exposed + + exactDeps : Dict ( String, String ) Pkg.Name V.Version + exactDeps = + -- for pkg docs in reactor + Dict.map (\_ (Solver.Details v _) -> v) solution + in + verifyDependencies env time (ValidPkg pkg exposedList exactDeps) solution direct + ) + + else + Task.throw (Exit.DetailsBadElmInPkg elm) verifyApp : Env -> File.Time -> Outline.AppOutline -> Task Exit.Details Details -verifyApp env time ((Outline.AppOutline elmVersion srcDirs direct _ _ _) as outline) = - if elmVersion == V.elmCompiler then - checkAppDeps outline - |> Task.bind - (\stated -> - verifyConstraints env (Dict.map (\_ -> Con.exactly) stated) - |> Task.bind - (\actual -> - if Dict.size stated == Dict.size actual then - verifyDependencies env time (ValidApp srcDirs) actual direct +verifyApp env time outline = + case outline of + Outline.GuidaAppOutline guidaVersion srcDirs direct _ _ _ -> + if guidaVersion == V.compiler then + checkAppDeps outline + |> Task.bind + (\stated -> + verifyConstraints env (Dict.map (\_ -> Con.exactly) stated) + |> Task.bind + (\actual -> + if Dict.size stated == Dict.size actual then + verifyDependencies env time (ValidApp srcDirs) actual direct + + else + Task.throw Exit.DetailsHandEditedGuidaDependencies + ) + ) - else - Task.throw Exit.DetailsHandEditedDependencies - ) - ) + else + Task.throw (Exit.DetailsBadGuidaInAppOutline guidaVersion) - else - Task.throw (Exit.DetailsBadElmInAppOutline elmVersion) + Outline.ElmAppOutline elmVersion srcDirs direct _ _ _ -> + if elmVersion == V.elmCompiler then + checkAppDeps outline + |> Task.bind + (\stated -> + verifyConstraints env (Dict.map (\_ -> Con.exactly) stated) + |> Task.bind + (\actual -> + if Dict.size stated == Dict.size actual then + verifyDependencies env time (ValidApp srcDirs) actual direct + + else + Task.throw Exit.DetailsHandEditedElmDependencies + ) + ) + + else + Task.throw (Exit.DetailsBadElmInAppOutline elmVersion) checkAppDeps : Outline.AppOutline -> Task Exit.Details (Dict ( String, String ) Pkg.Name V.Version) -checkAppDeps (Outline.AppOutline _ _ direct indirect testDirect testIndirect) = - union identity Pkg.compareName allowEqualDups indirect testDirect - |> Task.bind - (\x -> - union identity Pkg.compareName noDups direct testIndirect - |> Task.bind (\y -> union identity Pkg.compareName noDups x y) - ) +checkAppDeps outline = + case outline of + Outline.GuidaAppOutline _ _ direct indirect testDirect testIndirect -> + union identity Pkg.compareName allowEqualGuidaDups indirect testDirect + |> Task.bind + (\x -> + union identity Pkg.compareName noGuidaDups direct testIndirect + |> Task.bind (\y -> union identity Pkg.compareName noGuidaDups x y) + ) + + Outline.ElmAppOutline _ _ direct indirect testDirect testIndirect -> + union identity Pkg.compareName allowEqualElmDups indirect testDirect + |> Task.bind + (\x -> + union identity Pkg.compareName noElmDups direct testIndirect + |> Task.bind (\y -> union identity Pkg.compareName noElmDups x y) + ) @@ -309,7 +363,7 @@ checkAppDeps (Outline.AppOutline _ _ direct indirect testDirect testIndirect) = verifyConstraints : Env -> Dict ( String, String ) Pkg.Name Con.Constraint -> Task Exit.Details (Dict ( String, String ) Pkg.Name Solver.Details) -verifyConstraints (Env _ _ _ cache _ connection registry) constraints = +verifyConstraints (Env _ _ root cache _ connection registry) constraints = Task.io (Solver.verify cache connection registry constraints) |> Task.bind (\result -> @@ -318,10 +372,28 @@ verifyConstraints (Env _ _ _ cache _ connection registry) constraints = Task.pure details Solver.NoSolution -> - Task.throw Exit.DetailsNoSolution + Task.throw + (case root of + Stuff.GuidaRoot _ -> + Exit.DetailsNoGuidaSolution + + Stuff.ElmRoot _ -> + Exit.DetailsNoElmSolution + ) Solver.NoOfflineSolution -> - Task.throw Exit.DetailsNoOfflineSolution + Task.io Website.domain + |> Task.bind + (\registryDomain -> + Task.throw + (case root of + Stuff.GuidaRoot _ -> + Exit.DetailsNoGuidaOfflineSolution registryDomain + + Stuff.ElmRoot _ -> + Exit.DetailsNoElmOfflineSolution registryDomain + ) + ) Solver.SolverErr exit -> Task.throw (Exit.DetailsSolverProblem exit) @@ -346,18 +418,32 @@ union toComparable keyComparison tieBreaker deps1 deps2 = (Task.pure Dict.empty) -noDups : k -> v -> v -> Task Exit.Details v -noDups _ _ _ = - Task.throw Exit.DetailsHandEditedDependencies +noGuidaDups : k -> v -> v -> Task Exit.Details v +noGuidaDups _ _ _ = + Task.throw Exit.DetailsHandEditedGuidaDependencies + +noElmDups : k -> v -> v -> Task Exit.Details v +noElmDups _ _ _ = + Task.throw Exit.DetailsHandEditedElmDependencies -allowEqualDups : k -> v -> v -> Task Exit.Details v -allowEqualDups _ v1 v2 = + +allowEqualGuidaDups : k -> v -> v -> Task Exit.Details v +allowEqualGuidaDups _ v1 v2 = if v1 == v2 then Task.pure v1 else - Task.throw Exit.DetailsHandEditedDependencies + Task.throw Exit.DetailsHandEditedGuidaDependencies + + +allowEqualElmDups : k -> v -> v -> Task Exit.Details v +allowEqualElmDups _ v1 v2 = + if v1 == v2 then + Task.pure v1 + + else + Task.throw Exit.DetailsHandEditedElmDependencies @@ -397,7 +483,7 @@ verifyDependencies ((Env key scope root cache _ _ _) as env) time outline soluti (\deps -> case Utils.sequenceDictResult identity Pkg.compareName deps of Err _ -> - Stuff.getElmHome + Stuff.getGuidaHome |> Task.fmap (\home -> Err @@ -424,9 +510,9 @@ verifyDependencies ((Env key scope root cache _ _ _) as env) time outline soluti details = Details time outline 0 Dict.empty foreigns (ArtifactsFresh ifaces objs) in - BW.writeBinary Opt.globalGraphEncoder scope (Stuff.objects root) objs - |> Task.bind (\_ -> BW.writeBinary interfacesEncoder scope (Stuff.interfaces root) ifaces) - |> Task.bind (\_ -> BW.writeBinary detailsEncoder scope (Stuff.details root) details) + BW.writeBinary Opt.globalGraphEncoder scope (Stuff.objects (Stuff.rootPath root)) objs + |> Task.bind (\_ -> BW.writeBinary interfacesEncoder scope (Stuff.interfaces (Stuff.rootPath root)) ifaces) + |> Task.bind (\_ -> BW.writeBinary detailsEncoder scope (Stuff.details (Stuff.rootPath root)) details) |> Task.fmap (\_ -> Ok details) ) ) @@ -559,19 +645,13 @@ toComparableFingerprint fingerprint = build : Reporting.DKey -> Stuff.PackageCache -> MVar (Dict ( String, String ) Pkg.Name (MVar Dep)) -> Pkg.Name -> Solver.Details -> Fingerprint -> EverySet (List ( ( String, String ), ( Int, Int, Int ) )) Fingerprint -> Task Never Dep build key cache depsMVar pkg (Solver.Details vsn _) f fs = - Outline.read (Stuff.package cache pkg vsn) + -- FIXME hardcoded ElmRoot! + Outline.read (Stuff.ElmRoot (Stuff.package cache pkg vsn)) |> Task.bind (\eitherOutline -> - case eitherOutline of - Err _ -> - Reporting.report key Reporting.DBroken - |> Task.fmap (\_ -> Err (Just (Exit.BD_BadBuild pkg vsn f))) - - Ok (Outline.App _) -> - Reporting.report key Reporting.DBroken - |> Task.fmap (\_ -> Err (Just (Exit.BD_BadBuild pkg vsn f))) - - Ok (Outline.Pkg (Outline.PkgOutline _ _ _ _ exposed deps _ _)) -> + let + pkgBuild : Outline.Exposed -> Dict ( String, String ) Pkg.Name Con.Constraint -> Task Never Dep + pkgBuild exposed deps = Utils.readMVar dictPkgNameMVarDepDecoder depsMVar |> Task.bind (\allDeps -> @@ -667,6 +747,21 @@ build key cache depsMVar pkg (Solver.Details vsn _) f fs = ) ) ) + in + case eitherOutline of + Err _ -> + Reporting.report key Reporting.DBroken + |> Task.fmap (\_ -> Err (Just (Exit.BD_BadBuild pkg vsn f))) + + Ok (Outline.App _) -> + Reporting.report key Reporting.DBroken + |> Task.fmap (\_ -> Err (Just (Exit.BD_BadBuild pkg vsn f))) + + Ok (Outline.Pkg (Outline.GuidaPkgOutline _ _ _ _ exposed deps _ _)) -> + pkgBuild exposed deps + + Ok (Outline.Pkg (Outline.ElmPkgOutline _ _ _ _ exposed deps _ _)) -> + pkgBuild exposed deps ) @@ -700,7 +795,7 @@ gatherInterfaces exposed artifacts = let onLeft : a -> b -> c -> d onLeft _ _ _ = - crash "compiler bug manifesting in Elm.Details.gatherInterfaces" + crash "compiler bug manifesting in Guida.Details.gatherInterfaces" onBoth : comparable -> () -> DResult -> Dict comparable comparable I.DependencyInterface -> Dict comparable comparable I.DependencyInterface onBoth k () iface = diff --git a/src/Builder/Elm/Outline.elm b/src/Builder/Guida/Outline.elm similarity index 59% rename from src/Builder/Elm/Outline.elm rename to src/Builder/Guida/Outline.elm index b2eb1dcb7..d8e4fdf44 100644 --- a/src/Builder/Elm/Outline.elm +++ b/src/Builder/Guida/Outline.elm @@ -1,14 +1,15 @@ -module Builder.Elm.Outline exposing +module Builder.Guida.Outline exposing ( AppOutline(..) , Decoder , Exposed(..) , Outline(..) , PkgOutline(..) , SrcDir(..) - , decoder , defaultSummary + , elmDecoder , flattenExposed , getAllModulePaths + , guidaDecoder , read , srcDirDecoder , srcDirEncoder @@ -22,11 +23,11 @@ import Builder.Stuff as Stuff import Compiler.Data.Name as Name import Compiler.Data.NonEmptyList as NE import Compiler.Data.OneOrMore as OneOrMore -import Compiler.Elm.Constraint as Con -import Compiler.Elm.Licenses as Licenses -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg -import Compiler.Elm.Version as V +import Compiler.Guida.Constraint as Con +import Compiler.Guida.Licenses as Licenses +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg +import Compiler.Guida.Version as V import Compiler.Json.Decode as D import Compiler.Json.Encode as E import Compiler.Parse.Primitives as P @@ -49,11 +50,13 @@ type Outline type AppOutline - = AppOutline V.Version (NE.Nonempty SrcDir) (Dict ( String, String ) Pkg.Name V.Version) (Dict ( String, String ) Pkg.Name V.Version) (Dict ( String, String ) Pkg.Name V.Version) (Dict ( String, String ) Pkg.Name V.Version) + = GuidaAppOutline V.Version (NE.Nonempty SrcDir) (Dict ( String, String ) Pkg.Name V.Version) (Dict ( String, String ) Pkg.Name V.Version) (Dict ( String, String ) Pkg.Name V.Version) (Dict ( String, String ) Pkg.Name V.Version) + | ElmAppOutline V.Version (NE.Nonempty SrcDir) (Dict ( String, String ) Pkg.Name V.Version) (Dict ( String, String ) Pkg.Name V.Version) (Dict ( String, String ) Pkg.Name V.Version) (Dict ( String, String ) Pkg.Name V.Version) type PkgOutline - = PkgOutline Pkg.Name String Licenses.License V.Version Exposed (Dict ( String, String ) Pkg.Name Con.Constraint) (Dict ( String, String ) Pkg.Name Con.Constraint) Con.Constraint + = GuidaPkgOutline Pkg.Name String Licenses.License V.Version Exposed (Dict ( String, String ) Pkg.Name Con.Constraint) (Dict ( String, String ) Pkg.Name Con.Constraint) Con.Constraint + | ElmPkgOutline Pkg.Name String Licenses.License V.Version Exposed (Dict ( String, String ) Pkg.Name Con.Constraint) (Dict ( String, String ) Pkg.Name Con.Constraint) Con.Constraint type Exposed @@ -93,9 +96,9 @@ flattenExposed exposed = -- WRITE -write : FilePath -> Outline -> Task Never () +write : Stuff.Root -> Outline -> Task Never () write root outline = - E.write (root ++ "/elm.json") (encode outline) + E.write (Stuff.rootProjectFilePath root) (encode outline) @@ -105,7 +108,26 @@ write root outline = encode : Outline -> E.Value encode outline = case outline of - App (AppOutline elm srcDirs depsDirect depsTrans testDirect testTrans) -> + App (GuidaAppOutline guida srcDirs depsDirect depsTrans testDirect testTrans) -> + E.object + [ ( "type", E.string "application" ) + , ( "source-directories", E.list encodeSrcDir (NE.toList srcDirs) ) + , ( "guida-version", V.encode guida ) + , ( "dependencies" + , E.object + [ ( "direct", encodeDeps V.encode depsDirect ) + , ( "indirect", encodeDeps V.encode depsTrans ) + ] + ) + , ( "test-dependencies" + , E.object + [ ( "direct", encodeDeps V.encode testDirect ) + , ( "indirect", encodeDeps V.encode testTrans ) + ] + ) + ] + + App (ElmAppOutline elm srcDirs depsDirect depsTrans testDirect testTrans) -> E.object [ ( "type", E.string "application" ) , ( "source-directories", E.list encodeSrcDir (NE.toList srcDirs) ) @@ -124,7 +146,20 @@ encode outline = ) ] - Pkg (PkgOutline name summary license version exposed deps tests elm) -> + Pkg (GuidaPkgOutline name summary license version exposed deps tests guida) -> + E.object + [ ( "type", E.string "package" ) + , ( "name", Pkg.encode name ) + , ( "summary", E.string summary ) + , ( "license", Licenses.encode license ) + , ( "version", V.encode version ) + , ( "exposed-modules", encodeExposed exposed ) + , ( "guida-version", Con.encode guida ) + , ( "dependencies", encodeDeps Con.encode deps ) + , ( "test-dependencies", encodeDeps Con.encode tests ) + ] + + Pkg (ElmPkgOutline name summary license version exposed deps tests elm) -> E.object [ ( "type", E.string "package" ) , ( "name", Pkg.encode name ) @@ -172,31 +207,81 @@ encodeSrcDir srcDir = -- PARSE AND VERIFY -read : FilePath -> Task Never (Result Exit.Outline Outline) +read : Stuff.Root -> Task Never (Result Exit.Outline Outline) read root = - File.readUtf8 (root ++ "/elm.json") + File.readUtf8 (Stuff.rootProjectFilePath root) |> Task.bind (\bytes -> + let + decoder = + case root of + Stuff.GuidaRoot _ -> + guidaDecoder + + Stuff.ElmRoot _ -> + elmDecoder + in case D.fromByteString decoder bytes of Err err -> - Task.pure <| Err (Exit.OutlineHasBadStructure err) + case root of + Stuff.GuidaRoot _ -> + Task.pure <| Err (Exit.OutlineHasBadGuidaStructure err) + + Stuff.ElmRoot _ -> + Task.pure <| Err (Exit.OutlineHasBadElmStructure err) Ok outline -> case outline of - Pkg (PkgOutline pkg _ _ _ _ deps _ _) -> + Pkg (GuidaPkgOutline pkg _ _ _ _ deps _ _) -> + Task.pure <| + if not (Dict.member identity Pkg.core deps) && pkg /= Pkg.core then + Err Exit.OutlineNoGuidaPkgCore + + else + Ok outline + + Pkg (ElmPkgOutline pkg _ _ _ _ deps _ _) -> Task.pure <| if not (Dict.member identity Pkg.core deps) && pkg /= Pkg.core then - Err Exit.OutlineNoPkgCore + Err Exit.OutlineNoElmPkgCore else Ok outline - App (AppOutline _ srcDirs direct indirect _ _) -> + App (GuidaAppOutline _ srcDirs direct indirect _ _) -> + if not (Dict.member identity Pkg.core direct) then + Task.pure <| Err Exit.OutlineNoGuidaAppCore + + else if not (Dict.member identity Pkg.json direct) && not (Dict.member identity Pkg.json indirect) then + Task.pure <| Err Exit.OutlineNoGuidaAppJson + + else + Utils.filterM (isSrcDirMissing root) (NE.toList srcDirs) + |> Task.bind + (\badDirs -> + case List.map toGiven badDirs of + d :: ds -> + Task.pure <| Err (Exit.OutlineHasMissingSrcDirs d ds) + + [] -> + detectDuplicates (Stuff.rootPath root) (NE.toList srcDirs) + |> Task.bind + (\maybeDups -> + case maybeDups of + Nothing -> + Task.pure <| Ok outline + + Just ( canonicalDir, ( dir1, dir2 ) ) -> + Task.pure <| Err (Exit.OutlineHasDuplicateSrcDirs canonicalDir dir1 dir2) + ) + ) + + App (ElmAppOutline _ srcDirs direct indirect _ _) -> if not (Dict.member identity Pkg.core direct) then - Task.pure <| Err Exit.OutlineNoAppCore + Task.pure <| Err Exit.OutlineNoElmAppCore else if not (Dict.member identity Pkg.json direct) && not (Dict.member identity Pkg.json indirect) then - Task.pure <| Err Exit.OutlineNoAppJson + Task.pure <| Err Exit.OutlineNoElmAppJson else Utils.filterM (isSrcDirMissing root) (NE.toList srcDirs) @@ -207,7 +292,7 @@ read root = Task.pure <| Err (Exit.OutlineHasMissingSrcDirs d ds) [] -> - detectDuplicates root (NE.toList srcDirs) + detectDuplicates (Stuff.rootPath root) (NE.toList srcDirs) |> Task.bind (\maybeDups -> case maybeDups of @@ -221,9 +306,9 @@ read root = ) -isSrcDirMissing : FilePath -> SrcDir -> Task Never Bool +isSrcDirMissing : Stuff.Root -> SrcDir -> Task Never Bool isSrcDirMissing root srcDir = - Task.fmap not (Utils.dirDoesDirectoryExist (toAbsolute root srcDir)) + Task.fmap not (Utils.dirDoesDirectoryExist (toAbsolute (Stuff.rootPath root) srcDir)) toGiven : SrcDir -> FilePath @@ -280,7 +365,7 @@ isDup paths = -- GET ALL MODULE PATHS -getAllModulePaths : FilePath -> Task Never (Dict (List String) TypeCheck.Canonical FilePath) +getAllModulePaths : Stuff.Root -> Task Never (Dict (List String) TypeCheck.Canonical FilePath) getAllModulePaths root = read root |> Task.bind @@ -290,8 +375,8 @@ getAllModulePaths root = Task.pure Dict.empty Ok outline -> - case outline of - App (AppOutline _ srcDirs depsDirect indirect _ _) -> + let + getAllAppModulePaths srcDirs depsDirect indirect = let deps : Dict ( String, String ) Pkg.Name V.Version deps = @@ -299,17 +384,30 @@ getAllModulePaths root = absoluteSrcDirs : List FilePath absoluteSrcDirs = - List.map (toAbsolute root) (NE.toList srcDirs) + List.map (toAbsolute (Stuff.rootPath root)) (NE.toList srcDirs) in getAllModulePathsHelper Pkg.dummyName absoluteSrcDirs deps - Pkg (PkgOutline name _ _ _ _ pkgDeps _ _) -> + getAllPkgModulePaths name pkgDeps = let deps : Dict ( String, String ) Pkg.Name V.Version deps = Dict.map (\_ -> Con.lowerBound) pkgDeps in - getAllModulePathsHelper name [ root ++ "/src" ] deps + getAllModulePathsHelper name [ Stuff.rootPath root ++ "/src" ] deps + in + case outline of + App (GuidaAppOutline _ srcDirs depsDirect indirect _ _) -> + getAllAppModulePaths srcDirs depsDirect indirect + + App (ElmAppOutline _ srcDirs depsDirect indirect _ _) -> + getAllAppModulePaths srcDirs depsDirect indirect + + Pkg (GuidaPkgOutline name _ _ _ _ pkgDeps _ _) -> + getAllPkgModulePaths name pkgDeps + + Pkg (ElmPkgOutline name _ _ _ _ pkgDeps _ _) -> + getAllPkgModulePaths name pkgDeps ) @@ -392,52 +490,83 @@ type alias Decoder a = D.Decoder Exit.OutlineProblem a -decoder : Decoder Outline -decoder = - let - application : String - application = - "application" +guidaDecoder : Decoder Outline +guidaDecoder = + D.field "type" D.string + |> D.bind + (\tipe -> + if tipe == "application" then + D.fmap App guidaAppDecoder + + else if tipe == "package" then + D.fmap Pkg guidaPkgDecoder + + else + D.failure Exit.OP_BadType + ) + + +guidaAppDecoder : Decoder AppOutline +guidaAppDecoder = + D.pure GuidaAppOutline + |> D.apply (D.field "guida-version" versionDecoder) + |> D.apply (D.field "source-directories" dirsDecoder) + |> D.apply (D.field "dependencies" (D.field "direct" (guidaDepsDecoder versionDecoder))) + |> D.apply (D.field "dependencies" (D.field "indirect" (guidaDepsDecoder versionDecoder))) + |> D.apply (D.field "test-dependencies" (D.field "direct" (guidaDepsDecoder versionDecoder))) + |> D.apply (D.field "test-dependencies" (D.field "indirect" (guidaDepsDecoder versionDecoder))) + - package : String - package = - "package" - in +guidaPkgDecoder : Decoder PkgOutline +guidaPkgDecoder = + D.pure GuidaPkgOutline + |> D.apply (D.field "name" nameDecoder) + |> D.apply (D.field "summary" summaryDecoder) + |> D.apply (D.field "license" (Licenses.decoder Exit.OP_BadLicense)) + |> D.apply (D.field "version" versionDecoder) + |> D.apply (D.field "exposed-modules" exposedDecoder) + |> D.apply (D.field "dependencies" (guidaDepsDecoder constraintDecoder)) + |> D.apply (D.field "test-dependencies" (guidaDepsDecoder constraintDecoder)) + |> D.apply (D.field "guida-version" constraintDecoder) + + +elmDecoder : Decoder Outline +elmDecoder = D.field "type" D.string |> D.bind (\tipe -> - if tipe == application then - D.fmap App appDecoder + if tipe == "application" then + D.fmap App elmAppDecoder - else if tipe == package then - D.fmap Pkg pkgDecoder + else if tipe == "package" then + D.fmap Pkg elmPkgDecoder else D.failure Exit.OP_BadType ) -appDecoder : Decoder AppOutline -appDecoder = - D.pure AppOutline +elmAppDecoder : Decoder AppOutline +elmAppDecoder = + D.pure ElmAppOutline |> D.apply (D.field "elm-version" versionDecoder) |> D.apply (D.field "source-directories" dirsDecoder) - |> D.apply (D.field "dependencies" (D.field "direct" (depsDecoder versionDecoder))) - |> D.apply (D.field "dependencies" (D.field "indirect" (depsDecoder versionDecoder))) - |> D.apply (D.field "test-dependencies" (D.field "direct" (depsDecoder versionDecoder))) - |> D.apply (D.field "test-dependencies" (D.field "indirect" (depsDecoder versionDecoder))) + |> D.apply (D.field "dependencies" (D.field "direct" (elmDepsDecoder versionDecoder))) + |> D.apply (D.field "dependencies" (D.field "indirect" (elmDepsDecoder versionDecoder))) + |> D.apply (D.field "test-dependencies" (D.field "direct" (elmDepsDecoder versionDecoder))) + |> D.apply (D.field "test-dependencies" (D.field "indirect" (elmDepsDecoder versionDecoder))) -pkgDecoder : Decoder PkgOutline -pkgDecoder = - D.pure PkgOutline +elmPkgDecoder : Decoder PkgOutline +elmPkgDecoder = + D.pure ElmPkgOutline |> D.apply (D.field "name" nameDecoder) |> D.apply (D.field "summary" summaryDecoder) |> D.apply (D.field "license" (Licenses.decoder Exit.OP_BadLicense)) |> D.apply (D.field "version" versionDecoder) |> D.apply (D.field "exposed-modules" exposedDecoder) - |> D.apply (D.field "dependencies" (depsDecoder constraintDecoder)) - |> D.apply (D.field "test-dependencies" (depsDecoder constraintDecoder)) + |> D.apply (D.field "dependencies" (elmDepsDecoder constraintDecoder)) + |> D.apply (D.field "test-dependencies" (elmDepsDecoder constraintDecoder)) |> D.apply (D.field "elm-version" constraintDecoder) @@ -467,9 +596,14 @@ constraintDecoder = D.mapError Exit.OP_BadConstraint Con.decoder -depsDecoder : Decoder a -> Decoder (Dict ( String, String ) Pkg.Name a) -depsDecoder valueDecoder = - D.dict identity (Pkg.keyDecoder Exit.OP_BadDependencyName) valueDecoder +guidaDepsDecoder : Decoder a -> Decoder (Dict ( String, String ) Pkg.Name a) +guidaDepsDecoder valueDecoder = + D.dict identity (Pkg.keyDecoder Exit.OP_BadGuidaDependencyName) valueDecoder + + +elmDepsDecoder : Decoder a -> Decoder (Dict ( String, String ) Pkg.Name a) +elmDepsDecoder valueDecoder = + D.dict identity (Pkg.keyDecoder Exit.OP_BadElmDependencyName) valueDecoder dirsDecoder : Decoder (NE.Nonempty SrcDir) diff --git a/src/Builder/Http.elm b/src/Builder/Http.elm index 518ac7a7f..c7b8911e2 100644 --- a/src/Builder/Http.elm +++ b/src/Builder/Http.elm @@ -23,7 +23,7 @@ module Builder.Http exposing import Basics.Extra exposing (uncurry) import Codec.Archive.Zip as Zip -import Compiler.Elm.Version as V +import Compiler.Guida.Version as V import Http import Json.Decode as Decode import Json.Encode as Encode @@ -124,7 +124,7 @@ addDefaultHeaders headers = userAgent : String userAgent = - "elm/" ++ V.toChars V.compiler + "guida/" ++ V.toChars V.compiler accept : String -> Header diff --git a/src/Builder/Reporting.elm b/src/Builder/Reporting.elm index e77b40cca..7d3c835f6 100644 --- a/src/Builder/Reporting.elm +++ b/src/Builder/Reporting.elm @@ -21,9 +21,9 @@ module Builder.Reporting exposing import Builder.Reporting.Exit as Exit import Builder.Reporting.Exit.Help as Help import Compiler.Data.NonEmptyList as NE -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg -import Compiler.Elm.Version as V +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg +import Compiler.Guida.Version as V import Compiler.Json.Encode as Encode import Compiler.Reporting.Doc as D import System.Exit as Exit diff --git a/src/Builder/Reporting/Exit.elm b/src/Builder/Reporting/Exit.elm index cdefd7837..b81ff97e9 100644 --- a/src/Builder/Reporting/Exit.elm +++ b/src/Builder/Reporting/Exit.elm @@ -46,11 +46,11 @@ import Builder.Http as Http import Builder.Reporting.Exit.Help as Help import Compiler.Data.Name as N import Compiler.Data.NonEmptyList as NE -import Compiler.Elm.Constraint as C -import Compiler.Elm.Magnitude as M -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg -import Compiler.Elm.Version as V +import Compiler.Guida.Constraint as C +import Compiler.Guida.Magnitude as M +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg +import Compiler.Guida.Version as V import Compiler.Json.Decode as Decode import Compiler.Json.Encode as Encode import Compiler.Parse.Primitives exposing (Col, Row) @@ -87,7 +87,7 @@ toJson report = type Init = InitNoSolution (List Pkg.Name) - | InitNoOfflineSolution (List Pkg.Name) + | InitNoOfflineSolution String (List Pkg.Name) | InitSolverProblem Solver | InitAlreadyExists | InitRegistryProblem RegistryProblem @@ -99,21 +99,21 @@ initToReport exit = InitNoSolution pkgs -> Help.report "NO SOLUTION" Nothing - "I tried to create an elm.json with the following direct dependencies:" + "I tried to create a guida.json with the following direct dependencies:" [ D.indent 4 <| D.vcat <| List.map (D.dullyellow << D.fromChars << Pkg.toChars) pkgs - , D.reflow "I could not find compatible versions though! This should not happen, so please ask around one of the community forums at https://elm-lang.org/community to learn what is going on!" + , D.reflow "I could not find compatible versions though! This should not happen, so please ask around one of the community forums at https://guida-lang.org/community to learn what is going on!" ] - InitNoOfflineSolution pkgs -> + InitNoOfflineSolution registry pkgs -> Help.report "NO OFFLINE SOLUTION" Nothing - "I tried to create an elm.json with the following direct dependencies:" + "I tried to create an guida.json with the following direct dependencies:" [ D.indent 4 <| D.vcat <| List.map (D.dullyellow << D.fromChars << Pkg.toChars) pkgs - , D.reflow "I could not find compatible versions though, but that may be because I could not connect to https://package.elm-lang.org to get the latest list of packages. Are you able to connect to the internet? Please ask around one of the community forums at https://elm-lang.org/community for help!" + , D.reflow ("I could not find compatible versions though, but that may be because I could not connect to " ++ registry ++ " to get the latest list of packages. Are you able to connect to the internet? Please ask around one of the community forums at https://guida-lang.org/community for help!") ] InitSolverProblem solver -> @@ -122,7 +122,7 @@ initToReport exit = InitAlreadyExists -> Help.report "EXISTING PROJECT" Nothing - "You already have an elm.json file, so there is nothing for me to initialize!" + "You already have a guida.json file, so there is nothing for me to initialize!" [ D.fillSep [ D.fromChars "Maybe" , D.green (D.fromChars (D.makeLink "init")) @@ -150,10 +150,12 @@ initToReport exit = type Diff = DiffNoOutline | DiffBadOutline Outline - | DiffApplication - | DiffNoExposed + | DiffGuidaApplication + | DiffElmApplication + | DiffGuidaNoExposed + | DiffElmNoExposed | DiffUnpublished - | DiffUnknownPackage Pkg.Name (List Pkg.Name) + | DiffUnknownPackage String Pkg.Name (List Pkg.Name) | DiffUnknownVersion V.Version (List V.Version) | DiffDocsProblem V.Version DocsProblem | DiffMustHaveLatestRegistry RegistryProblem @@ -167,28 +169,42 @@ diffToReport diff = DiffNoOutline -> Help.report "DIFF WHAT?" Nothing - "I cannot find an elm.json so I am not sure what you want me to diff. Normally you run `elm diff` from within a project!" + "I cannot find a guida.json (or elm.json) so I am not sure what you want me to diff. Normally you run `guida diff` from within a project!" [ D.reflow <| "If you are just curious to see a diff, try running this command:" - , D.indent 4 <| D.green <| D.fromChars "elm diff elm/http 1.0.0 2.0.0" + , D.indent 4 <| D.green <| D.fromChars "guida diff elm/json 1.0.0 1.1.4" ] DiffBadOutline outline -> toOutlineReport outline - DiffApplication -> + DiffGuidaApplication -> + Help.report "CANNOT DIFF APPLICATIONS" + (Just "guida.json") + "Your guida.json says this project is an application, but `guida diff` only works with packages. That way there are previously published versions of the API to diff against!" + [ D.reflow <| "If you are just curious to see a diff, try running this command:" + , D.indent 4 <| D.dullyellow <| D.fromChars "guida diff elm/json 1.0.0 1.1.2" + ] + + DiffElmApplication -> Help.report "CANNOT DIFF APPLICATIONS" (Just "elm.json") - "Your elm.json says this project is an application, but `elm diff` only works with packages. That way there are previously published versions of the API to diff against!" + "Your elm.json says this project is an application, but `guida diff` only works with packages. That way there are previously published versions of the API to diff against!" [ D.reflow <| "If you are just curious to see a diff, try running this command:" - , D.indent 4 <| D.dullyellow <| D.fromChars "elm diff elm/json 1.0.0 1.1.2" + , D.indent 4 <| D.dullyellow <| D.fromChars "guida diff elm/json 1.0.0 1.1.2" + ] + + DiffGuidaNoExposed -> + Help.report "NO EXPOSED MODULES" + (Just "guida.json") + "Your guida.json has no \"exposed-modules\" which means there is no public API at all right now! What am I supposed to diff?" + [ D.reflow "Try adding some modules back to the \"exposed-modules\" field." ] - DiffNoExposed -> + DiffElmNoExposed -> Help.report "NO EXPOSED MODULES" (Just "elm.json") "Your elm.json has no \"exposed-modules\" which means there is no public API at all right now! What am I supposed to diff?" - [ D.reflow <| - "Try adding some modules back to the \"exposed-modules\" field." + [ D.reflow "Try adding some modules back to the \"exposed-modules\" field." ] DiffUnpublished -> @@ -197,14 +213,14 @@ diffToReport diff = "This package is not published yet. There is nothing to diff against!" [] - DiffUnknownPackage pkg suggestions -> + DiffUnknownPackage registry pkg suggestions -> Help.report "UNKNOWN PACKAGE" Nothing "I cannot find a package called:" [ D.indent 4 <| D.red <| D.fromChars <| Pkg.toChars pkg , D.fromChars "Maybe you want one of these instead?" , D.indent 4 <| D.dullyellow <| D.vcat <| List.map (D.fromChars << Pkg.toChars) suggestions - , D.fromChars "But check to see all possibilities!" + , D.fromChars ("But check <" ++ registry ++ "> to see all possibilities!") ] DiffUnknownVersion vsn realVersions -> @@ -266,12 +282,15 @@ diffToReport diff = type Bump = BumpNoOutline | BumpBadOutline Outline - | BumpApplication - | BumpUnexpectedVersion V.Version (List V.Version) + | BumpGuidaApplication String + | BumpElmApplication String + | BumpGuidaUnexpectedVersion String V.Version (List V.Version) + | BumpElmUnexpectedVersion String V.Version (List V.Version) | BumpMustHaveLatestRegistry RegistryProblem | BumpCannotFindDocs V.Version DocsProblem | BumpBadDetails Details - | BumpNoExposed + | BumpGuidaNoExposed + | BumpElmNoExposed | BumpBadBuild BuildProblem @@ -281,21 +300,98 @@ bumpToReport bump = BumpNoOutline -> Help.report "BUMP WHAT?" Nothing - "I cannot find an elm.json so I am not sure what you want me to bump." + "I cannot find a guida.json so I am not sure what you want me to bump." [ D.reflow <| - "Elm packages always have an elm.json that says the current version number. If you run this command from a directory with an elm.json file, I will try to bump the version in there based on the API changes." + "Guida packages always have an guida.json that says the current version number. If you run this command from a directory with a guida.json file, I will try to bump the version in there based on the API changes." ] BumpBadOutline outline -> toOutlineReport outline - BumpApplication -> + BumpGuidaApplication registry -> + Help.report "CANNOT BUMP APPLICATIONS" + (Just "guida.json") + ("Your guida.json says this is an application. That means it cannot be published on <" ++ registry ++ "> and therefore has no version to bump!") + [] + + BumpElmApplication registry -> Help.report "CANNOT BUMP APPLICATIONS" (Just "elm.json") - "Your elm.json says this is an application. That means it cannot be published on and therefore has no version to bump!" + ("Your elm.json says this is an application. That means it cannot be published on <" ++ registry ++ "> and therefore has no version to bump!") [] - BumpUnexpectedVersion vsn versions -> + BumpGuidaUnexpectedVersion registryDomain vsn versions -> + Help.docReport "CANNOT BUMP" + (Just "guida.json") + (D.fillSep + [ D.fromChars "Your" + , D.fromChars "guida.json" + , D.fromChars "says" + , D.fromChars "I" + , D.fromChars "should" + , D.fromChars "bump" + , D.fromChars "relative" + , D.fromChars "to" + , D.fromChars "version" + , D.red (D.fromVersion vsn) + |> D.a (D.fromChars ",") + , D.fromChars "but" + , D.fromChars "I" + , D.fromChars "cannot" + , D.fromChars "find" + , D.fromChars "that" + , D.fromChars "version" + , D.fromChars "on" + , D.fromChars ("<" ++ registryDomain ++ ">.") + , D.fromChars "That" + , D.fromChars "means" + , D.fromChars "there" + , D.fromChars "is" + , D.fromChars "no" + , D.fromChars "API" + , D.fromChars "for" + , D.fromChars "me" + , D.fromChars "to" + , D.fromChars "diff" + , D.fromChars "against" + , D.fromChars "and" + , D.fromChars "figure" + , D.fromChars "out" + , D.fromChars "if" + , D.fromChars "these" + , D.fromChars "are" + , D.fromChars "MAJOR," + , D.fromChars "MINOR," + , D.fromChars "or" + , D.fromChars "PATCH" + , D.fromChars "changes." + ] + ) + [ D.fillSep <| + [ D.fromChars "Try" + , D.fromChars "bumping" + , D.fromChars "again" + , D.fromChars "after" + , D.fromChars "changing" + , D.fromChars "the" + , D.dullyellow (D.fromChars "\"version\"") + , D.fromChars "in" + , D.fromChars "guida.json" + ] + ++ (if List.length versions == 1 then + [ D.fromChars "to:" ] + + else + [ D.fromChars "to" + , D.fromChars "one" + , D.fromChars "of" + , D.fromChars "these:" + ] + ) + , D.vcat <| List.map (D.green << D.fromVersion) versions + ] + + BumpElmUnexpectedVersion registryDomain vsn versions -> Help.docReport "CANNOT BUMP" (Just "elm.json") (D.fillSep @@ -317,7 +413,7 @@ bumpToReport bump = , D.fromChars "that" , D.fromChars "version" , D.fromChars "on" - , D.fromChars "." + , D.fromChars ("<" ++ registryDomain ++ ">.") , D.fromChars "That" , D.fromChars "means" , D.fromChars "there" @@ -379,7 +475,32 @@ bumpToReport bump = BumpBadDetails details -> toDetailsReport details - BumpNoExposed -> + BumpGuidaNoExposed -> + Help.docReport "NO EXPOSED MODULES" + (Just "guida.json") + (D.fillSep <| + [ D.fromChars "To" + , D.fromChars "bump" + , D.fromChars "a" + , D.fromChars "package," + , D.fromChars "the" + , D.dullyellow (D.fromChars "\"exposed-modules\"") + , D.fromChars "field" + , D.fromChars "of" + , D.fromChars "your" + , D.fromChars "guida.json" + , D.fromChars "must" + , D.fromChars "list" + , D.fromChars "at" + , D.fromChars "least" + , D.fromChars "one" + , D.fromChars "module." + ] + ) + [ D.reflow "Try adding some modules back to the \"exposed-modules\" field." + ] + + BumpElmNoExposed -> Help.docReport "NO EXPOSED MODULES" (Just "elm.json") (D.fillSep <| @@ -401,8 +522,7 @@ bumpToReport bump = , D.fromChars "module." ] ) - [ D.reflow <| - "Try adding some modules back to the \"exposed-modules\" field." + [ D.reflow "Try adding some modules back to the \"exposed-modules\" field." ] BumpBadBuild problem -> @@ -443,7 +563,8 @@ type Publish | PublishBadDetails Details | PublishMustHaveLatestRegistry RegistryProblem | PublishApplication - | PublishNotInitialVersion V.Version + | PublishGuidaNotInitialVersion V.Version + | PublishElmNotInitialVersion V.Version | PublishAlreadyPublished V.Version | PublishInvalidBump V.Version V.Version | PublishBadBump V.Version V.Version M.Magnitude V.Version M.Magnitude @@ -475,9 +596,8 @@ publishToReport publish = PublishNoOutline -> Help.report "PUBLISH WHAT?" Nothing - "I cannot find an elm.json so I am not sure what you want me to publish." - [ D.reflow <| - "Elm packages always have an elm.json that states the version number, dependencies, exposed modules, etc." + "I cannot find a guida.json (or elm.json) so I am not sure what you want me to publish." + [ D.reflow "Guida (and Elm) packages always have a guida.json (or elm.json) that states the version number, dependencies, exposed modules, etc." ] PublishBadOutline outline -> @@ -493,7 +613,38 @@ publishToReport publish = PublishApplication -> Help.report "UNPUBLISHABLE" Nothing "I cannot publish applications, only packages!" [] - PublishNotInitialVersion vsn -> + PublishGuidaNotInitialVersion vsn -> + Help.docReport "INVALID VERSION" + Nothing + (D.fillSep + [ D.fromChars "I" + , D.fromChars "cannot" + , D.fromChars "publish" + , D.red (D.fromVersion vsn) + , D.fromChars "as" + , D.fromChars "the" + , D.fromChars "initial" + , D.fromChars "version." + ] + ) + [ D.fillSep + [ D.fromChars "Change" + , D.fromChars "it" + , D.fromChars "to" + , D.green (D.fromChars "1.0.0") + , D.fromChars "which" + , D.fromChars "is" + , D.fromChars "the" + , D.fromChars "initial" + , D.fromChars "version" + , D.fromChars "for" + , D.fromChars "all" + , D.fromChars "Guida" + , D.fromChars "packages." + ] + ] + + PublishElmNotInitialVersion vsn -> Help.docReport "INVALID VERSION" Nothing (D.fillSep @@ -544,7 +695,7 @@ publishToReport publish = , D.fromChars "Try using the `bump` command:" ] ) - [ D.dullyellow <| D.indent 4 (D.fromChars "elm bump") + [ D.dullyellow <| D.indent 4 (D.fromChars "guida bump") , D.reflow <| "It computes the version number based on API changes, ensuring that no breaking changes end up in PATCH releases!" ] @@ -599,7 +750,7 @@ publishToReport publish = , D.fromChars "by" , D.fromChars "running:" ] - , D.indent 4 <| D.green (D.fromChars "elm bump") + , D.indent 4 <| D.green (D.fromChars "guida bump") , D.reflow <| "If you want more insight on the API changes Elm detects, you can run `elm diff` at this point as well." ] @@ -1059,7 +1210,7 @@ installToReport exit = toRegistryProblemReport "PROBLEM LOADING PACKAGE LIST" problem <| "I need the list of published packages to figure out how to install things" - InstallNoArgs elmHome -> + InstallNoArgs guidaHome -> Help.report "INSTALL WHAT?" Nothing "I am expecting commands like:" @@ -1090,11 +1241,11 @@ installToReport exit = , D.fromChars "and" , D.fromChars "again?" , D.fromChars "Instead," - , D.fromChars "Elm" + , D.fromChars "Guida" , D.fromChars "caches" , D.fromChars "packages" , D.fromChars "in" - , D.dullyellow (D.fromChars elmHome) + , D.dullyellow (D.fromChars guidaHome) , D.fromChars "so" , D.fromChars "each" , D.fromChars "one" @@ -1106,7 +1257,7 @@ installToReport exit = , D.fromChars "on" , D.fromChars "your" , D.fromChars "machine." - , D.fromChars "Elm" + , D.fromChars "Guida" , D.fromChars "projects" , D.fromChars "check" , D.fromChars "that" @@ -1132,16 +1283,16 @@ installToReport exit = , D.fromChars "As" , D.fromChars "a" , D.fromChars "result" - , D.dullcyan (D.fromChars "elm install") + , D.dullcyan (D.fromChars "guida install") , D.fromChars "is" , D.fromChars "only" , D.fromChars "for" , D.fromChars "adding" , D.fromChars "dependencies" , D.fromChars "to" - , D.fromChars "elm.json," + , D.fromChars "guida.json," , D.fromChars "whereas" - , D.dullcyan (D.fromChars "elm make") + , D.dullcyan (D.fromChars "guida make") , D.fromChars "is" , D.fromChars "in" , D.fromChars "charge" @@ -1154,7 +1305,7 @@ installToReport exit = , D.fromChars "So" , D.fromChars "maybe" , D.fromChars "try" - , D.green (D.fromChars "elm make") + , D.green (D.fromChars "guida make") , D.fromChars "instead?" ] ] @@ -1369,12 +1520,16 @@ toSolverReport problem = type Outline - = OutlineHasBadStructure (Decode.Error OutlineProblem) + = OutlineHasBadGuidaStructure (Decode.Error OutlineProblem) + | OutlineHasBadElmStructure (Decode.Error OutlineProblem) | OutlineHasMissingSrcDirs FilePath (List FilePath) | OutlineHasDuplicateSrcDirs FilePath FilePath FilePath - | OutlineNoPkgCore - | OutlineNoAppCore - | OutlineNoAppJson + | OutlineNoGuidaPkgCore + | OutlineNoElmPkgCore + | OutlineNoGuidaAppCore + | OutlineNoElmAppCore + | OutlineNoGuidaAppJson + | OutlineNoElmAppJson type OutlineProblem @@ -1384,7 +1539,8 @@ type OutlineProblem | OP_BadConstraint C.Error | OP_BadModuleName Row Col | OP_BadModuleHeaderTooLong - | OP_BadDependencyName Row Col + | OP_BadGuidaDependencyName Row Col + | OP_BadElmDependencyName Row Col | OP_BadLicense (List String) | OP_BadSummaryTooLong | OP_NoSrcDirs @@ -1393,7 +1549,11 @@ type OutlineProblem toOutlineReport : Outline -> Help.Report toOutlineReport problem = case problem of - OutlineHasBadStructure decodeError -> + OutlineHasBadGuidaStructure decodeError -> + Json.toReport "guida.json" (Json.FailureToReport toOutlineProblemReport) decodeError <| + Json.ExplicitReason "I ran into a problem with your guida.json file." + + OutlineHasBadElmStructure decodeError -> Json.toReport "elm.json" (Json.FailureToReport toOutlineProblemReport) decodeError <| Json.ExplicitReason "I ran into a problem with your elm.json file." @@ -1445,7 +1605,15 @@ toOutlineReport problem = "Remove one of the redundant entries from your \"source-directories\" field." ] - OutlineNoPkgCore -> + OutlineNoGuidaPkgCore -> + Help.report "MISSING DEPENDENCY" + (Just "guida.json") + "I need to see an \"elm/core\" dependency your guida.json file. The default imports of `List` and `Maybe` do not work without it." + [ D.reflow <| + "If you modified your guida.json by hand, try to change it back! And if you are having trouble getting back to a working guida.json, it may be easier to find a working package and start fresh with their guida.json file." + ] + + OutlineNoElmPkgCore -> Help.report "MISSING DEPENDENCY" (Just "elm.json") "I need to see an \"elm/core\" dependency your elm.json file. The default imports of `List` and `Maybe` do not work without it." @@ -1453,7 +1621,15 @@ toOutlineReport problem = "If you modified your elm.json by hand, try to change it back! And if you are having trouble getting back to a working elm.json, it may be easier to find a working package and start fresh with their elm.json file." ] - OutlineNoAppCore -> + OutlineNoGuidaAppCore -> + Help.report "MISSING DEPENDENCY" + (Just "guida.json") + "I need to see an \"elm/core\" dependency your guida.json file. The default imports of `List` and `Maybe` do not work without it." + [ D.reflow <| + "If you modified your guida.json by hand, try to change it back! And if you are having trouble getting back to a working guida.json, it may be easier to delete it and use `guida init` to start fresh." + ] + + OutlineNoElmAppCore -> Help.report "MISSING DEPENDENCY" (Just "elm.json") "I need to see an \"elm/core\" dependency your elm.json file. The default imports of `List` and `Maybe` do not work without it." @@ -1461,7 +1637,15 @@ toOutlineReport problem = "If you modified your elm.json by hand, try to change it back! And if you are having trouble getting back to a working elm.json, it may be easier to delete it and use `elm init` to start fresh." ] - OutlineNoAppJson -> + OutlineNoGuidaAppJson -> + Help.report "MISSING DEPENDENCY" + (Just "guida.json") + "I need to see an \"elm/json\" dependency your guida.json file. It helps me handle flags and ports." + [ D.reflow <| + "If you modified your guida.json by hand, try to change it back! And if you are having trouble getting back to a working guida.json, it may be easier to delete it and use `guida init` to start fresh." + ] + + OutlineNoElmAppJson -> Help.report "MISSING DEPENDENCY" (Just "elm.json") "I need to see an \"elm/json\" dependency your elm.json file. It helps me handle flags and ports." @@ -1607,10 +1791,9 @@ toOutlineProblemReport path source _ region problem = if before == after then toSnippet "PROBLEM WITH CONSTRAINT" Nothing - ( D.reflow <| - "I got stuck while reading your elm.json file. I ran into an invalid version constraint:" + ( D.reflow "I got stuck while reading your elm.json file. I ran into an invalid version constraint:" , D.fillSep - [ D.fromChars "Elm" + [ D.fromChars "Guida" , D.fromChars "checks" , D.fromChars "that" , D.fromChars "all" @@ -1670,7 +1853,7 @@ toOutlineProblemReport path source _ region problem = |> D.a (D.fromChars "\"") ) , D.fromChars "instead?" - , D.fromChars "Elm" + , D.fromChars "Guida" , D.fromChars "checks" , D.fromChars "that" , D.fromChars "all" @@ -1760,7 +1943,60 @@ toOutlineProblemReport path source _ region problem = ] ) - OP_BadDependencyName row col -> + OP_BadGuidaDependencyName row col -> + toSnippet "PROBLEM WITH DEPENDENCY NAME" + (toHighlight row col) + ( D.reflow <| + "I got stuck while reading your guida.json file. There is something wrong with this dependency name:" + , D.stack + [ D.fillSep + [ D.fromChars "Package" + , D.fromChars "names" + , D.fromChars "always" + , D.fromChars "include" + , D.fromChars "the" + , D.fromChars "name" + , D.fromChars "of" + , D.fromChars "the" + , D.fromChars "author," + , D.fromChars "so" + , D.fromChars "I" + , D.fromChars "am" + , D.fromChars "expecting" + , D.fromChars "to" + , D.fromChars "see" + , D.fromChars "dependencies" + , D.fromChars "like" + , D.dullyellow (D.fromChars "\"mdgriffith/elm-ui\"") + , D.fromChars "and" + , D.dullyellow (D.fromChars "\"Microsoft/elm-json-tree-view\"") + |> D.a (D.fromChars ".") + ] + , D.fillSep <| + [ D.fromChars "I" + , D.fromChars "generally" + , D.fromChars "recommend" + , D.fromChars "finding" + , D.fromChars "the" + , D.fromChars "package" + , D.fromChars "you" + , D.fromChars "want" + , D.fromChars "on" + , D.fromChars "the" + , D.fromChars "package" + , D.fromChars "website," + , D.fromChars "and" + , D.fromChars "installing" + , D.fromChars "it" + , D.fromChars "with" + , D.fromChars "the" + , D.green (D.fromChars "guida install") + , D.fromChars "command!" + ] + ] + ) + + OP_BadElmDependencyName row col -> toSnippet "PROBLEM WITH DEPENDENCY NAME" (toHighlight row col) ( D.reflow <| @@ -1807,7 +2043,7 @@ toOutlineProblemReport path source _ region problem = , D.fromChars "it" , D.fromChars "with" , D.fromChars "the" - , D.green (D.fromChars "elm install") + , D.green (D.fromChars "guida install") , D.fromChars "command!" ] ] @@ -1910,12 +2146,17 @@ toOutlineProblemReport path source _ region problem = type Details - = DetailsNoSolution - | DetailsNoOfflineSolution + = DetailsNoGuidaSolution + | DetailsNoElmSolution + | DetailsNoGuidaOfflineSolution String + | DetailsNoElmOfflineSolution String | DetailsSolverProblem Solver + | DetailsBadGuidaInPkg C.Constraint | DetailsBadElmInPkg C.Constraint + | DetailsBadGuidaInAppOutline V.Version | DetailsBadElmInAppOutline V.Version - | DetailsHandEditedDependencies + | DetailsHandEditedGuidaDependencies + | DetailsHandEditedElmDependencies | DetailsBadOutline Outline | DetailsCannotGetRegistry RegistryProblem | DetailsBadDeps FilePath (List DetailsBadDep) @@ -1929,7 +2170,38 @@ type DetailsBadDep toDetailsReport : Details -> Help.Report toDetailsReport details = case details of - DetailsNoSolution -> + DetailsNoGuidaSolution -> + Help.report "INCOMPATIBLE DEPENDENCIES" + (Just "guida.json") + "The dependencies in your guida.json are not compatible." + [ D.fillSep + [ D.fromChars "Did" + , D.fromChars "you" + , D.fromChars "change" + , D.fromChars "them" + , D.fromChars "by" + , D.fromChars "hand?" + , D.fromChars "Try" + , D.fromChars "to" + , D.fromChars "change" + , D.fromChars "it" + , D.fromChars "back!" + , D.fromChars "It" + , D.fromChars "is" + , D.fromChars "much" + , D.fromChars "more" + , D.fromChars "reliable" + , D.fromChars "to" + , D.fromChars "add" + , D.fromChars "dependencies" + , D.fromChars "with" + , D.green (D.fromChars "guida install") + |> D.a (D.fromChars ".") + ] + , D.reflow "Please ask for help on the community forums if you try those paths and are still having problems!" + ] + + DetailsNoElmSolution -> Help.report "INCOMPATIBLE DEPENDENCIES" (Just "elm.json") "The dependencies in your elm.json are not compatible." @@ -1954,19 +2226,49 @@ toDetailsReport details = , D.fromChars "add" , D.fromChars "dependencies" , D.fromChars "with" - , D.green (D.fromChars "elm install") + , D.green (D.fromChars "guida install") + |> D.a (D.fromChars ".") + ] + , D.reflow "Please ask for help on the community forums if you try those paths and are still having problems!" + ] + + DetailsNoGuidaOfflineSolution registryDomain -> + Help.report "TROUBLE VERIFYING DEPENDENCIES" + (Just "guida.json") + ("I could not connect to " ++ registryDomain ++ " to get the latest list of packages, and I was unable to verify your dependencies with the information I have cached locally.") + [ D.reflow "Are you able to connect to the internet? These dependencies may work once you get access to the registry!" + , D.toFancyNote + [ D.fromChars "If" + , D.fromChars "you" + , D.fromChars "changed" + , D.fromChars "your" + , D.fromChars "dependencies" + , D.fromChars "by" + , D.fromChars "hand," + , D.fromChars "try" + , D.fromChars "to" + , D.fromChars "change" + , D.fromChars "them" + , D.fromChars "back!" + , D.fromChars "It" + , D.fromChars "is" + , D.fromChars "much" + , D.fromChars "more" + , D.fromChars "reliable" + , D.fromChars "to" + , D.fromChars "add" + , D.fromChars "dependencies" + , D.fromChars "with" + , D.green (D.fromChars "guida install") |> D.a (D.fromChars ".") ] - , D.reflow <| - "Please ask for help on the community forums if you try those paths and are still having problems!" ] - DetailsNoOfflineSolution -> + DetailsNoElmOfflineSolution registryDomain -> Help.report "TROUBLE VERIFYING DEPENDENCIES" (Just "elm.json") - "I could not connect to https://package.elm-lang.org to get the latest list of packages, and I was unable to verify your dependencies with the information I have cached locally." - [ D.reflow <| - "Are you able to connect to the internet? These dependencies may work once you get access to the registry!" + ("I could not connect to " ++ registryDomain ++ " to get the latest list of packages, and I was unable to verify your dependencies with the information I have cached locally.") + [ D.reflow "Are you able to connect to the internet? These dependencies may work once you get access to the registry!" , D.toFancyNote [ D.fromChars "If" , D.fromChars "you" @@ -1989,7 +2291,7 @@ toDetailsReport details = , D.fromChars "add" , D.fromChars "dependencies" , D.fromChars "with" - , D.green (D.fromChars "elm install") + , D.green (D.fromChars "guida install") |> D.a (D.fromChars ".") ] ] @@ -1997,6 +2299,23 @@ toDetailsReport details = DetailsSolverProblem solver -> toSolverReport solver + DetailsBadGuidaInPkg constraint -> + Help.report "GUIDA VERSION MISMATCH" + (Just "guida.json") + "Your guida.json says this package needs a version of Guida in this range:" + [ D.indent 4 <| D.dullyellow <| D.fromChars <| C.toChars constraint + , D.fillSep + [ D.fromChars "But" + , D.fromChars "you" + , D.fromChars "are" + , D.fromChars "using" + , D.fromChars "Guida" + , D.red (D.fromVersion V.compiler) + , D.fromChars "right" + , D.fromChars "now." + ] + ] + DetailsBadElmInPkg constraint -> Help.report "ELM VERSION MISMATCH" (Just "elm.json") @@ -2014,6 +2333,25 @@ toDetailsReport details = ] ] + DetailsBadGuidaInAppOutline version -> + Help.report "GUIDA VERSION MISMATCH" + (Just "guida.json") + "Your guida.json says this application needs a different version of Guida." + [ D.fillSep + [ D.fromChars "It" + , D.fromChars "requires" + , D.green (D.fromVersion version) + |> D.a (D.fromChars ",") + , D.fromChars "but" + , D.fromChars "you" + , D.fromChars "are" + , D.fromChars "using" + , D.red (D.fromVersion V.compiler) + , D.fromChars "right" + , D.fromChars "now." + ] + ] + DetailsBadElmInAppOutline version -> Help.report "ELM VERSION MISMATCH" (Just "elm.json") @@ -2033,7 +2371,38 @@ toDetailsReport details = ] ] - DetailsHandEditedDependencies -> + DetailsHandEditedGuidaDependencies -> + Help.report "ERROR IN DEPENDENCIES" + (Just "guida.json") + "It looks like the dependencies guida.json in were edited by hand (or by a 3rd party tool) leaving them in an invalid state." + [ D.fillSep + [ D.fromChars "Try" + , D.fromChars "to" + , D.fromChars "change" + , D.fromChars "them" + , D.fromChars "back" + , D.fromChars "to" + , D.fromChars "what" + , D.fromChars "they" + , D.fromChars "were" + , D.fromChars "before!" + , D.fromChars "It" + , D.fromChars "is" + , D.fromChars "much" + , D.fromChars "more" + , D.fromChars "reliable" + , D.fromChars "to" + , D.fromChars "add" + , D.fromChars "dependencies" + , D.fromChars "with" + , D.green (D.fromChars "guida install") + |> D.a (D.fromChars ".") + ] + , D.reflow <| + "Please ask for help on the community forums if you try those paths and are still having problems!" + ] + + DetailsHandEditedElmDependencies -> Help.report "ERROR IN DEPENDENCIES" (Just "elm.json") "It looks like the dependencies elm.json in were edited by hand (or by a 3rd party tool) leaving them in an invalid state." @@ -2057,7 +2426,7 @@ toDetailsReport details = , D.fromChars "add" , D.fromChars "dependencies" , D.fromChars "with" - , D.green (D.fromChars "elm install") + , D.green (D.fromChars "guida install") |> D.a (D.fromChars ".") ] , D.reflow <| @@ -2082,7 +2451,7 @@ toDetailsReport details = ++ cacheDir ++ " and guida-stuff/ directories, then trying to build again. That will work if some cached files got corrupted somehow." , D.reflow <| - "If that does not work, go to https://elm-lang.org/community and ask for help. This is a weird case!" + "If that does not work, go to https://guida-lang.org/community and ask for help. This is a weird case!" ] d :: _ -> @@ -2096,7 +2465,7 @@ toDetailsReport details = "I ran into a compilation error when trying to build the following package:" [ D.indent 4 <| D.red <| D.fromChars <| Pkg.toChars pkg ++ " " ++ V.toChars vsn , D.reflow <| - "This probably means it has package constraints that are too wide. It may be possible to tweak your elm.json to avoid the root problem as a stopgap. Head over to https://elm-lang.org/community to get help figuring out how to take this path!" + "This probably means it has package constraints that are too wide. It may be possible to tweak your elm.json to avoid the root problem as a stopgap. Head over to https://guida-lang.org/community to get help figuring out how to take this path!" , D.toSimpleNote <| "To help with the root problem, please report this to the package author along with the following information:" , D.indent 4 <| @@ -2179,8 +2548,7 @@ toPackageProblemReport pkg vsn problem = [ " Expected: " ++ expectedHash , " Actual: " ++ actualHash ] - , D.reflow <| - "This usually means that the package author moved the version tag, so report it to them and see if that is the issue. Folks on Elm slack can probably help as well." + , D.reflow "This usually means that the package author moved the version tag, so report it to them and see if that is the issue. Folks on Guida discord can probably help as well." ] @@ -2240,10 +2608,9 @@ toHttpErrorReport title err context = Http.BadUrl url reason -> toHttpReport (context ++ ", so I wanted to fetch:") url - [ D.reflow <| "But my HTTP library is saying this is not a valid URL. It is saying:" + [ D.reflow "But my HTTP library is saying this is not a valid URL. It is saying:" , D.indent 4 <| D.fromChars reason - , D.reflow <| - "This may indicate that there is some problem in the compiler, so please open an issue at https://github.com/elm/compiler/issues listing your operating system, Elm version, the command you ran, the terminal output, and any additional information that might help others reproduce the error." + , D.reflow "This may indicate that there is some problem in the compiler, so please open an issue at https://github.com/guida-lang/compiler/issues listing your operating system, Guida version, the command you ran, the terminal output, and any additional information that might help others reproduce the error." ] Http.BadHttp url httpExceptionContent -> @@ -2265,8 +2632,7 @@ toHttpErrorReport title err context = ] ++ List.map D.fromChars (String.words message) , D.indent 4 <| D.reflow <| body - , D.reflow <| - "This may mean some online endpoint changed in an unexpected way, so if does not seem like something on your side is causing this (e.g. firewall) please report this to https://github.com/elm/compiler/issues with your operating system, Elm version, the command you ran, the terminal output, and any additional information that can help others reproduce the error!" + , D.reflow "This may mean some online endpoint changed in an unexpected way, so if does not seem like something on your side is causing this (e.g. firewall) please report this to https://github.com/guida-lang/compiler/issues with your operating system, Guida version, the command you ran, the terminal output, and any additional information that can help others reproduce the error!" ] Utils.TooManyRedirects responses -> @@ -2335,12 +2701,11 @@ makeToReport : Make -> Help.Report makeToReport make = case make of MakeNoOutline -> - Help.report "NO elm.json FILE" + Help.report "NO guida.json (or elm.json) FILE" Nothing - "It looks like you are starting a new Elm project. Very exciting! Try running:" - [ D.indent 4 <| D.green <| D.fromChars "elm init" - , D.reflow <| - "It will help you get set up. It is really simple!" + "It looks like you are starting a new Guida project. Very exciting! Try running:" + [ D.indent 4 <| D.green <| D.fromChars "guida init" + , D.reflow "It will help you get set up. It is really simple!" ] MakeCannotOptimizeAndDebug -> @@ -2372,11 +2737,11 @@ makeToReport make = Nothing "What should I make though? I need specific files like:" [ D.vcat - [ D.indent 4 <| D.green (D.fromChars "elm make src/Main.elm") - , D.indent 4 <| D.green (D.fromChars "elm make src/This.elm src/That.elm") + [ D.indent 4 <| D.green (D.fromChars "guida make src/Main.guida") + , D.indent 4 <| D.green (D.fromChars "guida make src/This.guida src/That.guida") ] , D.reflow <| - "I recommend reading through https://guide.elm-lang.org for guidance on what to actually put in those files!" + "I recommend reading through https://guida-lang.org/docs for guidance on what to actually put in those files!" ] MakePkgNeedsExposing -> @@ -2384,11 +2749,10 @@ makeToReport make = Nothing "What should I make though? I need specific files like:" [ D.vcat - [ D.indent 4 <| D.green (D.fromChars "elm make src/Main.elm") - , D.indent 4 <| D.green (D.fromChars "elm make src/This.elm src/That.elm") + [ D.indent 4 <| D.green (D.fromChars "guida make src/Main.guida") + , D.indent 4 <| D.green (D.fromChars "guida make src/This.guida src/That.guida") ] - , D.reflow <| - "You can also entries to the \"exposed-modules\" list in your elm.json file, and I will try to compile the relevant files." + , D.reflow "You can also add entries to the \"exposed-modules\" list in your elm.json file, and I will try to compile the relevant files." ] MakeMultipleFilesIntoHtml -> diff --git a/src/Builder/Stuff.elm b/src/Builder/Stuff.elm index 9728ecd4b..98ae253d6 100644 --- a/src/Builder/Stuff.elm +++ b/src/Builder/Stuff.elm @@ -1,8 +1,9 @@ module Builder.Stuff exposing ( PackageCache + , Root(..) , details , findRoot - , getElmHome + , getGuidaHome , getPackageCache , getReplCache , guidai @@ -14,14 +15,18 @@ module Builder.Stuff exposing , packageCacheEncoder , prepublishDir , registry + , rootFilename + , rootMap + , rootPath + , rootProjectFilePath , testDir , withRegistryLock , withRootLock ) -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg -import Compiler.Elm.Version as V +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg +import Compiler.Guida.Version as V import Prelude import Task exposing (Task) import Utils.Bytes.Decode as BD @@ -70,7 +75,7 @@ compilerVersion = --- ELMI and ELMO +-- GUIDAI and GUIDAO guidai : String -> ModuleName.Raw -> String @@ -92,7 +97,52 @@ toArtifactPath root name ext = -- ROOT -findRoot : Task Never (Maybe String) +type Root + = GuidaRoot String + | ElmRoot String + + +rootProjectFilePath : Root -> Utils.FilePath +rootProjectFilePath root = + case root of + GuidaRoot path -> + path ++ "/guida.json" + + ElmRoot path -> + path ++ "/elm.json" + + +rootFilename : Root -> String +rootFilename root = + case root of + GuidaRoot _ -> + "guida.json" + + ElmRoot _ -> + "elm.json" + + +rootPath : Root -> Utils.FilePath +rootPath root = + case root of + GuidaRoot path -> + path + + ElmRoot path -> + path + + +rootMap : (String -> String) -> Root -> Root +rootMap f root = + case root of + GuidaRoot path -> + GuidaRoot (f path) + + ElmRoot path -> + GuidaRoot (f path) + + +findRoot : Task Never (Maybe Root) findRoot = Utils.dirGetCurrentDirectory |> Task.bind @@ -101,21 +151,29 @@ findRoot = ) -findRootHelp : List String -> Task Never (Maybe String) +findRootHelp : List String -> Task Never (Maybe Root) findRootHelp dirs = case dirs of [] -> Task.pure Nothing _ :: _ -> - Utils.dirDoesFileExist (Utils.fpJoinPath dirs ++ "/elm.json") + Utils.dirDoesFileExist (Utils.fpJoinPath dirs ++ "/guida.json") |> Task.bind - (\exists -> - if exists then - Task.pure (Just (Utils.fpJoinPath dirs)) + (\guidaExists -> + if guidaExists then + Task.pure (Just (GuidaRoot (Utils.fpJoinPath dirs))) else - findRootHelp (Prelude.init dirs) + Utils.dirDoesFileExist (Utils.fpJoinPath dirs ++ "/elm.json") + |> Task.bind + (\elmExists -> + if elmExists then + Task.pure (Just (ElmRoot (Utils.fpJoinPath dirs))) + + else + findRootHelp (Prelude.init dirs) + ) ) @@ -176,7 +234,7 @@ getReplCache = getCacheDir : String -> Task Never String getCacheDir projectName = - getElmHome + getGuidaHome |> Task.bind (\home -> let @@ -189,8 +247,8 @@ getCacheDir projectName = ) -getElmHome : Task Never String -getElmHome = +getGuidaHome : Task Never String +getGuidaHome = Utils.envLookupEnv "GUIDA_HOME" |> Task.bind (\maybeCustomHome -> diff --git a/src/Common/Format/Cheapskate/Parse.elm b/src/Common/Format/Cheapskate/Parse.elm index 6f57f1c2c..00e08e6d8 100644 --- a/src/Common/Format/Cheapskate/Parse.elm +++ b/src/Common/Format/Cheapskate/Parse.elm @@ -329,7 +329,7 @@ processElts refmap elts = (L _ lf) :: rest -> case lf of - -- Special handling of @docs lines in Elm: + -- Special handling of @docs lines in Guida: TextLine t -> case stripPrefix "@docs" t of Just terms1 -> @@ -359,7 +359,7 @@ processElts refmap elts = Just stripped -> stripped in - (ElmDocs <| List.filter ((/=) []) <| List.map (List.filter ((/=) "") << List.map String.trim << String.split ",") docs) + (GuidaDocs <| List.filter ((/=) []) <| List.map (List.filter ((/=) "") << List.map String.trim << String.split ",") docs) :: processElts refmap rest_ Nothing -> diff --git a/src/Common/Format/Cheapskate/Types.elm b/src/Common/Format/Cheapskate/Types.elm index 8fa4ddfbb..cb527e33b 100644 --- a/src/Common/Format/Cheapskate/Types.elm +++ b/src/Common/Format/Cheapskate/Types.elm @@ -38,7 +38,7 @@ type Block | HtmlBlock String | HRule | ReferencesBlock (List ( String, String, String )) - | ElmDocs (List (List String)) + | GuidaDocs (List (List String)) {-| Attributes for fenced code blocks. 'codeLang' is the diff --git a/src/Common/Format/ImportInfo.elm b/src/Common/Format/ImportInfo.elm index ccd73ede4..13407eac5 100644 --- a/src/Common/Format/ImportInfo.elm +++ b/src/Common/Format/ImportInfo.elm @@ -9,7 +9,7 @@ import Basics.Extra exposing (flip) import Common.Format.Bimap as Bimap exposing (Bimap) import Common.Format.KnownContents as KnownContents exposing (KnownContents) import Compiler.AST.Source as Src -import Compiler.Elm.Compiler.Imports as Imports +import Compiler.Guida.Compiler.Imports as Imports import Compiler.Parse.Module as M import Compiler.Reporting.Annotation as A import Data.Map as Dict exposing (Dict) diff --git a/src/Common/Format/Render/Box.elm b/src/Common/Format/Render/Box.elm index 244c3ca65..bff17aacd 100644 --- a/src/Common/Format/Render/Box.elm +++ b/src/Common/Format/Render/Box.elm @@ -6,7 +6,7 @@ import Common.Format.Cheapskate.Parse as Parse import Common.Format.Cheapskate.Types exposing (Block(..), Blocks, Doc(..), LinkTarget(..), Options(..)) import Common.Format.ImportInfo as ImportInfo exposing (ImportInfo) import Common.Format.KnownContents as KnownContents -import Common.Format.Render.ElmStructure as ElmStructure +import Common.Format.Render.GuidaStructure as GuidaStructure import Common.Format.Render.Markdown as Markdown import Compiler.AST.Source as Src import Compiler.AST.Utils.Binop as Binop @@ -176,7 +176,7 @@ intersperseMap spacer fn list = pleaseReport__ : String -> String -> String pleaseReport__ what details = -- TODO: include version in the message - "" + "" pleaseReport_ : String -> String -> Box.Line @@ -224,8 +224,8 @@ formatBinary multiline left ops = ( ( isLeftPipe, comments, op ), next ) :: rest -> if isLeftPipe then - ElmStructure.forceableSpaceSepOrIndented multiline - (ElmStructure.spaceSepOrStack left + GuidaStructure.forceableSpaceSepOrIndented multiline + (GuidaStructure.spaceSepOrStack left (List.concat [ Maybe.toList <| formatComments comments , [ op ] @@ -237,7 +237,7 @@ formatBinary multiline left ops = else formatBinary multiline - (ElmStructure.forceableSpaceSepOrIndented multiline left [ formatCommentedApostrophe comments (ElmStructure.spaceSepOrPrefix op next) ]) + (GuidaStructure.forceableSpaceSepOrIndented multiline left [ formatCommentedApostrophe comments (GuidaStructure.spaceSepOrPrefix op next) ]) rest @@ -450,7 +450,7 @@ formatModuleHeader addDefaultHeader modu = extractDocs : Block -> List (List String) extractDocs block = case block of - ElmDocs vars -> + GuidaDocs vars -> List.map (List.map (refName << textToRef)) vars _ -> @@ -677,12 +677,12 @@ formatModuleLine ( varsToExpose, extraComments ) srcTag name moduleSettings preE Box.line (Box.keyword "module") Port comments -> - ElmStructure.spaceSepOrIndented + GuidaStructure.spaceSepOrIndented (formatTailCommented ( comments, Box.line <| Box.keyword "port" )) [ Box.line (Box.keyword "module") ] Effect comments -> - ElmStructure.spaceSepOrIndented + GuidaStructure.spaceSepOrIndented (formatTailCommented ( comments, Box.line <| Box.keyword "effect" )) [ Box.line (Box.keyword "module") ] @@ -695,12 +695,12 @@ formatModuleLine ( varsToExpose, extraComments ) srcTag name moduleSettings preE [ oneGroup ] -> oneGroup |> List.map (formatCommented << Src.c2map formatVarValue) - |> ElmStructure.group_ False "(" "," (Maybe.toList (formatComments extraComments)) ")" False + |> GuidaStructure.group_ False "(" "," (Maybe.toList (formatComments extraComments)) ")" False _ -> varsToExpose - |> List.map (formatCommented << Src.c2map (ElmStructure.group False "" "," "" False << List.map formatVarValue) << Src.sequenceAC2) - |> ElmStructure.group_ False "(" "," (Maybe.toList (formatComments extraComments)) ")" True + |> List.map (formatCommented << Src.c2map (GuidaStructure.group False "" "," "" False << List.map formatVarValue) << Src.sequenceAC2) + |> GuidaStructure.group_ False "(" "," (Maybe.toList (formatComments extraComments)) ")" True formatSetting : ( Src.C2 String, Src.C2 String ) -> Box formatSetting ( k, v ) = @@ -709,7 +709,7 @@ formatModuleLine ( varsToExpose, extraComments ) srcTag name moduleSettings preE formatSettings : List ( Src.C2 String, Src.C2 String ) -> Box formatSettings settings = List.map formatSetting settings - |> ElmStructure.group True "{" "," "}" False + |> GuidaStructure.group True "{" "," "}" False whereClause : List Box whereClause = @@ -740,8 +740,8 @@ formatModuleLine ( varsToExpose, extraComments ) srcTag name moduleSettings preE , Box.indent name_ ] in - ElmStructure.spaceSepOrIndented - (ElmStructure.spaceSepOrIndented + GuidaStructure.spaceSepOrIndented + (GuidaStructure.spaceSepOrIndented nameClause (whereClause ++ [ formatCommented ( ( preExposing, postExposing ), Box.line <| Box.keyword "exposing" ) ]) ) @@ -1226,7 +1226,7 @@ formatTopLevelBody linesBetween importInfo body = Just <| Box.stack1 boxes -type ElmCodeBlock +type GuidaCodeBlock = DeclarationsCode (List (TopLevelStructure Declaration)) | ExpressionsCode (List (TopLevelStructure (Src.C0Eol Src.Expr))) | ModuleCode Module @@ -1235,7 +1235,7 @@ type ElmCodeBlock formatDocComment : ImportInfo -> Blocks -> Box formatDocComment importInfo blocks = let - parse : String -> Maybe ElmCodeBlock + parse : String -> Maybe GuidaCodeBlock parse source = source |> Maybe.oneOf @@ -1244,7 +1244,7 @@ formatDocComment importInfo blocks = , Maybe.map ModuleCode << Result.toMaybe << parseModule ] - format : ElmCodeBlock -> String + format : GuidaCodeBlock -> String format result = case result of ModuleCode modu -> @@ -1271,8 +1271,8 @@ formatDocComment importInfo blocks = cleanBlock : Block -> Block cleanBlock block = case block of - ElmDocs docs -> - ElmDocs <| + GuidaDocs docs -> + GuidaDocs <| (List.map << List.map) (String.replace "(..)" "") docs @@ -1528,7 +1528,7 @@ formatListing format listing = Nothing vars_ -> - Just <| ElmStructure.group False "(" "," ")" multiline vars_ + Just <| GuidaStructure.group False "(" "," ")" multiline vars_ @@ -1548,7 +1548,7 @@ formatListing format listing = -- multiline = -- A.isMultiline region -- in --- Just <| ElmStructure.group False "(" "," ")" multiline vars_ +-- Just <| GuidaStructure.group False "(" "," ")" multiline vars_ formatDetailedListing : DetailedListing -> List Box @@ -1691,7 +1691,7 @@ formatDeclaration importInfo decl = ] TypeAlias preAlias nameWithArgs typ -> - ElmStructure.definition "=" + GuidaStructure.definition "=" True (Box.line <| Box.keyword "type") [ formatPreCommented ( preAlias, Box.line <| Box.keyword "alias" ) @@ -1700,7 +1700,7 @@ formatDeclaration importInfo decl = (formatPreCommentedStack <| Src.c1map (typeParens NotRequired << formatType) typ) PortAnnotation name typeComments typ -> - ElmStructure.definition ":" + GuidaStructure.definition ":" False (Box.line <| Box.keyword "port") [ formatCommented <| Src.c2map (Box.line << formatLowercaseIdentifier []) name ] @@ -1720,7 +1720,7 @@ formatDeclaration importInfo decl = Binop.Non -> Box.keyword "non " in - ElmStructure.spaceSepOrIndented + GuidaStructure.spaceSepOrIndented (Box.line <| Box.keyword "infix") [ formatPreCommented <| Src.c1map (Box.line << formatAssoc) assoc , formatPreCommented <| Src.c1map (Box.line << Box.literal << String.fromInt) precedence @@ -1754,7 +1754,7 @@ formatDefinition importInfo (A.At _ name) args comments expr = ] ) in - ElmStructure.definition "=" + GuidaStructure.definition "=" True (syntaxParens SpaceSeparated (formatPattern name)) (List.map (\( x, A.At _ y ) -> formatCommentedApostrophe x (syntaxParens SpaceSeparated (formatPattern y))) args) @@ -1763,7 +1763,7 @@ formatDefinition importInfo (A.At _ name) args comments expr = formatTypeAnnotation : Src.C1 (Ref ()) -> Src.C1 Src.Type -> Box formatTypeAnnotation name typ = - ElmStructure.definition ":" + GuidaStructure.definition ":" False (formatTailCommented (Src.c1map (Box.line << formatVar << refMap (\() -> [])) name)) [] @@ -1786,7 +1786,7 @@ formatPattern apattern = Src.PRecord ( _, fields ) -> ( SyntaxSeparated - , ElmStructure.group True "{" "," "}" False (List.map (formatCommented << Src.c2map (Box.line << formatLowercaseIdentifier [] << A.toValue)) (List.reverse fields)) + , GuidaStructure.group True "{" "," "}" False (List.map (formatCommented << Src.c2map (Box.line << formatLowercaseIdentifier [] << A.toValue)) (List.reverse fields)) ) Src.PAlias aliasPattern name -> @@ -1825,7 +1825,7 @@ formatPattern apattern = a :: b :: cs in ( SyntaxSeparated - , ElmStructure.group True "(" "," ")" False (List.map (formatCommented << Src.c2map (syntaxParens SyntaxSeparated << formatPattern << A.toValue)) patterns) + , GuidaStructure.group True "(" "," ")" False (List.map (formatCommented << Src.c2map (syntaxParens SyntaxSeparated << formatPattern << A.toValue)) patterns) ) Src.PCtor _ name [] -> @@ -1845,8 +1845,8 @@ formatPattern apattern = [ name ] in ( SpaceSeparated - , ElmStructure.application - (ElmStructure.FAJoinFirst ElmStructure.JoinAll) + , GuidaStructure.application + (GuidaStructure.FAJoinFirst GuidaStructure.JoinAll) (Box.line (formatQualifiedUppercaseIdentifier ctor)) (List.map (formatPreCommented << Src.c1map (syntaxParens SpaceSeparated << formatPattern << A.toValue)) patterns) ) @@ -1868,8 +1868,8 @@ formatPattern apattern = String.split "." home ++ [ name ] in ( SpaceSeparated - , ElmStructure.application - (ElmStructure.FAJoinFirst ElmStructure.JoinAll) + , GuidaStructure.application + (GuidaStructure.FAJoinFirst GuidaStructure.JoinAll) (Box.line (formatQualifiedUppercaseIdentifier ctor)) (List.map (formatPreCommented << Src.c1map (syntaxParens SpaceSeparated << formatPattern << A.toValue)) patterns) ) @@ -1881,7 +1881,7 @@ formatPattern apattern = Src.PList ( _, patterns ) -> ( SyntaxSeparated - , ElmStructure.group True "[" "," "]" False (List.map (formatCommented << Src.c2map (syntaxParens SyntaxSeparated << formatPattern << A.toValue)) patterns) + , GuidaStructure.group True "[" "," "]" False (List.map (formatCommented << Src.c2map (syntaxParens SyntaxSeparated << formatPattern << A.toValue)) patterns) ) Src.PCons hd tl -> @@ -1942,7 +1942,7 @@ formatPattern apattern = formatRecordPair : String -> (v -> Box) -> ( Src.C2 String, Src.C2 v, Bool ) -> Box formatRecordPair delim formatValue ( ( ( pre, postK ), k ), v, forceMultiline ) = - ElmStructure.equalsPair delim + GuidaStructure.equalsPair delim forceMultiline (formatCommented <| Src.c2map (Box.line << formatLowercaseIdentifier []) ( ( [], postK ), k )) (formatCommented <| Src.c2map formatValue v) @@ -1952,7 +1952,7 @@ formatRecordPair delim formatValue ( ( ( pre, postK ), k ), v, forceMultiline ) formatPair : String -> Src.Pair Box.Line Box -> Box formatPair delim (Src.Pair a b (Src.ForceMultiline forceMultiline)) = - ElmStructure.equalsPair delim + GuidaStructure.equalsPair delim forceMultiline (formatTailCommented <| Src.c1map Box.line a) (formatPreCommented b) @@ -2160,22 +2160,22 @@ formatExpression importInfo (A.At region aexpr) = (A.Region (A.Position aexprStartRow _) _) = region - multiline : ElmStructure.FunctionApplicationMultiline + multiline : GuidaStructure.FunctionApplicationMultiline multiline = if firstArgEndRow > aexprStartRow then - ElmStructure.FASplitFirst + GuidaStructure.FASplitFirst else - ElmStructure.FAJoinFirst + GuidaStructure.FAJoinFirst (if A.isMultiline region then - ElmStructure.SplitAll + GuidaStructure.SplitAll else - ElmStructure.JoinAll + GuidaStructure.JoinAll ) in ( SpaceSeparated - , ElmStructure.application + , GuidaStructure.application multiline (syntaxParens InfixSeparated <| formatExpression importInfo func) (List.map (formatPreCommentedExpression importInfo SpaceSeparated) args) @@ -2447,7 +2447,7 @@ formatExpression importInfo (A.At region aexpr) = a :: b :: cs in ( SyntaxSeparated - , ElmStructure.group True "(" "," ")" multiline <| + , GuidaStructure.group True "(" "," ")" multiline <| List.map (formatCommentedExpression importInfo) exprs ) @@ -2511,7 +2511,7 @@ formatRecordLike : Maybe (Src.C2 Box) -> List (Src.C2Eol Box) -> Src.FComments - formatRecordLike base_ fields trailing multiline = case ( base_, fields ) of ( Just base, pairs_ ) -> - ElmStructure.extensionGroup_ + GuidaStructure.extensionGroup_ ((\(Src.ForceMultiline b) -> b) multiline) (formatCommented base) (formatSequence '|' @@ -2542,8 +2542,8 @@ formatSequence left delim maybeRight (Src.ForceMultiline multiline) trailing lis Box.prefix (Box.row [ Box.punc (String.fromChar delim_), Box.space ]) <| formatC2Eol ( ( post, [], eol ), item ) in - ElmStructure.forceableSpaceSepOrStack multiline - (ElmStructure.forceableRowOrStack multiline + GuidaStructure.forceableSpaceSepOrStack multiline + (GuidaStructure.forceableRowOrStack multiline (formatItem left first) (List.map (formatItem delim) rest) ) @@ -2630,12 +2630,12 @@ formatComments comments = Nothing first :: rest -> - Just (ElmStructure.spaceSepOrStack first rest) + Just (GuidaStructure.spaceSepOrStack first rest) formatCommented_ : Bool -> Src.C2 Box -> Box formatCommented_ forceMultiline ( ( pre, post ), inner ) = - ElmStructure.forceableSpaceSepOrStack1 forceMultiline <| + GuidaStructure.forceableSpaceSepOrStack1 forceMultiline <| List.concat [ Maybe.toList (formatComments pre) , [ inner ] @@ -2696,7 +2696,7 @@ formatPreCommentedStack ( pre, inner ) = formatKeywordCommented : String -> Src.C2 Box -> Box formatKeywordCommented word ( ( pre, post ), value ) = - ElmStructure.spaceSepOrIndented + GuidaStructure.spaceSepOrIndented (formatCommented ( ( pre, post ), Box.line (Box.keyword word) )) [ value ] @@ -2950,9 +2950,9 @@ formatType (A.At region atype) = formatRight : Src.C2Eol Src.Type -> Box formatRight ( ( preOp, postOp, eol ), term ) = - ElmStructure.forceableSpaceSepOrStack1 False <| + GuidaStructure.forceableSpaceSepOrStack1 False <| ((Maybe.toList <| formatComments preOp) - ++ [ ElmStructure.prefixOrIndented + ++ [ GuidaStructure.prefixOrIndented (Box.line <| Box.punc "->") (formatC2Eol <| (Src.c2EolMap <| typeParens ForLambda << formatType) @@ -2962,7 +2962,7 @@ formatType (A.At region atype) = ) in ( ForFunctionType - , ElmStructure.forceableSpaceSepOrStack + , GuidaStructure.forceableSpaceSepOrStack forceMultiline (formatEolCommented (Src.c0EolMap (typeParens ForLambda << formatType) first)) (List.map formatRight rest) @@ -2981,21 +2981,21 @@ formatType (A.At region atype) = forceMultiline = Src.ForceMultiline (A.isMultiline region) - join : ElmStructure.FunctionApplicationMultiline + join : GuidaStructure.FunctionApplicationMultiline join = case forceMultiline of Src.ForceMultiline True -> - ElmStructure.FASplitFirst + GuidaStructure.FASplitFirst Src.ForceMultiline False -> - ElmStructure.FAJoinFirst ElmStructure.JoinAll + GuidaStructure.FAJoinFirst GuidaStructure.JoinAll in ( if List.isEmpty args then NotNeeded else ForTypeConstruction - , ElmStructure.application + , GuidaStructure.application join (formatTypeConstructor ctor) (List.map (formatPreCommented << Src.c1map (typeParens ForCtor << formatType)) args) @@ -3007,21 +3007,21 @@ formatType (A.At region atype) = forceMultiline = Src.ForceMultiline (A.isMultiline region) - join : ElmStructure.FunctionApplicationMultiline + join : GuidaStructure.FunctionApplicationMultiline join = case forceMultiline of Src.ForceMultiline True -> - ElmStructure.FASplitFirst + GuidaStructure.FASplitFirst Src.ForceMultiline False -> - ElmStructure.FAJoinFirst ElmStructure.JoinAll + GuidaStructure.FAJoinFirst GuidaStructure.JoinAll in ( if List.isEmpty args then NotNeeded else ForTypeConstruction - , ElmStructure.application + , GuidaStructure.application join (formatTypeConstructor (home ++ "." ++ name)) (List.map (formatPreCommented << Src.c1map (typeParens ForCtor << formatType)) args) @@ -3071,7 +3071,7 @@ formatType (A.At region atype) = A.isMultiline region in ( NotNeeded - , ElmStructure.group True "(" "," ")" forceMultiline (List.map (formatC2Eol << Src.c2EolMap (typeParens NotRequired << formatType)) types) + , GuidaStructure.group True "(" "," ")" forceMultiline (List.map (formatC2Eol << Src.c2EolMap (typeParens NotRequired << formatType)) types) ) Src.TParens type_ -> diff --git a/src/Common/Format/Render/ElmStructure.elm b/src/Common/Format/Render/GuidaStructure.elm similarity index 99% rename from src/Common/Format/Render/ElmStructure.elm rename to src/Common/Format/Render/GuidaStructure.elm index 11d816647..c26d8ec49 100644 --- a/src/Common/Format/Render/ElmStructure.elm +++ b/src/Common/Format/Render/GuidaStructure.elm @@ -1,4 +1,4 @@ -module Common.Format.Render.ElmStructure exposing +module Common.Format.Render.GuidaStructure exposing ( FunctionApplicationMultiline(..) , Multiline(..) , application diff --git a/src/Common/Format/Render/Markdown.elm b/src/Common/Format/Render/Markdown.elm index 6a00622a5..57fcca0e8 100644 --- a/src/Common/Format/Render/Markdown.elm +++ b/src/Common/Format/Render/Markdown.elm @@ -109,7 +109,7 @@ type Context formatMardownBlock : (String -> Maybe String) -> Context -> Block -> String formatMardownBlock formatCode context block = case block of - ElmDocs terms -> + GuidaDocs terms -> (String.join "\n" <| List.map (\term -> "@docs " ++ String.join ", " term) terms) ++ "\n" Para inlines -> @@ -147,14 +147,14 @@ formatMardownBlock formatCode context block = CodeBlock (CodeAttr { codeLang }) code -> let - isElm : Bool - isElm = - codeLang == "elm" || codeLang == "" + isGuidaOrElm : Bool + isGuidaOrElm = + codeLang == "guida" || codeLang == "elm" || codeLang == "" formatted : String formatted = Maybe.withDefault (ensureNewline code) <| - if isElm then + if isGuidaOrElm then formatCode code else @@ -177,7 +177,7 @@ formatMardownBlock formatCode context block = AfterIndentedList -> False in - if isElm && canIndent then + if isGuidaOrElm && canIndent then Utils.unlines <| List.map (\line -> " " ++ line) <| lines formatted else diff --git a/src/Compiler/AST/Canonical.elm b/src/Compiler/AST/Canonical.elm index 54bf29e81..3e4d959cc 100644 --- a/src/Compiler/AST/Canonical.elm +++ b/src/Compiler/AST/Canonical.elm @@ -63,7 +63,7 @@ import Compiler.AST.Utils.Binop as Binop import Compiler.AST.Utils.Shader as Shader import Compiler.Data.Index as Index import Compiler.Data.Name exposing (Name) -import Compiler.Elm.ModuleName as ModuleName +import Compiler.Guida.ModuleName as ModuleName import Compiler.Reporting.Annotation as A import Data.Map as Dict exposing (Dict) import System.TypeCheck.IO as IO diff --git a/src/Compiler/AST/Optimized.elm b/src/Compiler/AST/Optimized.elm index a3f9cdf51..5d754214b 100644 --- a/src/Compiler/AST/Optimized.elm +++ b/src/Compiler/AST/Optimized.elm @@ -28,9 +28,9 @@ import Compiler.AST.Canonical as Can import Compiler.AST.Utils.Shader as Shader import Compiler.Data.Index as Index import Compiler.Data.Name as Name exposing (Name) -import Compiler.Elm.Kernel as K -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg +import Compiler.Guida.Kernel as K +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg import Compiler.Optimize.DecisionTree as DT import Compiler.Reporting.Annotation as A import Data.Map as Dict exposing (Dict) @@ -222,13 +222,13 @@ addKernelDep chunk deps = K.JS _ -> deps - K.ElmVar home name -> + K.GuidaVar home name -> EverySet.insert toComparableGlobal (Global home name) deps K.JsVar shortName _ -> EverySet.insert toComparableGlobal (toKernelGlobal shortName) deps - K.ElmField _ -> + K.GuidaField _ -> deps K.JsField _ -> diff --git a/src/Compiler/Canonicalize/Effects.elm b/src/Compiler/Canonicalize/Effects.elm index 547ea36ce..de7e2943a 100644 --- a/src/Compiler/Canonicalize/Effects.elm +++ b/src/Compiler/Canonicalize/Effects.elm @@ -9,7 +9,7 @@ import Compiler.AST.Utils.Type as Type import Compiler.Canonicalize.Environment as Env import Compiler.Canonicalize.Type as Type import Compiler.Data.Name as Name -import Compiler.Elm.ModuleName as ModuleName +import Compiler.Guida.ModuleName as ModuleName import Compiler.Parse.SyntaxVersion exposing (SyntaxVersion) import Compiler.Reporting.Annotation as A import Compiler.Reporting.Error.Canonicalize as Error diff --git a/src/Compiler/Canonicalize/Environment/Foreign.elm b/src/Compiler/Canonicalize/Environment/Foreign.elm index d52d5384d..4c0379245 100644 --- a/src/Compiler/Canonicalize/Environment/Foreign.elm +++ b/src/Compiler/Canonicalize/Environment/Foreign.elm @@ -4,9 +4,9 @@ import Compiler.AST.Canonical as Can import Compiler.AST.Source as Src import Compiler.Canonicalize.Environment as Env import Compiler.Data.Name as Name exposing (Name) -import Compiler.Elm.Interface as I -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg +import Compiler.Guida.Interface as I +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg import Compiler.Reporting.Annotation as A import Compiler.Reporting.Error.Canonicalize as Error import Compiler.Reporting.Result as R diff --git a/src/Compiler/Canonicalize/Expression.elm b/src/Compiler/Canonicalize/Expression.elm index 76e7eba20..83d91723d 100644 --- a/src/Compiler/Canonicalize/Expression.elm +++ b/src/Compiler/Canonicalize/Expression.elm @@ -18,8 +18,8 @@ import Compiler.Canonicalize.Pattern as Pattern import Compiler.Canonicalize.Type as Type import Compiler.Data.Index as Index import Compiler.Data.Name as Name exposing (Name) -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg import Compiler.Parse.SyntaxVersion as SV exposing (SyntaxVersion) import Compiler.Reporting.Annotation as A import Compiler.Reporting.Error.Canonicalize as Error diff --git a/src/Compiler/Canonicalize/Module.elm b/src/Compiler/Canonicalize/Module.elm index d226c68d5..7514970ca 100644 --- a/src/Compiler/Canonicalize/Module.elm +++ b/src/Compiler/Canonicalize/Module.elm @@ -12,9 +12,9 @@ import Compiler.Canonicalize.Pattern as Pattern import Compiler.Canonicalize.Type as Type import Compiler.Data.Index as Index import Compiler.Data.Name as Name exposing (Name) -import Compiler.Elm.Interface as I -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg +import Compiler.Guida.Interface as I +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg import Compiler.Parse.SyntaxVersion exposing (SyntaxVersion) import Compiler.Reporting.Annotation as A import Compiler.Reporting.Error.Canonicalize as Error diff --git a/src/Compiler/Canonicalize/Pattern.elm b/src/Compiler/Canonicalize/Pattern.elm index 5d638ddf7..9c7172bf4 100644 --- a/src/Compiler/Canonicalize/Pattern.elm +++ b/src/Compiler/Canonicalize/Pattern.elm @@ -12,7 +12,7 @@ import Compiler.Canonicalize.Environment as Env import Compiler.Canonicalize.Environment.Dups as Dups import Compiler.Data.Index as Index import Compiler.Data.Name as Name -import Compiler.Elm.ModuleName as ModuleName +import Compiler.Guida.ModuleName as ModuleName import Compiler.Parse.SyntaxVersion as SV exposing (SyntaxVersion) import Compiler.Reporting.Annotation as A import Compiler.Reporting.Error.Canonicalize as Error diff --git a/src/Compiler/Compile.elm b/src/Compiler/Compile.elm index b45bb756e..2f962a7ee 100644 --- a/src/Compiler/Compile.elm +++ b/src/Compiler/Compile.elm @@ -8,9 +8,9 @@ import Compiler.AST.Optimized as Opt import Compiler.AST.Source as Src import Compiler.Canonicalize.Module as Canonicalize import Compiler.Data.Name as Name exposing (Name) -import Compiler.Elm.Interface as I -import Compiler.Elm.ModuleName as ModuleName -import Compiler.Elm.Package as Pkg +import Compiler.Guida.Interface as I +import Compiler.Guida.ModuleName as ModuleName +import Compiler.Guida.Package as Pkg import Compiler.Nitpick.PatternMatches as PatternMatches import Compiler.Optimize.Module as Optimize import Compiler.Reporting.Error as E diff --git a/src/Compiler/Generate/Html.elm b/src/Compiler/Generate/Html.elm index 136c1ece0..b08097e59 100644 --- a/src/Compiler/Generate/Html.elm +++ b/src/Compiler/Generate/Html.elm @@ -23,13 +23,13 @@ sandwich moduleName javascript = -

+