Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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