packages feed

mini 1.6.4.0 → 1.6.5.0

raw patch · 12 files changed

+58/−53 lines, 12 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Mini.Transformers.EitherT: right :: forall (m :: Type -> Type) a e. Applicative m => a -> EitherT e m a
+ Mini.Transformers.MaybeT: just :: forall (m :: Type -> Type) a. Applicative m => a -> MaybeT m a

Files

.hlint.yaml view
@@ -3,4 +3,7 @@ - group: {name: future, enabled: true} - group: {name: generalise, enabled: true} +- ignore: {Use <=<}+- ignore: {Use >=>}+- ignore: {Use tuple-section} - ignore: {name: Use fmap, within: Mini.Data.Map}
CHANGELOG.md view
@@ -1,3 +1,8 @@+1.6.5.0 [2026-07-20]+--------------------+* Mini.Transformers.MaybeT: Add 'just'+* Mini.Transformers.EitherT: Add 'right'+ 1.6.4.0 [2026-07-08] -------------------- * Create Mini.Linear: Linear algebra
mini.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               mini-version:            1.6.4.0+version:            1.6.5.0 license:            MIT license-file:       LICENSE author:             Victor Wallsten <victor.wallsten@protonmail.com>
src/Mini/Data/Map.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE LambdaCase #-} -- incomplete patterns in 'fromDistinct{Asc,Desc}List' {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -211,7 +210,7 @@ -- | Primitive recursion on maps (internally structured as trees) map   :: b-  -- ^ Value yielded in case of empty node+  -- ^ Value in case of empty node   -> (Map k a -> k -> a -> Map k a -> b -> b -> b)   -- ^ Function applied in case of non-empty node:   -- left child, key, value, right child, left recursion, right recursion@@ -224,7 +223,7 @@ -- Primitive recursion on maps map'   :: b-  -- ^ Value yielded in case of empty node+  -- ^ Value in case of empty node   -> (Map k a -> k -> a -> Map k a -> b -> b -> b)   -- ^ Function applied in case of left-heavy node:   -- left child, key, value, right child, left recursion, right recursion@@ -240,7 +239,7 @@   -> Map k a   -- ^ Object of the case analysis   -> b-map' e f g h = \case+map' e f g h obj = case obj of   L l k a r -> f l k a r (map' e f g h l) (map' e f g h r)   R l k a r -> h l k a r (map' e f g h l) (map' e f g h r)   B l k a r -> g l k a r (map' e f g h l) (map' e f g h r)
src/Mini/Data/Recursion.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE LambdaCase #-}- -- | Primitive recursive functions on basic data structures module Mini.Data.Recursion (   -- * Re-exports@@ -119,9 +117,9 @@ -- | Primitive recursion on bools bool   :: a-  -- ^ Value yielded in case of 'Bool.False'+  -- ^ Value in case of @False@   -> a-  -- ^ Value yielded in case of 'Bool.True'+  -- ^ Value in case of @True@   -> Bool   -- ^ Object of the case analysis   -> a@@ -130,9 +128,9 @@ -- | Primitive recursion on eithers either   :: (a -> c)-  -- ^ Function applied to @a@ in case of @'Either.Left' a@+  -- ^ Function applied in case of @Left a@   -> (b -> c)-  -- ^ Function applied to @b@ in case of @'Either.Right' b@+  -- ^ Function applied in case of @Right b@   -> Either a b   -- ^ Object of the case analysis   -> c@@ -141,9 +139,9 @@ -- | Primitive recursion on maybes maybe   :: b-  -- ^ Value yielded in case of 'Maybe.Nothing'+  -- ^ Value in case of @Nothing@   -> (a -> b)-  -- ^ Function applied to @a@ in case of @'Maybe.Just' a@+  -- ^ Function applied in case of @Just a@   -> Maybe a   -- ^ Object of the case analysis   -> b@@ -163,13 +161,13 @@ -- | Primitive recursion on lists list   :: b-  -- ^ Value yielded in case of empty list+  -- ^ Value in case of empty list   -> (a -> [a] -> b -> b)   -- ^ Function applied in case of non-empty list: head, tail, recursion   -> [a]   -- ^ Object of the case analysis   -> b-list e f = \case+list e f obj = case obj of   a : as -> f a as (list e f as)   [] -> e @@ -187,15 +185,15 @@ -- | Primitive recursion on orderings ordering   :: a-  -- ^ Value yielded in case of 'LT'+  -- ^ Value in case of @LT@   -> a-  -- ^ Value yielded in case of 'EQ'+  -- ^ Value in case of @EQ@   -> a-  -- ^ Value yielded in case of 'GT'+  -- ^ Value in case of @GT@   -> Ordering   -- ^ Object of the case analysis   -> a-ordering lt eq gt = \case+ordering lt eq gt obj = case obj of   LT -> lt   GT -> gt   EQ -> eq
src/Mini/Data/Set.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE LambdaCase #-} -- incomplete patterns in 'from{Asc,Desc}List' {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} @@ -160,7 +159,7 @@ -- | Primitive recursion on sets (internally structured as trees) set   :: b-  -- ^ Value yielded in case of empty node+  -- ^ Value in case of empty node   -> (Set a -> a -> Set a -> b -> b -> b)   -- ^ Function applied in case of non-empty node:   -- left child, element, right child, left recursion, right recursion@@ -173,7 +172,7 @@ -- Primitive recursion on sets set'   :: b-  -- ^ Value yielded in case of empty node+  -- ^ Value in case of empty node   -> (Set a -> a -> Set a -> b -> b -> b)   -- ^ Function applied in case of left-heavy node:   -- left child, element, right child, left recursion, right recursion@@ -189,7 +188,7 @@   -> Set a   -- ^ Object of the case analysis   -> b-set' e f g h = \case+set' e f g h obj = case obj of   L l a r -> f l a r (set' e f g h l) (set' e f g h r)   R l a r -> h l a r (set' e f g h l) (set' e f g h r)   B l a r -> g l a r (set' e f g h l) (set' e f g h r)
src/Mini/Linear/Approx.hs view
@@ -1,5 +1,6 @@ -- | Checking for approximate equality module Mini.Linear.Approx (+  -- * Class   Approx (     (~=)   ),@@ -16,6 +17,8 @@   (-),   (<=),  )++-- Class  -- | The class of approximative types class Approx a where
src/Mini/Transformers/EitherT.hs view
@@ -9,6 +9,7 @@   -- * Operations   anticipate,   left,+  right, ) where  import Control.Applicative (@@ -19,7 +20,6 @@ import Control.Monad (   ap,   liftM,-  (>=>),  ) import Control.Monad.IO.Class (   MonadIO,@@ -64,7 +64,7 @@   fmap = liftM  instance (Monad m) => Applicative (EitherT e m) where-  pure = EitherT . pure . Right+  pure = right   (<*>) = ap  instance (Monad m, Monoid e) => Alternative (EitherT e m) where@@ -97,8 +97,12 @@  -- | Run a computation and get its result anticipate :: (Monad m) => EitherT e m a -> EitherT e m (Either e a)-anticipate = lift . runEitherT . (Right <$>) >=> either (pure . Left) pure+anticipate = lift . runEitherT  -- | Terminate the computation with a value left :: (Applicative m) => e -> EitherT e m a left = EitherT . pure . Left++-- | Return a value+right :: (Applicative m) => a -> EitherT e m a+right = EitherT . pure . Right
src/Mini/Transformers/MaybeT.hs view
@@ -9,6 +9,7 @@   -- * Operations   anticipate,   nothing,+  just, ) where  import Control.Applicative (@@ -19,7 +20,6 @@ import Control.Monad (   ap,   liftM,-  (>=>),  ) import Control.Monad.IO.Class (   MonadIO,@@ -45,7 +45,6 @@   pure,   ($),   (.),-  (<$>),   (<*>),   (>>=),  )@@ -62,7 +61,7 @@   fmap = liftM  instance (Monad m) => Applicative (MaybeT m) where-  pure = MaybeT . pure . Just+  pure = just   (<*>) = ap  instance (Monad m) => Alternative (MaybeT m) where@@ -95,8 +94,12 @@  -- | Run a computation and get its result anticipate :: (Monad m) => MaybeT m a -> MaybeT m (Maybe a)-anticipate = lift . runMaybeT . (Just <$>) >=> maybe (pure Nothing) pure+anticipate = lift . runMaybeT  -- | Terminate the computation without a value nothing :: (Applicative m) => MaybeT m a nothing = MaybeT $ pure Nothing++-- | Return a value+just :: (Applicative m) => a -> MaybeT m a+just = MaybeT . pure . Just
src/Mini/Transformers/ParserT.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE TupleSections #-}- -- | Extend a monad with the ability to parse symbol sequences module Mini.Transformers.ParserT (   -- * Type@@ -50,7 +48,6 @@   ap,   liftM,   replicateM,-  (>=>),  ) import Control.Monad.IO.Class (   MonadIO,@@ -89,7 +86,6 @@   fail,   flip,   fmap,-  fst,   maybe,   mempty,   notElem,@@ -121,7 +117,7 @@   fmap = liftM  instance (Monad m) => Applicative (ParserT s m) where-  pure a = ParserT $ pure . Just . (a,)+  pure a = ParserT $ \ss -> pure (Just (a, ss))   (<*>) = ap  instance (Monad m) => Alternative (ParserT s m) where@@ -130,14 +126,14 @@  instance (Monad m) => Monad (ParserT s m) where   m >>= k =-    ParserT $-      runParserT m-        >=> maybe+    ParserT $ \ss ->+      runParserT m ss+        >>= maybe           (pure Nothing)           (\(a, ss') -> runParserT (k a) ss')  instance MonadTrans (ParserT s) where-  lift m = ParserT $ \ss -> Just . (,ss) <$> m+  lift m = ParserT $ \ss -> Just . (\a -> (a, ss)) <$> m  instance (Monad m, Semigroup a) => Semigroup (ParserT s m a) where   m <> n = (<>) <$> m <*> n@@ -203,7 +199,7 @@  -- | Parse @p@, without consuming input, iff @p@ succeeds via @accept p@ accept :: (Monad m) => ParserT s m a -> ParserT s m a-accept p = ParserT $ \ss -> fmap ((,ss) . fst) <$> runParserT p ss+accept p = ParserT $ \ss -> fmap (\(a, _) -> (a, ss)) <$> runParserT p ss  -- | Parse @n@ or more occurrences of @p@ via @atLeast n p@ atLeast :: (Monad m) => Int -> ParserT s m a -> ParserT s m [a]
src/Mini/Transformers/StateT.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE TupleSections #-}- -- | Extend a monad with a modifiable environment module Mini.Transformers.StateT (   -- * Type@@ -22,7 +20,6 @@ import Control.Monad (   ap,   liftM,-  (>=>),  ) import Control.Monad.IO.Class (   MonadIO,@@ -60,7 +57,7 @@   fmap = liftM  instance (Monad m) => Applicative (StateT s m) where-  pure a = StateT $ pure . (a,)+  pure a = StateT $ \s -> pure (a, s)   (<*>) = ap  instance (Monad m, Alternative m) => Alternative (StateT s m) where@@ -68,10 +65,10 @@   m <|> n = StateT $ \s -> runStateT m s <|> runStateT n s  instance (Monad m) => Monad (StateT s m) where-  m >>= k = StateT $ runStateT m >=> (\(a, s) -> runStateT (k a) s)+  m >>= k = StateT $ \s -> runStateT m s >>= (\(a, s') -> runStateT (k a) s')  instance MonadTrans (StateT s) where-  lift m = StateT $ \s -> (,s) <$> m+  lift m = StateT $ \s -> (\a -> (a, s)) <$> m  instance (MonadFail m) => MonadFail (StateT s m) where   fail = StateT . const . fail@@ -87,8 +84,8 @@  -- | Update the current state with an operation modify :: (Monad m) => (s -> s) -> StateT s m ()-modify f = StateT $ pure . ((),) . f+modify f = StateT $ \s -> pure ((), f s)  -- | Overwrite the current state with a value put :: (Monad m) => s -> StateT s m ()-put = StateT . const . pure . ((),)+put s = StateT . const $ pure ((), s)
src/Mini/Transformers/WriterT.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE TupleSections #-}- -- | Extend a monad with an accumulative write-only environment module Mini.Transformers.WriterT (   -- * Type@@ -58,7 +56,7 @@   fmap = liftM  instance (Monad m, Monoid w) => Applicative (WriterT w m) where-  pure = WriterT . pure . (,mempty)+  pure a = WriterT $ pure (a, mempty)   (<*>) = ap  instance (Monad m, Alternative m, Monoid w) => Alternative (WriterT w m) where@@ -72,7 +70,7 @@     pure (b, w <> w')  instance (Monoid w) => MonadTrans (WriterT w) where-  lift = WriterT . fmap (,mempty)+  lift = WriterT . fmap (\a -> (a, mempty))  instance (MonadFail m, Monoid w) => MonadFail (WriterT w m) where   fail = WriterT . fail@@ -84,4 +82,4 @@  -- | Append a value to the write-only environment tell :: (Monad m) => w -> WriterT w m ()-tell = WriterT . pure . ((),)+tell w = WriterT $ pure ((), w)