packages feed

mini 1.4.0.1 → 1.4.0.2

raw patch · 4 files changed

+74/−32 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Mini.Data.Map: lookupMax :: Map k a -> Maybe a
+ Mini.Data.Map: lookupMax :: Map k a -> Maybe (k, a)
- Mini.Data.Map: lookupMin :: Map k a -> Maybe a
+ Mini.Data.Map: lookupMin :: Map k a -> Maybe (k, a)

Files

CHANGELOG.md view
@@ -1,3 +1,9 @@+1.4.0.2 [2024-10-29]+--------------------+* Mini.Data.Map:+  * Fix 'lookupMax' and 'lookupMin' (now fetch entire bin)+  * docs: Add examples section+ 1.4.0.1 [2024-10-27] -------------------- * docs: Add 'Mini.Optics.Lens' tutorial@@ -19,12 +25,12 @@ 1.3.0.0 [2024-03-28] -------------------- * Mini.Transformers.ParserT:-    * Simplify and expose ParseError:-        * Now a wrapper for {unexpected :: String}-    * Prune redundant combinator 'chainl'-    * Prune redundant combinator 'chainr'+  * Simplify and expose ParseError:+    * Now a wrapper for {unexpected :: String}+  * Prune redundant combinator 'chainl'+  * Prune redundant combinator 'chainr' * docs: Remove code-cluttering examples-    * Future work: separate 'examples' sections+  * Future work: separate 'examples' sections  1.2.2.1 [2024-03-20] --------------------@@ -33,8 +39,8 @@ 1.2.2.0 [2024-03-20] -------------------- * Mini.Transformers.ParserT:-    * Add combinator 'reject'-    * Add combinator 'accept'+  * Add combinator 'reject'+  * Add combinator 'accept'  1.2.1.0 [2024-03-16] --------------------@@ -43,19 +49,19 @@ 1.2.0.0 [2024-03-15] -------------------- * Mini.Transformers.ParserT:-    * Simplify parse errors+  * Simplify parse errors  1.1.1.0 [2024-03-14] -------------------- * Mini.Transformers.ParserT:-    * Add MonadFail instance-    * Add end-of-file parser-    * Add chain combinators+  * Add MonadFail instance+  * Add end-of-file parser+  * Add chain combinators  1.1.0.0 [2024-03-11] -------------------- * Conventionalise module naming: package.section.title-    * Mini.Lens -> Mini.Optics.Lens+  * Mini.Lens -> Mini.Optics.Lens * Streamline optics documentation  1.0.1.0 [2024-03-10]
Mini/Data/Map.hs view
@@ -43,6 +43,9 @@    -- * Validation   valid,++  -- * Examples+  -- $examples ) where  import Control.Monad (@@ -972,19 +975,19 @@     EQ -> Just a     GT -> recr --- | /O(log n)/ Fetch the maximum value, or 'Nothing' if the map is empty-lookupMax :: Map k a -> Maybe a+-- | /O(log n)/ Fetch the bin with the maximum key, or 'Nothing' if empty+lookupMax :: Map k a -> Maybe (k, a) lookupMax = map Nothing go go go  where-  go _ _ a r _ recr = map (Just a) go' go' go' r+  go _ k a r _ recr = map (Just (k, a)) go' go' go' r    where     go' _ _ _ _ _ _ = recr --- | /O(log n)/ Fetch the minimum value, or 'Nothing' if the map is empty-lookupMin :: Map k a -> Maybe a+-- | /O(log n)/ Fetch the bin with the minimum key, or 'Nothing' if empty+lookupMin :: Map k a -> Maybe (k, a) lookupMin = map Nothing go go go  where-  go l _ a _ recl _ = map (Just a) go' go' go' l+  go l k a _ recl _ = map (Just (k, a)) go' go' go' l    where     go' _ _ _ _ _ _ = recl @@ -1042,3 +1045,36 @@      where       lt _ lk _ _ _ _ = lk < k && recl && recr       gt _ rk _ _ _ _ = rk > k && recl && recr++{-+ - Examples+ -}++{- $examples+'fromList': /tail-biased/ means that if a list of @(key, value)@ pairs contains+pairs with identical keys, the one closest to the end of the list is kept.++>>> fromList [('a',1),('b',2),('c',3),('b',4),('a',5)]+{('a',5),('b',4),('c',3)}++'intersection', 'union': /left-biased/ means that if the operands contain bins+with identical keys, the bins from the /left/ operand is kept.++>>> fromList [('a',1),('b',2)] `intersection` fromList [('c',3),('b',4),('a',5)]+{('a',1),('b',2)}+>>> fromList [('a',1),('b',2)] `union` fromList [('c',3),('b',4),('a',5)]+{('a',1),('b',2),('c',3)}++'update': If the key does not exist, the map is unchanged. If the key exists and+the result of the operation is @Just x@, the value of the corresponding bin is+updated to @x@. If the key exists and the result of the operation is @Nothing@,+the corresponding bin is removed.++>>> f a = if a == 2 then Just 9 else Nothing+>>> update f 'c' $ fromList [('a',1),('b',2)]+{('a',1),('b',2)}+>>> update f 'b' $ fromList [('a',1),('b',2)]+{('a',1),('b',9)}+>>> update f 'a' $ fromList [('a',1),('b',2)]+{('b',2)}+-}
Mini/Data/Set.hs view
@@ -142,11 +142,11 @@ empty :: Set a empty = E --- | /O(n log n)/ Make a set from a tail-biased list of values+-- | /O(n log n)/ Make a set from a list of elements fromList :: (Ord a) => [a] -> Set a fromList = foldl (flip insert) empty --- | /O(1)/ Make a set with a single value+-- | /O(1)/ Make a set with a single element singleton :: a -> Set a singleton a = B E a E @@ -158,11 +158,11 @@ difference :: (Ord a) => Set a -> Set a -> Set a difference = foldr delete --- | /O(n log n)/ Intersect a set with another via left-biased matching+-- | /O(n log n)/ Intersect a set with another intersection :: (Ord a) => Set a -> Set a -> Set a intersection t = foldr (\a b -> bool b (insert a b) (a `member` t)) empty --- | /O(n log n)/ Unite a set with another via left-biased matching+-- | /O(n log n)/ Unite a set with another union :: (Ord a) => Set a -> Set a -> Set a union = foldr insert @@ -170,11 +170,11 @@  - Conversion  -} --- | /O(n)/ Turn a set into a list of values in ascending order+-- | /O(n)/ Turn a set into a list of elements in ascending order toAscList :: Set a -> [a] toAscList = foldl (flip (:)) [] --- | /O(n)/ Turn a set into a list of values in descending order+-- | /O(n)/ Turn a set into a list of elements in descending order toDescList :: Set a -> [a] toDescList = foldr (:) [] @@ -182,7 +182,7 @@  - Modification  -} --- | /O(log n)/ Delete a value from a set+-- | /O(log n)/ Delete an element from a set delete :: (Ord a) => a -> Set a -> Set a delete a0 t = bool t (go t) (a0 `member` t)  where@@ -599,11 +599,11 @@   popRightBR l a rl ra rr = first (checkRightB l a) $ popRightR rl ra rr   popRightBL l a rl ra rr = first (checkRightB l a) $ popRightL rl ra rr --- | /O(n)/ Keep the values satisfying a predicate+-- | /O(n)/ Keep the elements satisfying a predicate filter :: (Ord a) => (a -> Bool) -> Set a -> Set a filter p = foldr (\a b -> bool b (insert a b) (p a)) empty --- | /O(log n)/ Insert a value into a set, overwriting if present+-- | /O(log n)/ Insert an element into a set insert :: (Ord a) => a -> Set a -> Set a insert a0 =   set@@ -772,11 +772,11 @@  - Query  -} --- | /O(n log n)/ Check whether the values of a set exist in the other+-- | /O(n log n)/ Check whether the elements of a set exist in the other isSubsetOf :: (Ord a) => Set a -> Set a -> Bool isSubsetOf p q = foldr (\a b -> a `member` q && b) True p --- | /O(log n)/ Fetch the maximum value, or 'Nothing' if the set is empty+-- | /O(log n)/ Fetch the maximum element, or 'Nothing' if the set is empty lookupMax :: Set a -> Maybe a lookupMax = set Nothing go go go  where@@ -784,7 +784,7 @@    where     go' _ _ _ _ _ = recr --- | /O(log n)/ Fetch the minimum value, or 'Nothing' if the set is empty+-- | /O(log n)/ Fetch the minimum element, or 'Nothing' if the set is empty lookupMin :: Set a -> Maybe a lookupMin = set Nothing go go go  where@@ -792,7 +792,7 @@    where     go' _ _ _ _ _ = recl --- | /O(log n)/ Check whether a value is in a set+-- | /O(log n)/ Check whether an element is in a set member :: (Ord a) => a -> Set a -> Bool member a = set False go go go  where
mini.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               mini-version:            1.4.0.1+version:            1.4.0.2 license:            MIT license-file:       LICENSE author:             Victor Wallsten <victor.wallsten@protonmail.com>