-
Notifications
You must be signed in to change notification settings - Fork 103
One-pass alter
#548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
One-pass alter
#548
Conversation
Co-authored-by: Simon Jakobi <simon.jakobi@gmail.com>
|
I've made
The Core size for these functions is pretty huge though: There are still a few things to improve though. |
|
Core sizes at 50e2490:
|
|
Large. Probably not something we'd want to newtype Maybe# a = Maybe# (# (##) | a
#)
pattern Just# :: a -> Maybe# a
pattern Just# a = Maybe# (# | a #)
pattern Nothing# :: Maybe# a
pattern Nothing# = Maybe# (# (##) | #)
{-# COMPLETE Nothing#, Just# #-}
toMaybe :: Maybe# a -> Maybe a
fromMaybe :: Maybe a -> Maybe# a
alter f = alter# $ \m# -> fromMaybe (f (toMaybe m#))
alter# :: (Hashable k, Eq k) => (Maybe# a -> Maybe# a) -> HashMap k a -> k -> HashMap k aIn the (I believe typical) case that the passed function is known, small, and non-recursive, GHC will inline it into the function passed to |
|
At the current state of this branch, the I guess this |
Exactly. |
This is a continuation of @oberblastmeister's work done in #471.
Resolves #392.
TODO:
MaybesCollision-handling code out of line