Skip to content

Commit

Permalink
Build correct non-opaque key-values in KMap smart constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
geo2a committed Apr 3, 2024
1 parent 51937a0 commit 348f852
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions library/Booster/Pattern/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -588,16 +588,19 @@ pattern KMap def keyVals rest <- Term _ (KMapF def keyVals rest)
(keyVals', rest') = case rest of
Just (KMap def' kvs r) | def' == def -> (kvs, r)
r -> ([], r)
newKeyVals = Set.toList $ Set.fromList $ keyVals ++ keyVals'
newRest = rest'
in Term
argAttributes
{ hash =
Hashable.hash
( "KMap" :: ByteString
, def
, map (\(k, v) -> (hash $ getAttributes k, hash $ getAttributes v)) keyVals
, hash . getAttributes <$> rest
, map (\(k, v) -> (hash $ getAttributes k, hash $ getAttributes v)) newKeyVals
, hash . getAttributes <$> newRest
)
}
$ KMapF def (Set.toList $ Set.fromList $ keyVals ++ keyVals') rest'
$ KMapF def newKeyVals newRest

pattern KList :: KListDefinition -> [Term] -> Maybe (Term, [Term]) -> Term
pattern KList def heads rest <- Term _ (KListF def heads rest)
Expand Down

0 comments on commit 348f852

Please sign in to comment.