packages feed

recover-rtti 0.4.3 → 0.5.0

raw patch · 15 files changed

+283/−53 lines, 15 filesdep +data-array-bytedep +ghc-internaldep ~aesondep ~basedep ~bytestringPVP ok

version bump matches the API change (PVP)

Dependencies added: data-array-byte, ghc-internal

Dependency ranges changed: aeson, base, bytestring, containers, ghc-heap, ghc-prim, primitive, text

API changes (from Hackage documentation)

+ Debug.RecoverRTTI: SomeMutableByteArray :: MutableByteArray RealWorld -> SomeMutableByteArray
+ Debug.RecoverRTTI: [C_ByteArray] :: PrimClassifier ByteArray
+ Debug.RecoverRTTI: [C_MutableByteArray] :: PrimClassifier SomeMutableByteArray
+ Debug.RecoverRTTI: newtype SomeMutableByteArray
- Debug.RecoverRTTI: pattern TCons :: forall xs'. (SListI xs', IsValidSize (Length xs')) => forall x xs. (xs' ~ (x : xs), SListI xs, IsValidSize (Length xs)) => x -> WrappedTuple xs -> WrappedTuple xs'
+ Debug.RecoverRTTI: pattern TCons :: forall xs'. (SListI xs', IsValidSize (Length xs')) => forall x xs. (xs' ~ (x ': xs), SListI xs, IsValidSize (Length xs)) => x -> WrappedTuple xs -> WrappedTuple xs'
- Debug.RecoverRTTI: type PrimSatisfies (c :: Type -> Constraint) = (c Bool, c Char, c Double, c Float, c Int, c Int16, c Int8, c Int32, c Int64, c Integer, c Ordering, c (), c Word, c Word8, c Word16, c Word32, c Word64, c String, c ByteString, c ByteString, c ShortByteString, c Text, c Text, c Value, c SomeSTRef, c SomeTVar, c SomeMVar, c SomeFun, c IntSet, c SomePrimArrayM, c SomeStorableVector, c SomeStorableVectorM, c SomePrimitiveVector, c SomePrimitiveVectorM)
+ Debug.RecoverRTTI: type PrimSatisfies (c :: Type -> Constraint) = (c Bool, c Char, c Double, c Float, c Int, c Int16, c Int8, c Int32, c Int64, c Integer, c Ordering, c (), c Word, c Word8, c Word16, c Word32, c Word64, c String, c ByteString, c ByteString, c Text, c Text, c ShortByteString, c Value, c SomeSTRef, c SomeTVar, c SomeMVar, c SomeFun, c IntSet, c SomePrimArrayM, c SomeStorableVector, c SomeStorableVectorM, c SomePrimitiveVector, c SomePrimitiveVectorM, c ByteArray, c SomeMutableByteArray)

Files

CHANGELOG.md view
@@ -1,5 +1,12 @@ # Revision history for recover-rtti +## 0.5.0 -- 2024-06-12++* Support ghc 9.8 and 9.10, including bytestring 0.12+* Support `ByteArray` and `MutableByteArray`+* Relax bounds (Marcin Szamotulski, #38)+* Drop support for ghc 8.8+ ## 0.4.3 -- 2023-06-05  * Support aeson 2.1, vector 0.13, and primitive 0.8
recover-rtti.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               recover-rtti-version:            0.4.3+version:            0.5.0 synopsis:           Recover run-time type information from the GHC heap description:        The main function in this package is 'classify', which looks                     at the GHC heap to recover type information about arbitrary@@ -20,12 +20,13 @@     README.md     CHANGELOG.md -Tested-With: GHC ==8.8.4-              || ==8.10.7+Tested-With: GHC ==8.10.7               || ==9.0.2               || ==9.2.7               || ==9.4.5               || ==9.6.2+              || ==9.8.2+              || ==9.10.1  source-repository head   type:     git@@ -50,15 +51,15 @@                       Debug.RecoverRTTI.Util                       Debug.RecoverRTTI.Wrappers -    build-depends:    base       >= 4.13 && < 4.19-                    , aeson      >= 1.4  && < 2.2-                    , bytestring >= 0.10 && < 0.12-                    , containers >= 0.6  && < 0.7-                    , ghc-heap   >= 8.8  && < 9.7-                    , ghc-prim   >= 0.5  && < 0.11+    build-depends:    base       >= 4.13 && < 4.21+                    , aeson      >= 1.4  && < 2.3+                    , bytestring >= 0.10 && < 0.13+                    , containers >= 0.6  && < 0.8+                    , ghc-heap   >= 8.8  && < 9.11+                    , ghc-prim   >= 0.5  && < 0.12                     , sop-core   >= 0.5  && < 0.6                     , stm        >= 2.5  && < 2.6-                    , text       >= 1.2  && < 2.1+                    , text       >= 1.2  && < 2.2                        -- mtl 2.3 does not have ExceptT?                     , mtl (>= 2.2 && < 2.3) || (>= 2.3.1 && < 2.4)@@ -70,7 +71,14 @@                       -- The dependencies below are the oldest versions of                       -- these packages that compile with this ghc version.                     , vector    >= 0.12.1.2 && < 0.14-                    , primitive >= 0.7      && < 0.9+                    , primitive >= 0.7      && < 0.10++    -- later versions of primitive use a compat package for Data.Array.Byte+    if impl(ghc < 9.4)+      build-depends: data-array-byte >= 0.1 && < 0.2++    if impl(ghc >= 9.10)+      build-depends: ghc-internal      hs-source-dirs:   src     default-language: Haskell2010
src/Debug/RecoverRTTI.hs view
@@ -30,6 +30,7 @@   , SomeStorableVectorM(..)   , SomePrimitiveVector(..)   , SomePrimitiveVectorM(..)+  , SomeMutableByteArray(..)     -- * Working with classifiers     -- ** Mapping   , mapClassifier
src/Debug/RecoverRTTI/CheckSame.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                 #-} {-# LANGUAGE DataKinds           #-} {-# LANGUAGE FlexibleContexts    #-} {-# LANGUAGE GADTs               #-}@@ -52,10 +53,13 @@     go C_String      C_String      = Just Refl     go C_BS_Strict   C_BS_Strict   = Just Refl     go C_BS_Lazy     C_BS_Lazy     = Just Refl-    go C_BS_Short    C_BS_Short    = Just Refl     go C_Text_Strict C_Text_Strict = Just Refl     go C_Text_Lazy   C_Text_Lazy   = Just Refl +#if !MIN_VERSION_bytestring(0,12,0)+    go C_BS_Short    C_BS_Short    = Just Refl+#endif+     -- Aeson      go C_Value C_Value = Just Refl@@ -74,6 +78,8 @@     go C_Vector_StorableM  C_Vector_StorableM  = Just Refl     go C_Vector_Primitive  C_Vector_Primitive  = Just Refl     go C_Vector_PrimitiveM C_Vector_PrimitiveM = Just Refl+    go C_ByteArray         C_ByteArray         = Just Refl+    go C_MutableByteArray  C_MutableByteArray  = Just Refl      -- Functions @@ -109,10 +115,13 @@         C_String      -> ()         C_BS_Strict   -> ()         C_BS_Lazy     -> ()-        C_BS_Short    -> ()         C_Text_Strict -> ()         C_Text_Lazy   -> () +#if !MIN_VERSION_bytestring(0,12,0)+        C_BS_Short    -> ()+#endif+         -- Aeson          C_Value -> ()@@ -131,6 +140,8 @@         C_Vector_StorableM  -> ()         C_Vector_Primitive  -> ()         C_Vector_PrimitiveM -> ()+        C_ByteArray         -> ()+        C_MutableByteArray  -> ()          -- Functions 
src/Debug/RecoverRTTI/Classifier.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                   #-} {-# LANGUAGE DataKinds             #-} {-# LANGUAGE FlexibleContexts      #-} {-# LANGUAGE GADTs                 #-}@@ -41,13 +42,17 @@  import qualified Data.ByteString             as BS.Strict import qualified Data.ByteString.Lazy        as BS.Lazy-import qualified Data.ByteString.Short       as BS.Short import qualified Data.HashMap.Internal.Array as HashMap (Array) import qualified Data.Primitive.Array        as Prim (Array)+import qualified Data.Primitive.ByteArray    as Prim (ByteArray) import qualified Data.Text                   as Text.Strict import qualified Data.Text.Lazy              as Text.Lazy import qualified Data.Vector                 as Vector.Boxed +#if !MIN_VERSION_bytestring(0,12,0)+import qualified Data.ByteString.Short as BS.Short+#endif+ import Debug.RecoverRTTI.Nat import Debug.RecoverRTTI.Tuple import Debug.RecoverRTTI.Wrappers@@ -153,10 +158,14 @@   C_String      :: PrimClassifier String   C_BS_Strict   :: PrimClassifier BS.Strict.ByteString   C_BS_Lazy     :: PrimClassifier BS.Lazy.ByteString-  C_BS_Short    :: PrimClassifier BS.Short.ShortByteString   C_Text_Strict :: PrimClassifier Text.Strict.Text   C_Text_Lazy   :: PrimClassifier Text.Lazy.Text +-- in bytestring 0.12, 'ShortByteStringSource' is a newtype around 'ByteArray'+#if !MIN_VERSION_bytestring(0,12,0)+  C_BS_Short    :: PrimClassifier BS.Short.ShortByteString+#endif+   -- Aeson    C_Value :: PrimClassifier Value@@ -182,6 +191,8 @@   C_Vector_StorableM  :: PrimClassifier SomeStorableVectorM   C_Vector_Primitive  :: PrimClassifier SomePrimitiveVector   C_Vector_PrimitiveM :: PrimClassifier SomePrimitiveVectorM+  C_ByteArray         :: PrimClassifier Prim.ByteArray+  C_MutableByteArray  :: PrimClassifier SomeMutableByteArray  {-------------------------------------------------------------------------------   Nested classification
src/Debug/RecoverRTTI/Classify.hs view
@@ -135,7 +135,9 @@ #endif       (inKnownModule DataByteStringLazyInternal  -> Just "Empty") -> return $ mustBe $ C_Prim C_BS_Lazy       (inKnownModule DataByteStringLazyInternal  -> Just "Chunk") -> return $ mustBe $ C_Prim C_BS_Lazy+#if !MIN_VERSION_bytestring(0,12,0)       (inKnownModule DataByteStringShortInternal -> Just "SBS")   -> return $ mustBe $ C_Prim C_BS_Short+#endif        -- text       (inKnownModule DataTextInternal     -> Just "Text")  -> return $ mustBe $ C_Prim C_Text_Strict@@ -251,6 +253,18 @@         mustBe <$> classifyPrimArray (unsafeCoerce x)       (inKnownModule DataPrimitiveArray -> Just "MutableArray") ->         return $ mustBe $ C_Prim C_Prim_ArrayM++#if !MIN_VERSION_primitive(0,8,0)+      (inKnownModule DataPrimitiveByteArray -> Just "ByteArray") ->+        return $ mustBe $ C_Prim C_ByteArray+      (inKnownModule DataPrimitiveByteArray -> Just "MutableByteArray") ->+        return $ mustBe $ C_Prim C_MutableByteArray+#else+      (inKnownModule DataArrayByte -> Just "ByteArray") ->+        return $ mustBe $ C_Prim C_ByteArray+      (inKnownModule DataArrayByte -> Just "MutableByteArray") ->+        return $ mustBe $ C_Prim C_MutableByteArray+#endif        -- Boxed vectors       (inKnownModule DataVector -> Just "Vector") ->
src/Debug/RecoverRTTI/Constraint.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE ConstraintKinds         #-}+{-# LANGUAGE CPP                     #-} {-# LANGUAGE DataKinds               #-} {-# LANGUAGE FlexibleContexts        #-} {-# LANGUAGE FlexibleInstances       #-}@@ -37,13 +38,17 @@  import qualified Data.ByteString             as BS.Strict import qualified Data.ByteString.Lazy        as BS.Lazy-import qualified Data.ByteString.Short       as BS.Short import qualified Data.HashMap.Internal.Array as HashMap (Array) import qualified Data.Primitive.Array        as Prim (Array)+import qualified Data.Primitive.ByteArray    as Prim (ByteArray) import qualified Data.Text                   as Text.Strict import qualified Data.Text.Lazy              as Text.Lazy import qualified Data.Vector                 as Vector.Boxed +#if !MIN_VERSION_bytestring(0,12,0)+import qualified Data.ByteString.Short as BS.Short+#endif+ import Debug.RecoverRTTI.Classifier import Debug.RecoverRTTI.Nat import Debug.RecoverRTTI.Tuple@@ -79,10 +84,13 @@   , c String   , c BS.Strict.ByteString   , c BS.Lazy.ByteString-  , c BS.Short.ShortByteString   , c Text.Strict.Text   , c Text.Lazy.Text +#if !MIN_VERSION_bytestring(0,12,0)+  , c BS.Short.ShortByteString+#endif+   -- Aeson    , c Value@@ -105,6 +113,8 @@   , c SomeStorableVectorM   , c SomePrimitiveVector   , c SomePrimitiveVectorM+  , c Prim.ByteArray+  , c SomeMutableByteArray   )  primSatisfies :: forall c.@@ -139,10 +149,13 @@     go C_String      = Dict     go C_BS_Strict   = Dict     go C_BS_Lazy     = Dict-    go C_BS_Short    = Dict     go C_Text_Strict = Dict     go C_Text_Lazy   = Dict +#if !MIN_VERSION_bytestring(0,12,0)+    go C_BS_Short    = Dict+#endif+     -- Aeson      go C_Value = Dict@@ -165,6 +178,8 @@     go C_Vector_StorableM  = Dict     go C_Vector_Primitive  = Dict     go C_Vector_PrimitiveM = Dict+    go C_ByteArray         = Dict+    go C_MutableByteArray  = Dict  {-------------------------------------------------------------------------------   Compound
src/Debug/RecoverRTTI/Modules.hs view
@@ -27,7 +27,13 @@  data KnownPkg =     PkgGhcPrim+#if MIN_VERSION_base(4,20,0)+  | PkgGhcInternal+#endif   | PkgBase+#if !MIN_VERSION_base(4,17,0)+  | PkgDataArrayByte+#endif   | PkgByteString   | PkgText   | PkgIntegerWiredIn@@ -46,7 +52,13 @@  data SPkg (pkg :: KnownPkg) where   SGhcPrim             :: SPkg 'PkgGhcPrim+#if MIN_VERSION_base(4,20,0)+  SGhcInternal         :: SPkg 'PkgGhcInternal+#endif   SBase                :: SPkg 'PkgBase+#if !MIN_VERSION_base(4,17,0)+  SDataArrayByte       :: SPkg 'PkgDataArrayByte+#endif   SByteString          :: SPkg 'PkgByteString   SText                :: SPkg 'PkgText   SIntegerWiredIn      :: SPkg 'PkgIntegerWiredIn@@ -61,7 +73,13 @@   singPkg :: SPkg pkg  instance IsKnownPkg 'PkgGhcPrim             where singPkg = SGhcPrim+#if MIN_VERSION_base(4,20,0)+instance IsKnownPkg 'PkgGhcInternal         where singPkg = SGhcInternal+#endif instance IsKnownPkg 'PkgBase                where singPkg = SBase+#if !MIN_VERSION_base(4,17,0)+instance IsKnownPkg 'PkgDataArrayByte       where singPkg = SDataArrayByte+#endif instance IsKnownPkg 'PkgByteString          where singPkg = SByteString instance IsKnownPkg 'PkgText                where singPkg = SText instance IsKnownPkg 'PkgIntegerWiredIn      where singPkg = SIntegerWiredIn@@ -73,7 +91,7 @@ instance IsKnownPkg 'PkgPrimitive           where singPkg = SPrimitive  {--------------------------------------------------------------------------------  Modules in @ghc-pri@+  Modules in @ghc-prim@ -------------------------------------------------------------------------------}  data instance KnownModule 'PkgGhcPrim =@@ -81,10 +99,34 @@   | GhcTuple  {-------------------------------------------------------------------------------+  Modules in @ghc-internal@ (ghc 9.10 and up)+-------------------------------------------------------------------------------}++#if MIN_VERSION_base(4,20,0)+data instance KnownModule 'PkgGhcInternal =+    GhcInt+  | GhcWord+  | GhcSTRef+  | GhcMVar+  | GhcConcSync+  | GhcMaybe+  | GhcReal+  | DataEither+#endif++{-------------------------------------------------------------------------------   Modules in @base@ -------------------------------------------------------------------------------} ++#if MIN_VERSION_base(4,20,0)+ data instance KnownModule 'PkgBase =+    DataArrayByte++#else++data instance KnownModule 'PkgBase =     GhcInt   | GhcWord   | GhcSTRef@@ -94,6 +136,15 @@   | GhcReal   | DataEither +#if MIN_VERSION_base(4,17,0)+  | DataArrayByte+#else+data instance KnownModule 'PkgDataArrayByte =+    DataArrayByte+#endif++#endif+ {-------------------------------------------------------------------------------   Modules in @bytestring@ -------------------------------------------------------------------------------}@@ -169,6 +220,7 @@  data instance KnownModule 'PkgPrimitive =     DataPrimitiveArray+  | DataPrimitiveByteArray  {-------------------------------------------------------------------------------   Matching@@ -198,7 +250,13 @@      namePkg :: SPkg pkg -> String     namePkg SGhcPrim             = "ghc-prim"+#if MIN_VERSION_base(4,20,0)+    namePkg SGhcInternal         = "ghc-internal"+#endif     namePkg SBase                = "base"+#if !MIN_VERSION_base(4,17,0)+    namePkg SDataArrayByte       = "data-array-byte"+#endif     namePkg SByteString          = "bytestring"     namePkg SText                = "text"     namePkg SIntegerWiredIn      = "integer-wired-in"@@ -214,21 +272,43 @@         SGhcPrim -> \case           GhcTypes -> "GHC.Types" -#if MIN_VERSION_ghc_prim(0,10,0)+#if MIN_VERSION_base(4,20,0)+          GhcTuple -> "GHC.Tuple"+#elif MIN_VERSION_ghc_prim(0,10,0)           GhcTuple -> "GHC.Tuple.Prim" #else           GhcTuple -> "GHC.Tuple" #endif +#if MIN_VERSION_base(4,20,0)+        SGhcInternal -> \case+          GhcInt      -> "GHC.Internal.Int"+          GhcWord     -> "GHC.Internal.Word"+          GhcSTRef    -> "GHC.Internal.STRef"+          GhcMVar     -> "GHC.Internal.MVar"+          GhcConcSync -> "GHC.Internal.Conc.Sync"+          GhcMaybe    -> "GHC.Internal.Maybe"+          GhcReal     -> "GHC.Internal.Real"+          DataEither  -> "GHC.Internal.Data.Either"+#endif+         SBase -> \case-          GhcInt      -> "GHC.Int"-          GhcWord     -> "GHC.Word"-          GhcSTRef    -> "GHC.STRef"-          GhcMVar     -> "GHC.MVar"-          GhcConcSync -> "GHC.Conc.Sync"-          GhcMaybe    -> "GHC.Maybe"-          GhcReal     -> "GHC.Real"-          DataEither  -> "Data.Either"+#if !MIN_VERSION_base(4,20,0)+          GhcInt        -> "GHC.Int"+          GhcWord       -> "GHC.Word"+          GhcSTRef      -> "GHC.STRef"+          GhcMVar       -> "GHC.MVar"+          GhcConcSync   -> "GHC.Conc.Sync"+          GhcMaybe      -> "GHC.Maybe"+          GhcReal       -> "GHC.Real"+          DataEither    -> "Data.Either"+#endif+#if MIN_VERSION_base(4,17,0)+          DataArrayByte -> "Data.Array.Byte"+#else+        SDataArrayByte -> \case+          DataArrayByte -> "Data.Array.Byte"+#endif          SByteString -> \case #if MIN_VERSION_bytestring(0,11,4)@@ -272,7 +352,8 @@           DataVectorPrimitiveMutable -> "Data.Vector.Primitive.Mutable"          SPrimitive -> \case-          DataPrimitiveArray -> "Data.Primitive.Array"+          DataPrimitiveArray     -> "Data.Primitive.Array"+          DataPrimitiveByteArray -> "Data.Primitive.ByteArray"      -- On OSX, cabal strips vowels from package IDs in order to work around     -- limitations around path lengths
src/Debug/RecoverRTTI/Wrappers.hs view
@@ -26,6 +26,7 @@   , SomeStorableVectorM(..)   , SomePrimitiveVector(..)   , SomePrimitiveVectorM(..)+  , SomeMutableByteArray(..)   ) where  import Control.Concurrent.MVar (MVar)@@ -33,7 +34,8 @@ import Data.STRef (STRef) import GHC.Exts -import qualified Data.Primitive.Array as Prim (MutableArray)+import qualified Data.Primitive.Array     as Prim (MutableArray)+import qualified Data.Primitive.ByteArray as Prim (MutableByteArray)  {-------------------------------------------------------------------------------   User-defined types@@ -106,6 +108,9 @@ -- | Mutable primitive vector newtype SomePrimitiveVectorM = SomePrimitiveVectorM Any +-- | Mutable byte array+newtype SomeMutableByteArray = SomeMutableByteArray (Prim.MutableByteArray RealWorld)+ {-------------------------------------------------------------------------------   Show instances @@ -144,3 +149,6 @@  instance Show SomePrimitiveVectorM where   show _ = "<Data.Vector.Primitive.MVector>"++instance Show SomeMutableByteArray where+  show _ = "<Data.Primitive.ByteArray.MutableByteArray>"
tests/Test/RecoverRTTI/Classifier/Arbitrary.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                   #-} {-# LANGUAGE DataKinds             #-} {-# LANGUAGE FlexibleContexts      #-} {-# LANGUAGE GADTs                 #-}@@ -17,12 +18,17 @@ import Data.Void import GHC.Real (Ratio((:%))) +#if MIN_VERSION_base(4,17,0)+import qualified GHC.IsList as IsList+#else+import qualified GHC.Exts as IsList (fromList)+#endif+ import qualified Data.HashMap.Internal.Array as HashMap.Array import qualified Data.HashMap.Lazy           as HashMap import qualified Data.HashSet                as HashSet import qualified Data.IntMap                 as IntMap import qualified Data.Map                    as Map-import qualified Data.Primitive.Array        as Prim.Array import qualified Data.Sequence               as Seq import qualified Data.Set                    as Set import qualified Data.Tree                   as Tree@@ -140,8 +146,8 @@           go_U_K C_HM_Array (mkArray [])             (mapSome (GenK (SG.genListLike mkArray)) <$> go) -        , go_U_K C_Prim_Array (Prim.Array.fromList [])-            (mapSome (GenK (SG.genListLike Prim.Array.fromList)) <$> go)+        , go_U_K C_Prim_Array (IsList.fromList [])+            (mapSome (GenK (SG.genListLike IsList.fromList)) <$> go)          , go_U_K C_Vector_Boxed Vector.Boxed.empty             (mapSome (GenK (SG.genListLike Vector.Boxed.fromList)) <$> go)
tests/Test/RecoverRTTI/Classifier/Equality.hs view
@@ -40,3 +40,6 @@  instance Eq SomePrimitiveVectorM where   _ == _ = True++instance Eq SomeMutableByteArray where+  _ == _ = True
tests/Test/RecoverRTTI/Classify.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                 #-} {-# LANGUAGE GADTs               #-} {-# LANGUAGE LambdaCase          #-} {-# LANGUAGE OverloadedStrings   #-}@@ -13,6 +14,12 @@ import Data.Type.Equality import Unsafe.Coerce (unsafeCoerce) +#if MIN_VERSION_base(4,17,0)+import qualified GHC.IsList as IsList+#else+import qualified GHC.Exts as IsList (fromList)+#endif+ import qualified Data.Aeson                  as Aeson import qualified Data.HashMap.Internal.Array as HashMap.Array import qualified Data.HashMap.Lazy           as HashMap@@ -20,7 +27,6 @@ import qualified Data.IntMap                 as IntMap import qualified Data.IntSet                 as IntSet import qualified Data.Map                    as Map-import qualified Data.Primitive.Array        as Prim.Array import qualified Data.Sequence               as Seq import qualified Data.Set                    as Set import qualified Data.Tree                   as Tree@@ -87,13 +93,16 @@     , compareClassifier $ Value (C_Prim C_BS_Strict)   "abcdefg"     , compareClassifier $ Value (C_Prim C_BS_Lazy)     ""     , compareClassifier $ Value (C_Prim C_BS_Lazy)     "abcdefg"-    , compareClassifier $ Value (C_Prim C_BS_Short)    ""-    , compareClassifier $ Value (C_Prim C_BS_Short)    "abcdefg"     , compareClassifier $ Value (C_Prim C_Text_Strict) ""     , compareClassifier $ Value (C_Prim C_Text_Strict) "abcdefg"     , compareClassifier $ Value (C_Prim C_Text_Lazy)   ""     , compareClassifier $ Value (C_Prim C_Text_Lazy)   "abcdefg" +#if !MIN_VERSION_bytestring(0,12,0)+    , compareClassifier $ Value (C_Prim C_BS_Short)    ""+    , compareClassifier $ Value (C_Prim C_BS_Short)    "abcdefg"+#endif+       -- Aeson      , compareClassifier $ Value (C_Prim C_Value) (Aeson.object [("x" Aeson..= True)])@@ -133,6 +142,11 @@     , compareClassifier $ Value (C_Prim C_Vector_PrimitiveM) $         examplePrimitiveVectorM +    , compareClassifier $ Value (C_Prim C_ByteArray) $+        IsList.fromList [0, 1, 2]+    , compareClassifier $ Value (C_Prim C_MutableByteArray) $+        exampleMutableByteArray+       -- Compound      , compareClassifier $ Value (C_Maybe ElemU) $@@ -195,9 +209,9 @@         HashMap.Array.fromList 2 [1, 2]      , compareClassifier $ Value (C_Prim_Array ElemU) $-        Prim.Array.fromList []+        IsList.fromList []     , compareClassifier $ Value (C_Prim_Array (ElemK (C_Prim C_Int))) $-        Prim.Array.fromList [1, 2, 3]+        IsList.fromList [1, 2, 3]      , compareClassifier $ Value (C_Vector_Boxed ElemU) $         Vector.Boxed.empty@@ -250,10 +264,13 @@         C_Prim C_String      -> ()         C_Prim C_BS_Strict   -> ()         C_Prim C_BS_Lazy     -> ()-        C_Prim C_BS_Short    -> ()         C_Prim C_Text_Strict -> ()         C_Prim C_Text_Lazy   -> () +#if !MIN_VERSION_bytestring(0,12,0)+        C_Prim C_BS_Short    -> ()+#endif+         -- Aeson          C_Prim C_Value -> ()@@ -266,6 +283,8 @@         C_Prim C_Vector_StorableM  -> ()         C_Prim C_Vector_Primitive  -> ()         C_Prim C_Vector_PrimitiveM -> ()+        C_Prim C_ByteArray         -> ()+        C_Prim C_MutableByteArray  -> ()          -- Functions 
tests/Test/RecoverRTTI/Globals.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ -- | Global mutable variables -- -- The tests are entirely pure, but occassionally needs examples of these@@ -10,6 +12,7 @@   , examplePrimArrayM   , exampleStorableVectorM   , examplePrimitiveVectorM+  , exampleMutableByteArray   ) where  import Control.Concurrent.MVar (newEmptyMVar)@@ -20,10 +23,17 @@ import System.IO.Unsafe (unsafePerformIO) import Unsafe.Coerce (unsafeCoerce) -import qualified Data.Primitive.Array  as Prim.Array-import qualified Data.Vector.Primitive as Vector.Primitive-import qualified Data.Vector.Storable  as Vector.Storable+#if MIN_VERSION_base(4,17,0)+import qualified GHC.IsList as IsList+#else+import qualified GHC.Exts as IsList (fromList)+#endif +import qualified Data.Primitive.Array     as Prim.Array+import qualified Data.Primitive.ByteArray as Prim.ByteArray+import qualified Data.Vector.Primitive    as Vector.Primitive+import qualified Data.Vector.Storable     as Vector.Storable+ import Debug.RecoverRTTI  exampleIORef :: SomeSTRef@@ -60,3 +70,8 @@ {-# NOINLINE examplePrimitiveVectorM #-} examplePrimitiveVectorM = unsafePerformIO $     unsafeCoerce <$> Vector.Primitive.thaw (Vector.Primitive.fromList "abc")++exampleMutableByteArray :: SomeMutableByteArray+{-# NOINLINE exampleMutableByteArray #-}+exampleMutableByteArray = unsafePerformIO $+    SomeMutableByteArray <$> Prim.ByteArray.thawByteArray (IsList.fromList [0, 1, 2]) 0 3
tests/Test/RecoverRTTI/Prim.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                        #-} {-# LANGUAGE DerivingStrategies         #-} {-# LANGUAGE FlexibleInstances          #-} {-# LANGUAGE GADTs                      #-}@@ -24,15 +25,25 @@ import Data.Word import Unsafe.Coerce (unsafeCoerce) -import qualified Data.Aeson            as Aeson-import qualified Data.ByteString       as BS.Strict-import qualified Data.ByteString.Lazy  as BS.Lazy+#if MIN_VERSION_base(4,17,0)+import qualified GHC.IsList as IsList+#else+import qualified GHC.Exts as IsList (fromList)+#endif++import qualified Data.Aeson               as Aeson+import qualified Data.ByteString          as BS.Strict+import qualified Data.ByteString.Lazy     as BS.Lazy+import qualified Data.Primitive.ByteArray as Prim (ByteArray)+import qualified Data.Text                as Text.Strict+import qualified Data.Text.Lazy           as Text.Lazy+import qualified Data.Vector              as Vector.Boxed+import qualified Data.Vector.Primitive    as Vector.Primitive+import qualified Data.Vector.Storable     as Vector.Storable++#if !MIN_VERSION_bytestring(0,12,0) import qualified Data.ByteString.Short as BS.Short-import qualified Data.Text             as Text.Strict-import qualified Data.Text.Lazy        as Text.Lazy-import qualified Data.Vector           as Vector.Boxed-import qualified Data.Vector.Primitive as Vector.Primitive-import qualified Data.Vector.Storable  as Vector.Storable+#endif  import Debug.RecoverRTTI @@ -82,10 +93,13 @@     , Some C_String     , Some C_BS_Strict     , Some C_BS_Lazy-    , Some C_BS_Short     , Some C_Text_Strict     , Some C_Text_Lazy +#if !MIN_VERSION_bytestring(0,12,0)+    , Some C_BS_Short+#endif+     -- Aeson      , Some C_Value@@ -108,6 +122,8 @@     , Some C_Vector_StorableM     , Some C_Vector_Primitive     , Some C_Vector_PrimitiveM+    , Some C_ByteArray+    , Some C_MutableByteArray     ]   where     _checkAllCases :: PrimClassifier a -> ()@@ -137,10 +153,13 @@         C_String      -> ()         C_BS_Strict   -> ()         C_BS_Lazy     -> ()-        C_BS_Short    -> ()         C_Text_Strict -> ()         C_Text_Lazy   -> () +#if !MIN_VERSION_bytestring(0,12,0)+        C_BS_Short    -> ()+#endif+         -- Aeson          C_Value -> ()@@ -163,6 +182,8 @@         C_Vector_StorableM  -> ()         C_Vector_Primitive  -> ()         C_Vector_PrimitiveM -> ()+        C_ByteArray         -> ()+        C_MutableByteArray  -> ()  {-------------------------------------------------------------------------------   Arbitrary instances for specific types@@ -197,8 +218,10 @@ instance Arbitrary (Wrap BS.Lazy.ByteString) where   arbitrary = Wrap . BS.Lazy.pack <$> arbitrary +#if !MIN_VERSION_bytestring(0,12,0) instance Arbitrary (Wrap BS.Short.ShortByteString) where   arbitrary = Wrap . BS.Short.pack <$> arbitrary+#endif  instance Arbitrary (Wrap Text.Strict.Text) where   arbitrary = Wrap . Text.Strict.pack <$> arbitrary@@ -276,6 +299,9 @@       some :: Vector.Primitive.Vector a -> SomePrimitiveVector       some = unsafeCoerce +instance Arbitrary (Wrap Prim.ByteArray) where+  arbitrary = Wrap . IsList.fromList <$> arbitrary+ {-------------------------------------------------------------------------------   For the mutable variables, we just use the one global example -------------------------------------------------------------------------------}@@ -297,3 +323,8 @@  instance Arbitrary (Wrap SomePrimitiveVectorM) where   arbitrary = return $ Wrap examplePrimitiveVectorM++instance Arbitrary (Wrap SomeMutableByteArray) where+  arbitrary = return $ Wrap exampleMutableByteArray++
tests/Test/RecoverRTTI/UserDefined.hs view
@@ -35,7 +35,7 @@   deriving (Show, Eq, Generic)  -- | Example of a non-recursive user-defined type-data NonRecursive a = NR1 Int | NR2 Bool a +data NonRecursive a = NR1 Int | NR2 Bool a   deriving (Show, Eq, Generic, Functor, Foldable, Traversable)  -- | Example of a recursive user-defined type