diff --git a/src/Data/Universe/TH.hs b/src/Data/Universe/TH.hs index 3f0452556..ef10054eb 100644 --- a/src/Data/Universe/TH.hs +++ b/src/Data/Universe/TH.hs @@ -1,4 +1,4 @@ --- SPDX-FileCopyrightText: 2022 Gregor Kleen ,Sarah Vaupel +-- SPDX-FileCopyrightText: 2024 Stephan Barth , 2022 Gregor Kleen ,Sarah Vaupel -- -- SPDX-License-Identifier: AGPL-3.0-or-later @@ -24,13 +24,14 @@ import Data.Containers.ListUtils import Control.Lens hiding (universe) import Data.Generics.Product.Types +--import Language.Haskell.TH.Datatype.TyVarBndr -- | Get type var bind name -- --- Stolen from https://hackage.haskell.org/package/template-haskell-util-0.1.1.0 -getTVBName :: TyVarBndr -> Name -getTVBName (PlainTV name ) = name -getTVBName (KindedTV name _) = name +-- Stolen from https://hackage.haskell.org/package/template-haskell-util-0.1.1.0; modified by Stephan Barth +getTVBName :: TyVarBndr flag -> Name +getTVBName (PlainTV name _) = name +getTVBName (KindedTV name _ _) = name diff --git a/src/Data/Void/Instances.hs b/src/Data/Void/Instances.hs index 692f742df..a94cb4f70 100644 --- a/src/Data/Void/Instances.hs +++ b/src/Data/Void/Instances.hs @@ -10,10 +10,10 @@ module Data.Void.Instances import ClassyPrelude.Yesod import Data.Void -instance ToContent Void where - toContent = absurd -instance ToTypedContent Void where - toTypedContent = absurd +--instance ToContent Void where +-- toContent = absurd +--instance ToTypedContent Void where +-- toTypedContent = absurd instance RenderMessage site Void where renderMessage _ _ = absurd diff --git a/src/Data/Word/Word24.hs b/src/Data/Word/Word24.hs new file mode 100644 index 000000000..eb5f1b1f3 --- /dev/null +++ b/src/Data/Word/Word24.hs @@ -0,0 +1,48 @@ + +module Data.Word.Word24 + ( Word24 + ) where + +import Data.Word + +import Import.NoModel +import Data.Bits + +newtype Word24 = Word24 Word32 + +maxWord24 :: Num a => a +maxWord24 = 16777215 + +instance Bounded Word24 where + minBound = 0 + maxBound = maxWord24 + +word24 :: Word32 -> Word24 +word24 = assert (maxWord24 == 2^24-1) (Word24 . (.&. maxWord24)) + +instance Num Word24 where + (+) (Word24 a) (Word24 b) = word24 (a + b) + (*) (Word24 a) (Word24 b) = word24 (a * b) + abs (Word24 a) = word24 (abs a) + signum (Word24 a) = word24 (signum a) + fromInteger i = word24 (fromInteger i) + negate (Word24 a) = word24 (negate a) + +instance Eq Word24 where + (==) (Word24 a) (Word24 b) = a == b + +instance Ord Word24 where + compare (Word24 a) (Word24 b) = compare a b + +instance Real Word24 where + toRational (Word24 a) = toRational a + +instance Enum Word24 where + toEnum k = word24 (toEnum k) + fromEnum (Word24 k) = fromEnum k + +instance Integral Word24 where + quotRem (Word24 a) (Word24 b) = + let (u,v) = quotRem a b in + (word24 u, word24 v) + toInteger (Word24 w) = toInteger w