Drop yaml/libyaml
This commit is contained in:
		
							parent
							
								
									13143b8e4d
								
							
						
					
					
						commit
						d98e54a743
					
				@ -35,7 +35,7 @@ import           Text.PrettyPrint.HughesPJClass ( prettyShow )
 | 
				
			|||||||
import qualified Data.Text.IO                  as T
 | 
					import qualified Data.Text.IO                  as T
 | 
				
			||||||
import qualified Data.Text                     as T
 | 
					import qualified Data.Text                     as T
 | 
				
			||||||
import qualified Data.ByteString               as B
 | 
					import qualified Data.ByteString               as B
 | 
				
			||||||
import qualified Data.Yaml                     as Y
 | 
					import qualified Data.YAML.Aeson               as Y
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
data Options = Options
 | 
					data Options = Options
 | 
				
			||||||
@ -146,8 +146,8 @@ main = do
 | 
				
			|||||||
    ValidateYAMLOpts { vInput = Just (FileInput file) } ->
 | 
					    ValidateYAMLOpts { vInput = Just (FileInput file) } ->
 | 
				
			||||||
      B.readFile file >>= valAndExit f
 | 
					      B.readFile file >>= valAndExit f
 | 
				
			||||||
  valAndExit f contents = do
 | 
					  valAndExit f contents = do
 | 
				
			||||||
    (GHCupInfo _ av gt) <- case Y.decodeEither' contents of
 | 
					    (GHCupInfo _ av gt) <- case Y.decode1Strict contents of
 | 
				
			||||||
      Right r -> pure r
 | 
					      Right r -> pure r
 | 
				
			||||||
      Left  e -> die (color Red $ show e)
 | 
					      Left  (_, e) -> die (color Red $ show e)
 | 
				
			||||||
    f av gt
 | 
					    f av gt
 | 
				
			||||||
      >>= exitWith
 | 
					      >>= exitWith
 | 
				
			||||||
 | 
				
			|||||||
@ -77,8 +77,7 @@ import qualified Data.Map.Strict               as M
 | 
				
			|||||||
import qualified Data.Text                     as T
 | 
					import qualified Data.Text                     as T
 | 
				
			||||||
import qualified Data.Text.IO                  as T
 | 
					import qualified Data.Text.IO                  as T
 | 
				
			||||||
import qualified Data.Text.Encoding            as E
 | 
					import qualified Data.Text.Encoding            as E
 | 
				
			||||||
import qualified Data.Yaml                     as Y
 | 
					import qualified Data.YAML.Aeson               as Y
 | 
				
			||||||
import qualified Data.Yaml.Pretty              as YP
 | 
					 | 
				
			||||||
import qualified Text.Megaparsec               as MP
 | 
					import qualified Text.Megaparsec               as MP
 | 
				
			||||||
import qualified Text.Megaparsec.Char          as MPC
 | 
					import qualified Text.Megaparsec.Char          as MPC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1318,7 +1317,7 @@ toSettings options = do
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
updateSettings :: Monad m => UTF8.ByteString -> Settings -> Excepts '[JSONError] m Settings
 | 
					updateSettings :: Monad m => UTF8.ByteString -> Settings -> Excepts '[JSONError] m Settings
 | 
				
			||||||
updateSettings config settings = do
 | 
					updateSettings config settings = do
 | 
				
			||||||
  settings' <- lE' JSONDecodeError . first show . Y.decodeEither' $ config
 | 
					  settings' <- lE' JSONDecodeError . first snd . Y.decode1Strict $ config
 | 
				
			||||||
  pure $ mergeConf settings' settings
 | 
					  pure $ mergeConf settings' settings
 | 
				
			||||||
  where
 | 
					  where
 | 
				
			||||||
   mergeConf :: UserSettings -> Settings -> Settings
 | 
					   mergeConf :: UserSettings -> Settings -> Settings
 | 
				
			||||||
