You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While it's definable with upsert f = alter (Just . f), I'd like to have it already in the library.
Compare implementation for Map:
even alter is tagged as INLINEABLE, the optimization may or may not happen.
alter::Ordk=> (Maybea->Maybea) ->k->Mapka->Mapka
alter = go
wherego::Ordk=> (Maybea->Maybea) ->k->Mapka->Mapka
go f !k Tip=case f NothingofNothing->TipJust x -> singleton k x
go f k (Bin sx kx x l r) =casecompare k kx ofLT-> balance kx x (go f k l) r
GT-> balance kx x l (go f k r)
EQ->case f (Just x) ofJust x' ->Bin sx kx x' l r
Nothing-> glue l r
vs
upsert::Ordk=> (Maybea->a) ->k->Mapka->Mapka
upsert = go
wherego::Ordk=> (Maybea->a) ->k->Mapka->Mapka
go f !k Tip= singleton k (f Nothing)
go f k (Bin sx kx x l r) =casecompare k kx ofLT-> balance kx x (go f k l) r
GT-> balance kx x l (go f k r)
EQ->Bin sx kx (f (Just x)) l r
In fact, I'd like having upsertF variant as well.
It would be less code/branches then with alterF.
The text was updated successfully, but these errors were encountered:
There are
but
variant is missing.
While it's definable with
upsert f = alter (Just . f)
, I'd like to have it already in the library.Compare implementation for
Map
:even
alter
is tagged asINLINEABLE
, the optimization may or may not happen.vs
In fact, I'd like having
upsertF
variant as well.It would be less code/branches then with
alterF
.The text was updated successfully, but these errors were encountered: