auxiliary view functions for heap lookups

This commit is contained in:
crumbtoo
2023-11-13 17:36:06 -07:00
parent 416f5d89fa
commit 371aa5343c

View File

@@ -8,6 +8,8 @@ module Data.Heap
, hLookupUnsafe , hLookupUnsafe
, addresses , addresses
, hSize , hSize
, hView
, hViewUnsafe
) )
where where
---------------------------------------------------------------------------------- ----------------------------------------------------------------------------------
@@ -67,3 +69,11 @@ addresses (Heap _ m) = M.keys m
hSize :: Heap a -> Int hSize :: Heap a -> Int
hSize (Heap _ m) = M.size m hSize (Heap _ m) = M.size m
-- | Intended for use with view patterns
hView :: Heap a -> Addr -> Maybe a
hView = flip hLookup
-- | Intended for use with view patterns
hViewUnsafe :: Heap a -> Addr -> a
hViewUnsafe = flip hLookupUnsafe