free-algebras 0.1.0.2 → 0.1.2.0
raw patch · 8 files changed
Files
- ChangeLog.md +7/−0
- README.md +2/−2
- free-algebras.cabal +7/−7
- src/Control/Algebra/Free.hs +17/−6
- src/Control/Algebra/Free2.hs +5/−5
- src/Data/Algebra/Free.hs +3/−3
- src/Data/Group/Free.hs +5/−3
- src/Data/Semigroup/Semilattice.hs +1/−1
ChangeLog.md view
@@ -1,5 +1,12 @@ # Changelog for free-algebras +## Version 0.1.2.0++- Support `GHC-9.10`.++## Version 0.1.1.0+- Support `GHC-9.6` and `mtl-2.3`, drop support of `GHC-8.8`.+ ## Version 0.1.0.2 - Support `GHC-9.0`, `GHC-9.2` and `GHC-9.4`, drop support for `GHC-8.6` or earlier.
README.md view
@@ -1,6 +1,6 @@ # Free Algebras-[](http://github.com/coot)-[](https://github.com/coot/free-algebras/actions/workflows/posix.yml)+[](http://github.com/coot)+[](https://github.com/coot/free-algebras/actions/workflows/ci.yaml) Universal algebra approach (which is compatible with categorical approach) to free algebras (including higher order structures like functors, applicative
free-algebras.cabal view
@@ -1,6 +1,6 @@-cabal-version: 2.2+cabal-version: 3.4 name: free-algebras-version: 0.1.0.2+version: 0.1.2.0 synopsis: Free algebras description: Algebraic approach to free algebras, inspired by Univeral Algebra and@@ -11,7 +11,7 @@ bug-reports: https://github.com/coot/free-algebras/issues author: Marcin Szamotulski maintainer: coot@coot.me-copyright: (c) 2018-2021 Marcin Szamotulski+copyright: (c) 2018-2024 Marcin Szamotulski license: MPL-2.0 license-file: LICENSE build-type: Simple@@ -19,7 +19,7 @@ ChangeLog.md README.md stability: experimental-tested-with: GHC==8.8.4, GHC==8.10.4, GHC==9.0.2, GHC==9.2.4, GHC==9.4.2+tested-with: GHC == { 8.10, 9.0, 9.2, 9.4, 9.6, 9.8, 9.10 } source-repository head type: git@@ -51,14 +51,14 @@ src build-depends: base >= 4.9 && <5- , containers >= 0.4.2 && <0.7+ , containers >= 0.4.2 && <0.8 , data-fix <0.4 , dlist >= 0.8 && <1.1 , free >= 4.0 && <6.0 , groups >= 0.3 && <0.6 , kan-extensions >= 4.1 && <6.0 , mtl >= 2.2 && <2.4- , transformers >= 0.5 && <0.6+ , transformers >= 0.5 && <0.7 default-language: Haskell2010 test-suite test-free-algebras@@ -92,7 +92,7 @@ , dlist , free , groups- , hedgehog >= 0.6 && < 1.3+ , hedgehog >= 0.6 && < 1.6 , kan-extensions , mtl , transformers
src/Control/Algebra/Free.hs view
@@ -18,6 +18,7 @@ -- 'ListT' transformer is depreciated {-# OPTIONS_GHC -Wno-deprecations #-}+{-# OPTIONS_GHC -Wno-orphans #-} module Control.Algebra.Free ( -- Higher free algebra class@@ -46,26 +47,34 @@ -- * Free construction in continuation passing style , Free1 (..) -- * Various classes (higher algebra types)+#if !MIN_VERSION_mtl(2,3,0) , MonadList (..)+#endif , MonadMaybe (..) ) where -import Control.Applicative ( Alternative (..)- , liftA2- )+import Control.Applicative ( Alternative (..) )+#if !MIN_VERSION_mtl(2,3,0)+import Control.Applicative ( liftA2 )+#endif import Control.Applicative.Free (Ap) import qualified Control.Applicative.Free as Ap import qualified Control.Applicative.Free.Fast as Fast import qualified Control.Applicative.Free.Final as Final import Control.Alternative.Free (Alt (..)) import qualified Control.Alternative.Free as Alt-import Control.Monad ( MonadPlus (..), foldM, join)+import Control.Monad ( MonadPlus (..), join )+#if !MIN_VERSION_mtl(2,3,0)+import Control.Monad ( foldM )+#endif import Control.Monad.Except (ExceptT (..), MonadError (..)) import Control.Monad.Free (Free) import qualified Control.Monad.Free as Free import qualified Control.Monad.Free.Church as Church+#if !MIN_VERSION_mtl(2,3,0) import Control.Monad.List (ListT (..))+#endif import Control.Monad.Reader (MonadReader (..), ReaderT (..)) import Control.Monad.RWS.Class (MonadRWS) import Control.Monad.RWS.Lazy as L (RWST (..))@@ -206,7 +215,7 @@ -- | @'unFoldNatFree'@ is an inverse of @'foldNatFree'@ ----- It is uniquely determined by its universal property (by Yonneda lemma):+-- It is uniquely determined by its universal property (by Yoneda lemma): -- -- prop> unFoldNatFree id = ruturnFree1 --@@ -562,6 +571,7 @@ tell w return a +#if !MIN_VERSION_mtl(2,3,0) -- | Algebra type for @'ListT'@ monad transformer. -- class Monad m => MonadList m where@@ -584,9 +594,10 @@ as <- nat mas empty1 <- mempty1 foldM (\x y -> x `mappend1_` y) empty1 as+#endif -- | Free construction for kinds @'Type' -> 'Type'@. @'Free1' 'Functor'@ is--- isomorhpic to @'Coyoneda'@ via @'hoistFreeH'@, and @'Free1' 'Applicative'@+-- isomorphic to @'Coyoneda'@ via @'hoistFreeH'@, and @'Free1' 'Applicative'@ -- is isomorphic to @'Ap'@ (also via @'hoistFreeH'@). -- -- Note: useful instance are only provided for ghc-8.6 using quantified
src/Control/Algebra/Free2.hs view
@@ -41,7 +41,7 @@ {-# MINIMAL liftFree2, foldNatFree2 #-} - -- | Lift a graph @f@ satsifying the constraint @'AlgebraType0'@ to a free+ -- | Lift a graph @f@ satisfying the constraint @'AlgebraType0'@ to a free -- its object @m f@. -- liftFree2 :: AlgebraType0 m f@@ -68,10 +68,10 @@ -> (m f a b -> d a b) -- | A proof that for each @f@ satisfying @AlgebraType0 m f@, @m f@- -- satisfies @AlgebraType m (m f)@ constrant. This means that @m@ is+ -- satisfies @AlgebraType m (m f)@ constraint. This means that @m@ is -- a well defined /functor/ from the full sub-category of types of kind @k -- -> k -> Type@ which satisfy the @AlgebraType0 m@ constraint to the full- -- subcategory of types of the same kind which satifsfy the constraint+ -- subcategory of types of the same kind which satisfy the constraint -- @AlgebraType m@. -- codom2 :: forall (f :: k -> k -> Type).@@ -123,7 +123,7 @@ -- @ -- -- It is the [unit](https://ncatlab.org/nlab/show/unit+of+an+adjunction) of--- adjuction defined by @'FreeAlgebra1'@ class.+-- adjunction defined by @'FreeAlgebra1'@ class. -- foldFree2 :: forall k (m :: (k -> k -> Type) -> k -> k -> Type)@@ -140,7 +140,7 @@ -- | Inverse of @'foldNatFree2'@. ----- It is uniquelly determined by its universal property (by Yonneda lemma):+-- It is uniquely determined by its universal property (by Yoneda lemma): -- -- prop> unFoldNatFree id = liftFree2 --
src/Data/Algebra/Free.hs view
@@ -132,7 +132,7 @@ -- | Inverse of @'foldMapFree'@ ----- It is uniquely determined by its universal property (by Yonneda lemma):+-- It is uniquely determined by its universal property (by Yoneda lemma): -- -- prop> unFoldMapFree id = returnFree --@@ -245,7 +245,7 @@ -- | @'Fix' m@ is the initial algebra in the category of algebras of type -- @'AlgebraType' m@ (the initial algebra is a free algebra generated by empty--- set of generators, e.g. the @Viod@ type).+-- set of generators, e.g. the @Void@ type). -- -- Another way of putting this is observing that @'Fix' m@ is isomorphic to @m -- Void@ where @m@ is the /free algebra/. This isomorphisms is given by@@ -357,7 +357,7 @@ foldMapFree f (a :| []) = f a foldMapFree f (a :| (b : bs)) = f a <> foldMapFree f (b :| bs) --- | 'DNonEmpty' is the free semigroup ihn the class of all semigroups.+-- | 'DNonEmpty' is the free semigroup in the class of all semigroups. -- newtype DNonEmpty a = DNonEmpty ([a] -> NonEmpty a) instance Semigroup (DNonEmpty a) where
src/Data/Group/Free.hs view
@@ -29,7 +29,9 @@ import Data.DList.Unsafe (DList (..)) #endif import Data.Group (Group (..))+#if __GLASGOW_HASKELL__ < 910 import Data.List (foldl')+#endif import Data.Algebra.Free ( AlgebraType@@ -44,7 +46,7 @@ -- inverse (FreeGroup [a]) = FreeGroup [either Right Left a] -- @ ----- It is a monad on a full subcategory of @Hask@ which constists of types which+-- It is a monad on a full subcategory of @Hask@ which consists of types which -- satisfy the @'Eq'@ constraint. -- -- @'FreeGroup' a@ is isomorphic with @'Free' Group a@ (but the latter does not@@ -68,7 +70,7 @@ -- | Normalize a @Dlist@, i.e. remove adjacent inverses from a word, i.e. -- @ab⁻¹ba⁻¹c = c@. Note that this function is implemented using--- @'normalizeL'@, implemnting it directly on @DList@s would be @O(n^2)@+-- @'normalizeL'@, implementing it directly on @DList@s would be @O(n^2)@ -- instead of @O(n)@. -- -- /Complexity:/ @O(n)@@@ -87,7 +89,7 @@ -- | Construct a FreeGroup from a list. ----- /Complextiy:/ @O(n)@+-- /Complexity:/ @O(n)@ -- freeGroupFromList :: Eq a => [Either a a] -> FreeGroup a freeGroupFromList = FreeGroup . DList.fromList . normalizeL
src/Data/Semigroup/Semilattice.hs view
@@ -24,7 +24,7 @@ ) import Data.Semigroup.Abelian (AbelianSemigroup) --- | Class of abelian semigroups in which every element is idempontent, i.e.+-- | Class of abelian semigroups in which every element is idempotent, i.e. -- @a <> a = a@. -- class AbelianSemigroup m => Semilattice m