Removed overlapping Instances; implemented Bits for Word24; added missing libraries

This commit is contained in:
Stephan Barth 2024-01-25 17:33:40 +01:00
parent 4f9a9db13f
commit ca7ff4aafc
6 changed files with 38 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -17,7 +17,5 @@ import qualified Language.Haskell.TH.Syntax as TH
deriving instance Generic TimeOfDay
instance Hashable TimeOfDay
deriving instance TH.Lift TimeZone

View File

@ -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

View File

@ -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 = (<>)

View File

@ -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(..))