packages feed

mini 1.4.3.0 → 1.5.0.0

raw patch · 5 files changed

+39/−36 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Mini.Transformers.ParserT: annotate :: Monad m => String -> ParserT s m a -> ParserT s m a

Files

CHANGELOG.md view
@@ -1,3 +1,11 @@+1.5.0.0 [2024-12-23]+--------------------+* Mini.Data.{Map,Set}:+  * Simplify 'show'+  * Fix element processing order of folds+* Mini.Transformers.ParserT:+  * Add combinator 'annotate'+ 1.4.3.0 [2024-12-08] -------------------- * All transformers now instantiate:
Mini/Data/Map.hs view
@@ -57,11 +57,9 @@ ) where  import Control.Applicative (+  liftA2,   (<|>),  )-import Control.Monad (-  liftM2,- ) import Data.Bool (   bool,  )@@ -138,15 +136,7 @@   compare t1 t2 = compare (toAscList t1) (toAscList t2)  instance (Show k, Show a) => Show (Map k a) where-  show = curl . map [] go go go-   where-    go _ k a _ recl recr = recl <> show (k, a) <> "," <> recr-    curl = wrap "{" "}" . removeTrailingComma-    wrap open close s = open <> s <> close-    removeTrailingComma s = case s of-      [] -> []-      [_] -> []-      (c : cs) -> c : removeTrailingComma cs+  show = show . toAscList  instance Functor (Map k) where   fmap f = map E (go L) (go B) (go R)@@ -229,7 +219,7 @@  -- | /O(m log n)/ Unite a map with another via left-biased key matching union :: (Ord k) => Map k a -> Map k a -> Map k a-union t = foldrWithKey (\k a b -> bool (insert k a b) b $ k `member` t) t+union = flip $ foldrWithKey insert  {-  - Conversion@@ -237,11 +227,11 @@  -- | /O(n)/ Turn a map into a list of @(key, value)@ pairs in ascending order toAscList :: Map k a -> [(k, a)]-toAscList = foldlWithKey (\b k a -> (k, a) : b) []+toAscList = foldrWithKey (\k a b -> (k, a) : b) []  -- | /O(n)/ Turn a map into a list of @(key, value)@ pairs in descending order toDescList :: Map k a -> [(k, a)]-toDescList = foldrWithKey (\k a b -> (k, a) : b) []+toDescList = foldlWithKey (\b k a -> (k, a) : b) []  {-  - Fold@@ -251,13 +241,13 @@ foldlWithKey :: (b -> k -> a -> b) -> b -> Map k a -> b foldlWithKey f b = map b go go go  where-  go l k a _ _ recr = foldlWithKey f (f recr k a) l+  go _ k a r recl _ = foldlWithKey f (f recl k a) r  -- | /O(n)/ Reduce a map with a right-associative operation and an accumulator foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b foldrWithKey f b = map b go go go  where-  go _ k a r recl _ = foldrWithKey f (f k a recl) r+  go l k a _ _ recr = foldrWithKey f (f k a recr) l  {-  - Modification@@ -1091,7 +1081,7 @@  -- | /O(n)/ Check whether a map is internally height-balanced and ordered valid :: (Ord k) => Map k a -> Bool-valid = liftM2 (&&) balanced ordered+valid = liftA2 (&&) balanced ordered  where   balanced =     map
Mini/Data/Set.hs view
@@ -39,11 +39,9 @@ ) where  import Control.Applicative (+  liftA2,   (<|>),  )-import Control.Monad (-  liftM2,- ) import Data.Bifunctor (   first,  )@@ -113,19 +111,12 @@   compare t1 t2 = compare (toAscList t1) (toAscList t2)  instance (Show a) => Show (Set a) where-  show = curl . set [] go go go-   where-    go _ a _ recl recr = recl <> show a <> "," <> recr-    curl = wrap "{" "}" . removeTrailingComma-    wrap open close s = open <> s <> close-    removeTrailingComma [] = []-    removeTrailingComma "," = []-    removeTrailingComma (c : cs) = c : removeTrailingComma cs+  show = show . toAscList  instance Foldable Set where   foldr f b = set b go go go    where-    go _ a r recl _ = foldr f (f a recl) r+    go l a _ _ recr = foldr f (f a recr) l  instance (Ord a) => Semigroup (Set a) where   (<>) = union@@ -181,11 +172,15 @@  -- | /O(m 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+intersection t1 t2 =+  foldr+    (\a b -> bool b (insert a b) (a `member` t2))+    empty+    t1  -- | /O(m log n)/ Unite a set with another union :: (Ord a) => Set a -> Set a -> Set a-union = foldr insert+union = flip $ foldr insert  {-  - Conversion@@ -193,11 +188,11 @@  -- | /O(n)/ Turn a set into a list of elements in ascending order toAscList :: Set a -> [a]-toAscList = foldl (flip (:)) []+toAscList = foldr (:) []  -- | /O(n)/ Turn a set into a list of elements in descending order toDescList :: Set a -> [a]-toDescList = foldr (:) []+toDescList = foldl (flip (:)) []  {-  - Modification@@ -872,7 +867,7 @@  -- | /O(n)/ Check whether a set is internally height-balanced and ordered valid :: (Ord a) => Set a -> Bool-valid = liftM2 (&&) balanced ordered+valid = liftA2 (&&) balanced ordered  where   balanced =     set
Mini/Transformers/ParserT.hs view
@@ -37,6 +37,7 @@   accept,   findFirst,   findLast,+  annotate, ) where  import Control.Applicative (@@ -273,3 +274,12 @@ -- | Find and parse the last instance of @p@ via @findLast p@ findLast :: (Monad m, Eq s, Show s) => ParserT s m a -> ParserT s m a findLast p = findFirst p >>= flip option (findLast p)++-- | Prepend an error message to that of a parser+annotate :: (Monad m) => String -> ParserT s m a -> ParserT s m a+annotate s p =+  ParserT $+    runParserT p+      >=> either+        (pure . Left . ParseError . (s <>) . unexpected)+        (pure . Right)
mini.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               mini-version:            1.4.3.0+version:            1.5.0.0 license:            MIT license-file:       LICENSE author:             Victor Wallsten <victor.wallsten@protonmail.com>