diff --git a/.gitignore b/.gitignore index e2e3b2d..fb4e46f 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ cabal.project.local~ .ghc.environment.* .cache .history -stack.yaml.lock +stack*.yaml.lock diff --git a/dhall/src/Dhall/Import.hs b/dhall/src/Dhall/Import.hs index dfc2907..ece1e96 100644 --- a/dhall/src/Dhall/Import.hs +++ b/dhall/src/Dhall/Import.hs @@ -201,6 +201,7 @@ import qualified Dhall.Parser import qualified Dhall.Pretty.Internal import qualified Dhall.TypeCheck import qualified System.Environment +import qualified System.Info import qualified System.Directory as Directory import qualified System.FilePath as FilePath import qualified Text.Megaparsec @@ -792,12 +793,25 @@ getCacheDirectory = alternative₀ <|> alternative₁ Just xdgCacheHome -> return xdgCacheHome Nothing -> empty - alternative₁ = do - maybeHomeDirectory <- liftIO (System.Environment.lookupEnv "HOME") + alternative₁ + | isWindows = do + maybeLocalAppDirectory <- + liftIO (System.Environment.lookupEnv "LOCALAPPDATA") + + case maybeLocalAppDirectory of + Just localAppDirectory -> return localAppDirectory + Nothing -> empty + + | otherwise = do + maybeHomeDirectory <- + liftIO (System.Environment.lookupEnv "HOME") + + case maybeHomeDirectory of + Just homeDirectory -> return (homeDirectory ".cache") + Nothing -> empty + + where isWindows = System.Info.os == "mingw32" - case maybeHomeDirectory of - Just homeDirectory -> return (homeDirectory ".cache") - Nothing -> empty -- If the URL contains headers typecheck them and replace them with their normal -- forms.