This commit is contained in:
crumbtoo
2023-11-10 17:38:17 -07:00
parent 0a9e4230ee
commit 8ce258b9de
4 changed files with 90 additions and 18 deletions

View File

@@ -5,6 +5,7 @@ module Data.Heap
, update
, free
, hLookup
, hLookupUnsafe
, addresses
, hSize
)
@@ -55,6 +56,11 @@ free (Heap u m) k = Heap (k:u) (M.delete k m)
hLookup :: Addr -> Heap a -> Maybe a
hLookup k (Heap _ m) = m !? k
hLookupUnsafe :: Addr -> Heap a -> a
hLookupUnsafe k (Heap _ m) = case m !? k of
Just a -> a
Nothing -> error "erm... segfault much?"
addresses :: Heap a -> [Addr]
addresses (Heap _ m) = M.keys m

View File

@@ -4,6 +4,7 @@ module Data.Pretty
, ISeq(..)
, precPretty
, prettyPrint
, prettyShow
, iBracket
, withPrec
, bracketPrec
@@ -27,6 +28,9 @@ precPretty = flip prettyPrec
prettyPrint :: (Pretty a) => a -> IO ()
prettyPrint = putStr . squash . pretty
prettyShow :: (Pretty a) => a -> String
prettyShow = squash . pretty
data ISeq where
INil :: ISeq
IStr :: String -> ISeq