on main help sign in
Fix segfault in 'toList' (#65)
commit45d30e7ff8d5bab77c7747f958b3da9ce4cadf6e authorVladislav Zavialov <vlad.z.4096@gmail.com> dateMon 21 Jan 2019, 22:29 (8 years ago) parent81141cb
2 files changed+5−2
shell.nix+1−1 src/Data/TypeRepMap/Internal.hs+4−1
shell.nix+1−1
@@ -4,7 +4,7 @@ with import <nixpkgs> { };
44stdenv.mkDerivation rec {
55 name = "typerep-map";
66 buildInputs = [
7− haskell.compiler.ghc843
7+ haskell.compiler.ghc844
88 pkgs.cabal-install
99 ];
1010}
src/Data/TypeRepMap/Internal.hs+4−1
@@ -345,6 +345,9 @@ data WrapTypeable f where
345345instance Show (WrapTypeable f) where
346346 show (WrapTypeable (_ :: f a)) = show $ calcFp @a
347347
348+wrapTypeable :: TypeRep a -> f a -> WrapTypeable f
349+wrapTypeable tr = withTypeable tr WrapTypeable
350+
348351{- |
349352
350353prop> fromList . toList == 'id'
@@ -375,7 +378,7 @@ instance IsList (TypeRepMap f) where
375378 toList = map toWrapTypeable . toTriples
376379 where
377380 toWrapTypeable :: (Fingerprint, Any, Any) -> WrapTypeable f
378− toWrapTypeable (_, an, k) = withTypeable (unsafeCoerce k) $ fromAny an
381+ toWrapTypeable (_, an, k) = wrapTypeable (unsafeCoerce k) (fromAny an)
379382
380383calcFp :: forall a . Typeable a => Fingerprint
381384calcFp = typeRepFingerprint $ typeRep @a