@ -1377,9 +1376,7 @@ plan_json = $( LitE . StringL <$>
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
formatConfig :: UserSettings -> String
 | 
					formatConfig :: UserSettings -> String
 | 
				
			||||||
formatConfig settings
 | 
					formatConfig settings
 | 
				
			||||||
  = UTF8.toString . YP.encodePretty yamlConfig $ settings
 | 
					  = UTF8.toString . Y.encode1Strict $ settings
 | 
				
			||||||
 where
 | 
					 | 
				
			||||||
  yamlConfig = YP.setConfCompare compare YP.defConfig
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
main :: IO ()
 | 
					main :: IO ()
 | 
				
			||||||
main = do
 | 
					main = do
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,9 @@ constraints: any.Cabal ==3.2.1.0,
 | 
				
			|||||||
             any.HUnit ==1.6.2.0,
 | 
					             any.HUnit ==1.6.2.0,
 | 
				
			||||||
             any.HsOpenSSL ==0.11.7.1,
 | 
					             any.HsOpenSSL ==0.11.7.1,
 | 
				
			||||||
             HsOpenSSL -fast-bignum -homebrew-openssl -macports-openssl -use-pkg-config,
 | 
					             HsOpenSSL -fast-bignum -homebrew-openssl -macports-openssl -use-pkg-config,
 | 
				
			||||||
 | 
					             any.HsYAML ==0.2.1.0,
 | 
				
			||||||
 | 
					             HsYAML -exe,
 | 
				
			||||||
 | 
					             any.HsYAML-aeson ==0.2.0.0,
 | 
				
			||||||
             any.QuickCheck ==2.14.2,
 | 
					             any.QuickCheck ==2.14.2,
 | 
				
			||||||
             QuickCheck -old-random +templatehaskell,
 | 
					             QuickCheck -old-random +templatehaskell,
 | 
				
			||||||
             any.StateVar ==1.2.2,
 | 
					             any.StateVar ==1.2.2,
 | 
				
			||||||
@ -55,7 +58,6 @@ constraints: any.Cabal ==3.2.1.0,
 | 
				
			|||||||
             any.composition-prelude ==3.0.0.2,
 | 
					             any.composition-prelude ==3.0.0.2,
 | 
				
			||||||
             composition-prelude -development,
 | 
					             composition-prelude -development,
 | 
				
			||||||
             any.concurrent-output ==1.10.12,
 | 
					             any.concurrent-output ==1.10.12,
 | 
				
			||||||
             any.conduit ==1.3.4.1,
 | 
					 | 
				
			||||||
             any.config-ini ==0.2.4.0,
 | 
					             any.config-ini ==0.2.4.0,
 | 
				
			||||||
             config-ini -enable-doctests,
 | 
					             config-ini -enable-doctests,
 | 
				
			||||||
             any.containers ==0.6.5.1,
 | 
					             any.containers ==0.6.5.1,
 | 
				
			||||||
@ -109,15 +111,12 @@ constraints: any.Cabal ==3.2.1.0,
 | 
				
			|||||||
             language-c -allwarnings +iecfpextension +usebytestrings,
 | 
					             language-c -allwarnings +iecfpextension +usebytestrings,
 | 
				
			||||||
             any.libarchive ==3.0.2.2,
 | 
					             any.libarchive ==3.0.2.2,
 | 
				
			||||||
             libarchive -cross -low-memory -system-libarchive,
 | 
					             libarchive -cross -low-memory -system-libarchive,
 | 
				
			||||||
             any.libyaml ==0.1.2,
 | 
					 | 
				
			||||||
             libyaml -no-unicode -system-libyaml,
 | 
					 | 
				
			||||||
             any.lzma-static ==5.2.5.4,
 | 
					             any.lzma-static ==5.2.5.4,
 | 
				
			||||||
             any.megaparsec ==9.0.1,
 | 
					             any.megaparsec ==9.0.1,
 | 
				
			||||||
             megaparsec -dev,
 | 
					             megaparsec -dev,
 | 
				
			||||||
             any.microlens ==0.4.12.0,
 | 
					             any.microlens ==0.4.12.0,
 | 
				
			||||||
             any.microlens-mtl ==0.2.0.1,
 | 
					             any.microlens-mtl ==0.2.0.1,
 | 
				
			||||||
             any.microlens-th ==0.4.3.10,
 | 
					             any.microlens-th ==0.4.3.10,
 | 
				
			||||||
             any.mono-traversable ==1.0.15.1,
 | 
					 | 
				
			||||||
             any.mtl ==2.2.2,
 | 
					             any.mtl ==2.2.2,
 | 
				
			||||||
             any.network ==3.1.2.2,
 | 
					             any.network ==3.1.2.2,
 | 
				
			||||||
             network -devel,
 | 
					             network -devel,
 | 
				
			||||||
@ -203,15 +202,11 @@ constraints: any.Cabal ==3.2.1.0,
 | 
				
			|||||||
             any.uuid-types ==1.0.5,
 | 
					             any.uuid-types ==1.0.5,
 | 
				
			||||||
             any.vector ==0.12.3.0,
 | 
					             any.vector ==0.12.3.0,
 | 
				
			||||||
             vector +boundschecks -internalchecks -unsafechecks -wall,
 | 
					             vector +boundschecks -internalchecks -unsafechecks -wall,
 | 
				
			||||||
             any.vector-algorithms ==0.8.0.4,
 | 
					 | 
				
			||||||
             vector-algorithms +bench +boundschecks -internalchecks -llvm +properties -unsafechecks,
 | 
					 | 
				
			||||||
             any.versions ==5.0.0,
 | 
					             any.versions ==5.0.0,
 | 
				
			||||||
             any.vty ==5.33,
 | 
					             any.vty ==5.33,
 | 
				
			||||||
             any.word-wrap ==0.4.1,
 | 
					             any.word-wrap ==0.4.1,
 | 
				
			||||||
             any.word8 ==0.1.3,
 | 
					             any.word8 ==0.1.3,
 | 
				
			||||||
             any.xor ==0.0.1.0,
 | 
					             any.xor ==0.0.1.0,
 | 
				
			||||||
             any.yaml ==0.11.5.0,
 | 
					 | 
				
			||||||
             yaml +no-examples +no-exe,
 | 
					 | 
				
			||||||
             any.zlib ==0.6.2.3,
 | 
					             any.zlib ==0.6.2.3,
 | 
				
			||||||
             zlib -bundled-c-zlib -non-blocking-ffi -pkg-config,
 | 
					             zlib -bundled-c-zlib -non-blocking-ffi -pkg-config,
 | 
				
			||||||
             any.zlib-bindings ==0.1.1.5
 | 
					             any.zlib-bindings ==0.1.1.5
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,9 @@ constraints: any.Cabal ==3.4.0.0,
 | 
				
			|||||||
             any.HUnit ==1.6.2.0,
 | 
					             any.HUnit ==1.6.2.0,
 | 
				
			||||||
             any.HsOpenSSL ==0.11.7.1,
 | 
					             any.HsOpenSSL ==0.11.7.1,
 | 
				
			||||||
             HsOpenSSL -fast-bignum -homebrew-openssl -macports-openssl -use-pkg-config,
 | 
					             HsOpenSSL -fast-bignum -homebrew-openssl -macports-openssl -use-pkg-config,
 | 
				
			||||||
 | 
					             any.HsYAML ==0.2.1.0,
 | 
				
			||||||
 | 
					             HsYAML -exe,
 | 
				
			||||||
 | 
					             any.HsYAML-aeson ==0.2.0.0,
 | 
				
			||||||
             any.QuickCheck ==2.14.2,
 | 
					             any.QuickCheck ==2.14.2,
 | 
				
			||||||
             QuickCheck -old-random +templatehaskell,
 | 
					             QuickCheck -old-random +templatehaskell,
 | 
				
			||||||
             any.StateVar ==1.2.2,
 | 
					             any.StateVar ==1.2.2,
 | 
				
			||||||
@ -55,7 +58,6 @@ constraints: any.Cabal ==3.4.0.0,
 | 
				
			|||||||
             any.composition-prelude ==3.0.0.2,
 | 
					             any.composition-prelude ==3.0.0.2,
 | 
				
			||||||
             composition-prelude -development,
 | 
					             composition-prelude -development,
 | 
				
			||||||
             any.concurrent-output ==1.10.12,
 | 
					             any.concurrent-output ==1.10.12,
 | 
				
			||||||
             any.conduit ==1.3.4.1,
 | 
					 | 
				
			||||||
             any.config-ini ==0.2.4.0,
 | 
					             any.config-ini ==0.2.4.0,
 | 
				
			||||||
             config-ini -enable-doctests,
 | 
					             config-ini -enable-doctests,
 | 
				
			||||||
             any.containers ==0.6.4.1,
 | 
					             any.containers ==0.6.4.1,
 | 
				
			||||||
@ -109,15 +111,12 @@ constraints: any.Cabal ==3.4.0.0,
 | 
				
			|||||||
             language-c -allwarnings +iecfpextension +usebytestrings,
 | 
					             language-c -allwarnings +iecfpextension +usebytestrings,
 | 
				
			||||||
             any.libarchive ==3.0.2.2,
 | 
					             any.libarchive ==3.0.2.2,
 | 
				
			||||||
             libarchive -cross -low-memory -system-libarchive,
 | 
					             libarchive -cross -low-memory -system-libarchive,
 | 
				
			||||||
             any.libyaml ==0.1.2,
 | 
					 | 
				
			||||||
             libyaml -no-unicode -system-libyaml,
 | 
					 | 
				
			||||||
             any.lzma-static ==5.2.5.4,
 | 
					             any.lzma-static ==5.2.5.4,
 | 
				
			||||||
             any.megaparsec ==9.0.1,
 | 
					             any.megaparsec ==9.0.1,
 | 
				
			||||||
             megaparsec -dev,
 | 
					             megaparsec -dev,
 | 
				
			||||||
             any.microlens ==0.4.12.0,
 | 
					             any.microlens ==0.4.12.0,
 | 
				
			||||||
             any.microlens-mtl ==0.2.0.1,
 | 
					             any.microlens-mtl ==0.2.0.1,
 | 
				
			||||||
             any.microlens-th ==0.4.3.10,
 | 
					             any.microlens-th ==0.4.3.10,
 | 
				
			||||||
             any.mono-traversable ==1.0.15.1,
 | 
					 | 
				
			||||||
             any.mtl ==2.2.2,
 | 
					             any.mtl ==2.2.2,
 | 
				
			||||||
             any.network ==3.1.2.2,
 | 
					             any.network ==3.1.2.2,
 | 
				
			||||||
             network -devel,
 | 
					             network -devel,
 | 
				
			||||||
@ -203,15 +202,11 @@ constraints: any.Cabal ==3.4.0.0,
 | 
				
			|||||||
             any.uuid-types ==1.0.5,
 | 
					             any.uuid-types ==1.0.5,
 | 
				
			||||||
             any.vector ==0.12.3.0,
 | 
					             any.vector ==0.12.3.0,
 | 
				
			||||||
             vector +boundschecks -internalchecks -unsafechecks -wall,
 | 
					             vector +boundschecks -internalchecks -unsafechecks -wall,
 | 
				
			||||||
             any.vector-algorithms ==0.8.0.4,
 | 
					 | 
				
			||||||
             vector-algorithms +bench +boundschecks -internalchecks -llvm +properties -unsafechecks,
 | 
					 | 
				
			||||||
             any.versions ==5.0.0,
 | 
					             any.versions ==5.0.0,
 | 
				
			||||||
             any.vty ==5.33,
 | 
					             any.vty ==5.33,
 | 
				
			||||||
             any.word-wrap ==0.4.1,
 | 
					             any.word-wrap ==0.4.1,
 | 
				
			||||||
             any.word8 ==0.1.3,
 | 
					             any.word8 ==0.1.3,
 | 
				
			||||||
             any.xor ==0.0.1.0,
 | 
					             any.xor ==0.0.1.0,
 | 
				
			||||||
             any.yaml ==0.11.5.0,
 | 
					 | 
				
			||||||
             yaml +no-examples +no-exe,
 | 
					 | 
				
			||||||
             any.zlib ==0.6.2.3,
 | 
					             any.zlib ==0.6.2.3,
 | 
				
			||||||
             zlib -bundled-c-zlib -non-blocking-ffi -pkg-config,
 | 
					             zlib -bundled-c-zlib -non-blocking-ffi -pkg-config,
 | 
				
			||||||
             any.zlib-bindings ==0.1.1.5
 | 
					             any.zlib-bindings ==0.1.1.5
 | 
				
			||||||
 | 
				
			|||||||
@ -132,7 +132,7 @@ library
 | 
				
			|||||||
    , vector                ^>=0.12
 | 
					    , vector                ^>=0.12
 | 
				
			||||||
    , versions              >=4.0.1      && <5.1
 | 
					    , versions              >=4.0.1      && <5.1
 | 
				
			||||||
    , word8                 ^>=0.1.3
 | 
					    , word8                 ^>=0.1.3
 | 
				
			||||||
    , yaml                  ^>=0.11.4.0
 | 
					    , HsYAML-aeson          ^>=0.2.0.0
 | 
				
			||||||
    , zlib                  ^>=0.6.2.2
 | 
					    , zlib                  ^>=0.6.2.2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (flag(internal-downloader) && !os(windows))
 | 
					  if (flag(internal-downloader) && !os(windows))
 | 
				
			||||||
@ -208,7 +208,7 @@ executable ghcup
 | 
				
			|||||||
    , uri-bytestring        ^>=0.3.2.2
 | 
					    , uri-bytestring        ^>=0.3.2.2
 | 
				
			||||||
    , utf8-string           ^>=1.0
 | 
					    , utf8-string           ^>=1.0
 | 
				
			||||||
    , versions              >=4.0.1    && <5.1
 | 
					    , versions              >=4.0.1    && <5.1
 | 
				
			||||||
    , yaml                  ^>=0.11.4.0
 | 
					    , HsYAML-aeson          ^>=0.2.0.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if flag(internal-downloader)
 | 
					  if flag(internal-downloader)
 | 
				
			||||||
    cpp-options: -DINTERNAL_DOWNLOADER
 | 
					    cpp-options: -DINTERNAL_DOWNLOADER
 | 
				
			||||||
@ -268,7 +268,7 @@ executable ghcup-gen
 | 
				
			|||||||
    , text                  ^>=1.2.4.0
 | 
					    , text                  ^>=1.2.4.0
 | 
				
			||||||
    , transformers          ^>=0.5
 | 
					    , transformers          ^>=0.5
 | 
				
			||||||
    , versions              >=4.0.1    && <5.1
 | 
					    , versions              >=4.0.1    && <5.1
 | 
				
			||||||
    , yaml                  ^>=0.11.4.0
 | 
					    , HsYAML-aeson          ^>=0.2.0.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test-suite ghcup-test
 | 
					test-suite ghcup-test
 | 
				
			||||||
  type:               exitcode-stdio-1.0
 | 
					  type:               exitcode-stdio-1.0
 | 
				
			||||||
 | 
				
			|||||||
@ -86,7 +86,7 @@ import qualified Data.Map.Strict               as M
 | 
				
			|||||||
import qualified Data.Text                     as T
 | 
					import qualified Data.Text                     as T
 | 
				
			||||||
import qualified Data.Text.IO                  as T
 | 
					import qualified Data.Text.IO                  as T
 | 
				
			||||||
import qualified Data.Text.Encoding            as E
 | 
					import qualified Data.Text.Encoding            as E
 | 
				
			||||||
import qualified Data.Yaml                     as Y
 | 
					import qualified Data.YAML.Aeson               as Y
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -183,16 +183,15 @@ getBase uri = do
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  -- if we didn't get a filepath from the download, use the cached yaml
 | 
					  -- if we didn't get a filepath from the download, use the cached yaml
 | 
				
			||||||
  actualYaml <- maybe (lift $ yamlFromCache uri) pure mYaml
 | 
					  actualYaml <- maybe (lift $ yamlFromCache uri) pure mYaml
 | 
				
			||||||
 | 
					  yamlContents <- liftIO $ L.readFile actualYaml
 | 
				
			||||||
  lift $ logDebug $ "Decoding yaml at: " <> T.pack actualYaml
 | 
					  lift $ logDebug $ "Decoding yaml at: " <> T.pack actualYaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  liftE
 | 
					  liftE
 | 
				
			||||||
    . onE_ (onError actualYaml)
 | 
					    . onE_ (onError actualYaml)
 | 
				
			||||||
    . lEM' @_ @_ @'[JSONError] JSONDecodeError
 | 
					    . lE' @_ @_ @'[JSONError] JSONDecodeError
 | 
				
			||||||
    . fmap (first (\e -> unlines [displayException e
 | 
					    . first (\(_, e) -> unlines [e, "Consider removing " <> actualYaml <> " manually."])
 | 
				
			||||||
                                 ,"Consider removing " <> actualYaml <> " manually."]))
 | 
					    . Y.decode1
 | 
				
			||||||
    . liftIO
 | 
					    $ yamlContents
 | 
				
			||||||
    . Y.decodeFileEither
 | 
					 | 
				
			||||||
    $ actualYaml
 | 
					 | 
				
			||||||
 where
 | 
					 where
 | 
				
			||||||
  -- On error, remove the etags file and set access time to 0. This should ensure the next invocation
 | 
					  -- On error, remove the etags file and set access time to 0. This should ensure the next invocation
 | 
				
			||||||
  -- may re-download and succeed.
 | 
					  -- may re-download and succeed.
 | 
				
			||||||
 | 
				
			|||||||
@ -58,7 +58,7 @@ import           System.IO.Temp
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import qualified Data.ByteString               as BS
 | 
					import qualified Data.ByteString               as BS
 | 
				
			||||||
import qualified Data.Text                     as T
 | 
					import qualified Data.Text                     as T
 | 
				
			||||||
import qualified Data.Yaml                     as Y
 | 
					import qualified Data.YAML.Aeson               as Y
 | 
				
			||||||
import qualified Text.Megaparsec               as MP
 | 
					import qualified Text.Megaparsec               as MP
 | 
				
			||||||
import Control.Concurrent (threadDelay)
 | 
					import Control.Concurrent (threadDelay)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -221,7 +221,7 @@ ghcupConfigFile = do
 | 
				
			|||||||
  contents <- liftIO $ handleIO' NoSuchThing (\_ -> pure Nothing) $ Just <$> BS.readFile filepath
 | 
					  contents <- liftIO $ handleIO' NoSuchThing (\_ -> pure Nothing) $ Just <$> BS.readFile filepath
 | 
				
			||||||
  case contents of
 | 
					  case contents of
 | 
				
			||||||
      Nothing -> pure defaultUserSettings
 | 
					      Nothing -> pure defaultUserSettings
 | 
				
			||||||
      Just contents' -> lE' JSONDecodeError . first show . Y.decodeEither' $ contents'
 | 
					      Just contents' -> lE' JSONDecodeError . first snd . Y.decode1Strict $ contents'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -------------------------
 | 
					    -------------------------
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user