Skip to content

Commit

Permalink
Merge branch 'wireapp:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
offsoc authored Oct 2, 2024
2 parents 90abec9 + ef67359 commit 821d16d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/5-internal/WPB-11386-map-range
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Introduce length-preserving function mapRange to replace Functor instance for Range data type.
6 changes: 5 additions & 1 deletion libs/types-common/src/Data/Range.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
module Data.Range
( Range,
toRange,
mapRange,
Within,
Bounds (..),
checked,
Expand Down Expand Up @@ -98,7 +99,10 @@ import Test.QuickCheck qualified as QC
newtype Range (n :: Nat) (m :: Nat) a = Range
{ fromRange :: a
}
deriving (Eq, Ord, Show, Functor)
deriving (Eq, Ord, Show)

mapRange :: forall (n :: Nat) (m :: Nat) a b. (a -> b) -> Range n m [a] -> Range n m [b]
mapRange f (Range as) = Range (f `map` as)

toRange :: (n <= x, x <= m, KnownNat x, Num a) => Proxy x -> Range n m a
toRange = Range . fromIntegral . natVal
Expand Down
2 changes: 1 addition & 1 deletion services/brig/src/Brig/IO/Intra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ notifyUserDeletionRemotes deleted = do
pure ()
Just rangedUcs -> do
luidDeleted <- qualifyLocal' deleted
embed $ notifyUserDeleted luidDeleted (qualifyAs ucs ((fmap (fmap (qUnqualified . ucTo))) rangedUcs))
embed $ notifyUserDeleted luidDeleted (qualifyAs ucs (mapRange (qUnqualified . ucTo) rangedUcs))
-- also sent connection cancelled events to the connections that are pending
let remotePendingConnections = qualifyAs ucs <$> filter ((==) Sent . ucStatus) (fromRange rangedUcs)
forM_ remotePendingConnections $ sendCancelledEvent luidDeleted
Expand Down

0 comments on commit 821d16d

Please sign in to comment.