From ca7ff4aafc601221277ad8635c7a68f48ea386a1 Mon Sep 17 00:00:00 2001 From: Stephan Barth Date: Thu, 25 Jan 2024 17:33:40 +0100 Subject: [PATCH] Removed overlapping Instances; implemented Bits for Word24; added missing libraries --- shell.nix | 2 +- src/Data/Time/Calendar/Instances.hs | 6 +++--- src/Data/Time/LocalTime/Instances.hs | 2 -- src/Data/Word/Word24.hs | 30 ++++++++++++++++++++++++++-- src/Language/Haskell/TH/Instances.hs | 10 +++++----- src/Utils/Pool.hs | 2 +- 6 files changed, 38 insertions(+), 14 deletions(-) diff --git a/shell.nix b/shell.nix index 4bf791a49..7603cb73f 100644 --- a/shell.nix +++ b/shell.nix @@ -275,7 +275,7 @@ in pkgs.mkShell { ''; nativeBuildInputs = [develop inDevelop killallUni2work diffRunning] ++ (with pkgs; - [ stdenv coreutils stack nodejs_21 postgresql_12 openldap exiftool expat bzip2 memcached minio minio-client + [ stdenv coreutils stack nodejs_21 postgresql_12 openldap exiftool expat bzip2 glibc memcached minio minio-client gup reuse pre-commit # busybox # for print services, but interferes with build commands in develop-shell htop diff --git a/src/Data/Time/Calendar/Instances.hs b/src/Data/Time/Calendar/Instances.hs index f51d09886..5d125685c 100644 --- a/src/Data/Time/Calendar/Instances.hs +++ b/src/Data/Time/Calendar/Instances.hs @@ -15,12 +15,12 @@ import Data.Time.Calendar import Data.Universe import Language.Haskell.TH.Syntax (Lift) -import Type.Reflection +--import Type.Reflection deriving instance Lift Day -instance Hashable Day where - hashWithSalt s (ModifiedJulianDay jDay) = s `hashWithSalt` hash (typeRep @Day) `hashWithSalt` jDay +--instance Hashable Day where +-- hashWithSalt s (ModifiedJulianDay jDay) = s `hashWithSalt` hash (typeRep @Day) `hashWithSalt` jDay -- -- Available since time-1.11 -- deriving instance Ord DayOfWeek diff --git a/src/Data/Time/LocalTime/Instances.hs b/src/Data/Time/LocalTime/Instances.hs index f0f8c449f..a10bfacb1 100644 --- a/src/Data/Time/LocalTime/Instances.hs +++ b/src/Data/Time/LocalTime/Instances.hs @@ -17,7 +17,5 @@ import qualified Language.Haskell.TH.Syntax as TH deriving instance Generic TimeOfDay -instance Hashable TimeOfDay - deriving instance TH.Lift TimeZone diff --git a/src/Data/Word/Word24.hs b/src/Data/Word/Word24.hs index eb5f1b1f3..330051a09 100644 --- a/src/Data/Word/Word24.hs +++ b/src/Data/Word/Word24.hs @@ -1,13 +1,21 @@ +-- unfortunately we need a deprecated thing in here: typeclass Bits has +-- bitSize both in the minimal set as well as marked as deprecated. +-- Hence, it fails to compile without bitSize but throws a warning +-- with it. When every warning is an error it does no compile in any +-- case, therefore we have deprecated only as warning so that it +-- compiles at least. +{-# OPTIONS_GHC -Wwarn=deprecations #-} + module Data.Word.Word24 ( Word24 ) where -import Data.Word +import ClassyPrelude -import Import.NoModel import Data.Bits + newtype Word24 = Word24 Word32 maxWord24 :: Num a => a @@ -46,3 +54,21 @@ instance Integral Word24 where let (u,v) = quotRem a b in (word24 u, word24 v) toInteger (Word24 w) = toInteger w + +instance Bits Word24 where + (.&.) (Word24 a) (Word24 b) = word24 (a .&. b) + (.|.) (Word24 a) (Word24 b) = word24 (a .|. b) + xor (Word24 a) (Word24 b) = word24 (xor a b) + complement (Word24 a) = word24 (complement a) + shift (Word24 a) i = word24 (shift a i) + rotate (Word24 a) i = word24 (rotate a i) + bitSize (Word24 a) = bitSize a -- it is listed as part of the minimal implementation, but it is denoted as deprecated elsewhere + bitSizeMaybe (Word24 a) = bitSizeMaybe a + isSigned (Word24 a) = isSigned a + testBit (Word24 a) i = testBit a i + bit = word24 . bit + popCount (Word24 a) = popCount a + + + + diff --git a/src/Language/Haskell/TH/Instances.hs b/src/Language/Haskell/TH/Instances.hs index 9169e5e51..8fa0fbb7c 100644 --- a/src/Language/Haskell/TH/Instances.hs +++ b/src/Language/Haskell/TH/Instances.hs @@ -28,9 +28,9 @@ instance Binary NameFlavour instance Binary Name -instance Semigroup (Q [Dec]) where - (<>) = liftA2 (<>) +--instance Semigroup (Q [Dec]) where +-- (<>) = liftA2 (<>) -instance Monoid (Q [Dec]) where - mempty = pure mempty - mappend = (<>) +--instance Monoid (Q [Dec]) where +-- mempty = pure mempty +-- mappend = (<>) diff --git a/src/Utils/Pool.hs b/src/Utils/Pool.hs index 7b025f8af..21b3b13fd 100644 --- a/src/Utils/Pool.hs +++ b/src/Utils/Pool.hs @@ -32,7 +32,7 @@ import System.Clock import Data.Time.Clock (DiffTime) import Control.Concurrent.STM.Delay -import Control.Concurrent.STM.TVar (stateTVar) +--import Control.Concurrent.STM.TVar (stateTVar) import Control.Monad.Writer.Strict (runWriter) import Control.Monad.Writer.Class (MonadWriter(..))