@@ -5,9 +5,10 @@ module Elm.Details
55 , ValidOutline(..)
66 , Local(..)
77 , Foreign(..)
8− , verify
8+ , load
99 , loadObjects
1010 , loadInterfaces
11+ , verifyInstall
1112 )
1213 where
1314
@@ -91,7 +92,7 @@ type Interfaces =
9192
9293
9394
94−-- LOAD
95+-- LOAD ARTIFACTS
9596
9697
9798loadObjects :: FilePath -> Details -> IO (MVar (Maybe Opt.GlobalGraph))
@@ -109,29 +110,43 @@ loadInterfaces root (Details _ _ _ _ extras) =
109110
110111
111112
112−-- VERIFY
113+-- VERIFY INSTALL -- used by Install
113114
114115
115−verify :: Reporting.Style -> FilePath -> IO (Either Exit.Details Details)
116−verify style root =
116+verifyInstall :: FilePath -> Solver.Env -> Outline.Outline -> IO (Either Exit.Details ())
117+verifyInstall root (Solver.Env cache manager connection registry) outline =
118+ do time <- File.getTime (root </> "elm.json")
119+ let key = Reporting.ignorer
120+ let env = Env key root cache manager connection registry
121+ case outline of
122+ Outline.Pkg pkg -> Task.run (verifyPkg env time pkg >> return ())
123+ Outline.App app -> Task.run (verifyApp env time app >> return ())
124+
125+
126+
127+-- LOAD -- used by Make, Repl, Reactor
128+
129+
130+load :: Reporting.Style -> FilePath -> IO (Either Exit.Details Details)
131+load style root =
117132 do newTime <- File.getTime (root </> "elm.json")
118133 maybeDetails <- File.readBinary (Stuff.details root)
119134 case maybeDetails of
120135 Nothing ->
121− verifyFromScratch style root newTime
136+ generate style root newTime
122137
123138 Just details@(Details oldTime _ _ _ _) ->
124139 if oldTime == newTime
125140 then return (Right details)
126− else verifyFromScratch style root newTime
141+ else generate style root newTime
127142
128143
129144
130−-- VERIFY FROM SCRATCH
145+-- GENERATE
131146
132147
133−verifyFromScratch :: Reporting.Style -> FilePath -> File.Time -> IO (Either Exit.Details Details)
134−verifyFromScratch style root time =
148+generate :: Reporting.Style -> FilePath -> File.Time -> IO (Either Exit.Details Details)
149+generate style root time =
135150 Reporting.trackDetails style $ \key ->
136151 do result <- initEnv key root
137152 case result of
@@ -144,6 +159,10 @@ verifyFromScratch style root time =
144159 Outline.App app -> Task.run (verifyApp env time app)
145160
146161
162+
163+-- ENV
164+
165+
147166data Env =
148167 Env
149168 { _key :: Reporting.DKey
@@ -157,47 +176,20 @@ data Env =
157176
158177initEnv :: Reporting.DKey -> FilePath -> IO (Either Exit.Details (Env, Outline.Outline))
159178initEnv key root =
160− do cacheMVar <- fork Stuff.getPackageCache
161− managerMVar <- fork Http.getManager
162− registryMVar <- fork (Registry.read =<< readMVar cacheMVar)
179+ do mvar <- fork Solver.initEnv
163180 eitherOutline <- Outline.read root
164− cache <- readMVar cacheMVar
165− manager <- readMVar managerMVar
166− maybeRegistry <- readMVar registryMVar
167181 case eitherOutline of
168182 Left problem ->
169183 return $ Left $ Exit.DetailsBadOutline problem
170184
171185 Right outline ->
172− case maybeRegistry of
173− Nothing ->
174− do eitherRegistry <- Registry.fetch manager cache
175− case eitherRegistry of
176− Right latestRegistry ->
177− let
178− conn = Solver.Online manager
179− env = Env key root cache manager conn latestRegistry
180− in
181− return $ Right (env, outline)
182−
183− Left problem ->
184− return $ Left $ Exit.DetailsCannotGetRegistry problem
185−
186− Just cachedRegistry ->
187− do eitherRegistry <- Registry.update manager cache cachedRegistry
188− case eitherRegistry of
189− Right latestRegistry ->
190− let
191− conn = Solver.Online manager
192− env = Env key root cache manager conn latestRegistry
193− in
194− return $ Right (env, outline)
195−
196− Left _ ->
197− let
198− env = Env key root cache manager Solver.Offline cachedRegistry
199− in
200− return $ Right (env, outline)
186+ do maybeEnv <- readMVar mvar
187+ case maybeEnv of
188+ Left problem ->
189+ return $ Left $ Exit.DetailsCannotGetRegistry problem
190+
191+ Right (Solver.Env cache manager connection registry) ->
192+ return $ Right (Env key root cache manager connection registry, outline)
201193
202194
203195
@@ -573,8 +565,8 @@ crawlModule foreignDeps mvar pkg src name =
573565
574566crawlFile :: Map.Map ModuleName.Raw ForeignInterface -> MVar StatusDict -> Pkg.Name -> FilePath -> ModuleName.Raw -> FilePath -> IO (Maybe Status)
575567crawlFile foreignDeps mvar pkg src name path =
576− do result <- Parse.fromFile pkg path
577− case result of
568+ do bytes <- File.readUtf8 path
569+ case Parse.fromByteString pkg bytes of
578570 Right modul@(Src.Module (Just actualName) _ imports _ _ _ _ _) | name == actualName ->
579571 do deps <- crawlImports foreignDeps mvar pkg src imports
580572 return (Just (SLocal deps modul))
@@ -600,8 +592,8 @@ crawlKernel foreignDeps mvar pkg src name =
600592 exists <- File.exists path
601593 if exists
602594 then
603− do maybeContent <- Kernel.fromFile pkg (Map.mapMaybe getDepHome foreignDeps) path
604− case maybeContent of
595+ do bytes <- File.readUtf8 path
596+ case Kernel.fromByteString pkg (Map.mapMaybe getDepHome foreignDeps) bytes of
605597 Nothing ->
606598 return Nothing
607599