From a01fe5c06fc99bd66c681b981f63534e03063aee Mon Sep 17 00:00:00 2001 From: sterni Date: Fri, 19 Mar 2021 13:13:44 +0000 Subject: [PATCH] fix(gs/xanthous): fix build failures caused by dependency updates The following changes in dependencies of xanthous broke the build and have been fixed in this CL. Thus we can reenable CI for xanthous. * random 1.2.0 removed the Read instance for StdGen, so we need use System.Random.Internal to un-newtype StdGen into an SMGen in the appropriate places as that type still has a Show and Read instance. Requires a new direct dependency on splitmix as well. * witherable 4.0 renamed Data.Witherable into Witherable and no longer exports Filter. * random 1.2.0 probably also broke the Function instance for GameState which contains a StdGen. I'm not exactly sure which change exactly triggered this, but the fix is easy enough: We implement a Function instance for SMGen using functionShow allowing us to write a Function instance for StdGen using functionMap. I've put these instances into Xanthous.Orphans. * hgeometry 0.12.0.0 removes the triangulationEdges function (which is also not mentioned in the changelog, so I'm not sure if there's a replacement yet). Fix by pinning to 0.11.0.0 for now. * hedgehog-classes: relax bounds on semirings Change-Id: I3617d8916d753b386c9fa80062be6bcbdfee0131 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2607 Tested-by: BuildkiteCI Reviewed-by: glittershark --- .../haskell_overlay/default.nix | 26 +++++++++++++++++++ users/glittershark/xanthous/default.nix | 7 ++--- users/glittershark/xanthous/package.yaml | 1 + .../xanthous/src/Xanthous/Game/Arbitrary.hs | 1 + .../src/Xanthous/Messages/Template.hs | 2 +- .../xanthous/src/Xanthous/Orphans.hs | 20 +++++++++++--- .../xanthous/src/Xanthous/Prelude.hs | 4 +-- 7 files changed, 50 insertions(+), 11 deletions(-) diff --git a/third_party/nixpkgs-exposed/haskell_overlay/default.nix b/third_party/nixpkgs-exposed/haskell_overlay/default.nix index af6bbd475..4cf3cfb4c 100644 --- a/third_party/nixpkgs-exposed/haskell_overlay/default.nix +++ b/third_party/nixpkgs-exposed/haskell_overlay/default.nix @@ -15,4 +15,30 @@ self: super: with pkgs.haskell.lib; rec { test-framework = doJailbreak super.test-framework; hashable = doJailbreak super.hashable; test-framework-quickcheck2 = doJailbreak super.test-framework-quickcheck2; + + # can be removed if we have the following PR or equivalent + # https://github.com/NixOS/nixpkgs/pull/116931 + hedgehog-classes = overrideCabal super.hedgehog-classes (attrs: { + # remove version bound on semirings which is inside a + # conditional, so doJailbreak doesn't work + prePatch = '' + sed -i 's|semirings.*0.6|semirings|g' hedgehog-classes.cabal + ''; + }); + + # pin hgeometry* to 0.11.0.0 since 0.12.0.0 removes triangulationEdges + # which is used by //users/glittershark/xanthous + hgeometry = + self.callHackageDirect { + pkg = "hgeometry"; + ver = "0.11.0.0"; + sha256 = "0qidbpgs6jxrirrhmy7iabwd62178sm68fqrmqg3w3gfyx8nm8ls"; + } {}; + + hgeometry-combinatorial = + self.callHackageDirect { + pkg = "hgeometry-combinatorial"; + ver = "0.11.0.0"; + sha256 = "0c9ccqz1m45kkdkzw00gvzdspjljhg12vish6himqjqpms7g6sag"; + } {}; } diff --git a/users/glittershark/xanthous/default.nix b/users/glittershark/xanthous/default.nix index 8dfd0bce4..0b89a50af 100644 --- a/users/glittershark/xanthous/default.nix +++ b/users/glittershark/xanthous/default.nix @@ -2,9 +2,6 @@ , lib ? pkgs.lib , ... }: -(pkgs.haskell.lib.failOnAllWarnings ( +pkgs.haskell.lib.failOnAllWarnings ( pkgs.haskellPackages.callPackage (import ./pkg.nix { inherit pkgs; }) {} -)) // { - # TODO(grfn): Get this passing (see https://buildkite.com/tvl/depot/builds/3055) - meta.ci = false; -} +) diff --git a/users/glittershark/xanthous/package.yaml b/users/glittershark/xanthous/package.yaml index e954374f8..e8cda5969 100644 --- a/users/glittershark/xanthous/package.yaml +++ b/users/glittershark/xanthous/package.yaml @@ -65,6 +65,7 @@ dependencies: - raw-strings-qq - reflection - Rasterific +- splitmix - streams - stache - semigroupoids diff --git a/users/glittershark/xanthous/src/Xanthous/Game/Arbitrary.hs b/users/glittershark/xanthous/src/Xanthous/Game/Arbitrary.hs index a1eb789a3..1b15ad4ff 100644 --- a/users/glittershark/xanthous/src/Xanthous/Game/Arbitrary.hs +++ b/users/glittershark/xanthous/src/Xanthous/Game/Arbitrary.hs @@ -16,6 +16,7 @@ import qualified Xanthous.Data.EntityMap as EntityMap import Xanthous.Entities.Entities () import Xanthous.Entities.Character import Xanthous.Game.State +import Xanthous.Orphans () import Xanthous.Util.QuickCheck (GenericArbitrary(..)) -------------------------------------------------------------------------------- diff --git a/users/glittershark/xanthous/src/Xanthous/Messages/Template.hs b/users/glittershark/xanthous/src/Xanthous/Messages/Template.hs index 2998db7f7..517688035 100644 --- a/users/glittershark/xanthous/src/Xanthous/Messages/Template.hs +++ b/users/glittershark/xanthous/src/Xanthous/Messages/Template.hs @@ -28,7 +28,7 @@ module Xanthous.Messages.Template where -------------------------------------------------------------------------------- import Xanthous.Prelude hiding - (many, concat, try, elements, some, parts, Filter) + (many, concat, try, elements, some, parts) -------------------------------------------------------------------------------- import Test.QuickCheck hiding (label) import Test.QuickCheck.Instances.Text () diff --git a/users/glittershark/xanthous/src/Xanthous/Orphans.hs b/users/glittershark/xanthous/src/Xanthous/Orphans.hs index 39821150e..1fe9708ed 100644 --- a/users/glittershark/xanthous/src/Xanthous/Orphans.hs +++ b/users/glittershark/xanthous/src/Xanthous/Orphans.hs @@ -18,7 +18,8 @@ import Graphics.Vty.Attributes import Brick.Widgets.Edit import Data.Text.Zipper.Generic (GenericTextZipper) import Brick.Widgets.Core (getName) -import System.Random (StdGen) +import System.Random.Internal (StdGen (..)) +import System.Random.SplitMix (SMGen ()) import Test.QuickCheck import "quickcheck-instances" Test.QuickCheck.Instances () import Text.Megaparsec (errorBundlePretty) @@ -304,8 +305,15 @@ instance forall t name. (NFData t, Monoid t, NFData name) => NFData (Editor t name) where rnf ed = getName @_ @name ed `deepseq` getEditContents ed `deepseq` () -deriving via (ReadShowJSON StdGen) instance ToJSON StdGen -deriving via (ReadShowJSON StdGen) instance FromJSON StdGen +deriving via (ReadShowJSON SMGen) instance ToJSON SMGen +deriving via (ReadShowJSON SMGen) instance FromJSON SMGen + +instance ToJSON StdGen where + toJSON = toJSON . unStdGen + toEncoding = toEncoding . unStdGen + +instance FromJSON StdGen where + parseJSON = fmap StdGen . parseJSON -------------------------------------------------------------------------------- @@ -326,6 +334,12 @@ instance forall t n. (CoArbitrary t, CoArbitrary n, Monoid t) instance CoArbitrary StdGen where coarbitrary = coarbitrary . show +instance Function StdGen where + function = functionMap unStdGen StdGen + +instance Function SMGen where + function = functionShow + -------------------------------------------------------------------------------- deriving newtype instance (Arbitrary s, CoArbitrary (m (a, s))) diff --git a/users/glittershark/xanthous/src/Xanthous/Prelude.hs b/users/glittershark/xanthous/src/Xanthous/Prelude.hs index 9bec777de..4d79b026f 100644 --- a/users/glittershark/xanthous/src/Xanthous/Prelude.hs +++ b/users/glittershark/xanthous/src/Xanthous/Prelude.hs @@ -7,7 +7,7 @@ module Xanthous.Prelude , module Control.Lens , module Data.Void , module Control.Comonad - , module Data.Witherable + , module Witherable , fail , (&!) @@ -27,7 +27,7 @@ import GHC.TypeLits hiding (Text) import Control.Lens hiding (levels, Level) import Data.Void import Control.Comonad -import Data.Witherable +import Witherable import Control.Monad.Fail (fail) --------------------------------------------------------------------------------