diff --git a/cas/hashable/app/Main.hs b/cas/hashable/app/Main.hs index a395ba4d..e7279def 100644 --- a/cas/hashable/app/Main.hs +++ b/cas/hashable/app/Main.hs @@ -34,5 +34,5 @@ main = do -- This hash should not change, unless the hashing algorithm change or the order of the walk in the structure changes. let - expected = "ContentHash \"7f953cc9aaf79bac4d02e70dca91da1ee630b4a7894aeca9ed61942cc3a20d8a\"" + expected = "ContentHash \"da33d38419fc15489a5435694a5107f07fd62b4659ddd799720f62b9e423e3a0\"" when (show rawHash /= expected) $ error $ "Raw hash is different than expected: " <> show rawHash diff --git a/cas/hashable/src/Data/CAS/ContentHashable.hs b/cas/hashable/src/Data/CAS/ContentHashable.hs index 06a251c8..486c704e 100644 --- a/cas/hashable/src/Data/CAS/ContentHashable.hs +++ b/cas/hashable/src/Data/CAS/ContentHashable.hs @@ -478,11 +478,15 @@ instance (Constructor c, GContentHashable m f) => GContentHashable m (C1 c f) wh nameCtx = hashUpdate ctx0 $ C8.pack (conName x) instance (Datatype d, GContentHashable m f) => GContentHashable m (D1 d f) where - gContentHashUpdate ctx0 x = packageCtx `seq` gContentHashUpdate packageCtx (unM1 x) + gContentHashUpdate ctx0 x = datatypeCtx `seq` gContentHashUpdate datatypeCtx (unM1 x) where + -- Only add the datatype context in the hash + -- Adding the module and package would lead to hash invalidation when + -- moving the type to another module + -- See https://github.com/tweag/funflow/issues/202 datatypeCtx = hashUpdate ctx0 $ C8.pack (datatypeName x) - moduleCtx = hashUpdate datatypeCtx $ C8.pack (datatypeName x) - packageCtx = hashUpdate moduleCtx $ C8.pack (datatypeName x) + -- moduleCtx = hashUpdate datatypeCtx $ C8.pack (datatypeName x) + -- packageCtx = hashUpdate moduleCtx $ C8.pack (datatypeName x) instance GContentHashable m f => GContentHashable m (S1 s f) where gContentHashUpdate ctx x = gContentHashUpdate ctx (unM1 x)