unfoldable 1.0.1 → 1.1
raw patch · 6 files changed
+28/−63 lines, 6 filesdep −ghc-primdep ~QuickCheckdep ~containersdep ~one-liner
Dependencies removed: ghc-prim
Dependency ranges changed: QuickCheck, containers, one-liner, random, transformers
Files
- CHANGELOG.md +4/−0
- src/Data/Biunfoldable.hs +0/−1
- src/Data/Triunfoldable.hs +4/−5
- src/Data/Unfoldable.hs +0/−8
- src/Data/Unfolder.hs +0/−23
- unfoldable.cabal +20/−26
CHANGELOG.md view
@@ -1,3 +1,7 @@+1.1+---+* Updates for GHC 9.6 through 9.14+ 1.0 --- * improved generic implementation of `unfold`
src/Data/Biunfoldable.hs view
@@ -10,7 +10,6 @@ -- -- Class of data structures with 2 type arguments that can be unfolded. ------------------------------------------------------------------------------{-# LANGUAGE Safe #-} module Data.Biunfoldable (
src/Data/Triunfoldable.hs view
@@ -10,8 +10,7 @@ -- -- Class of data structures with 3 type arguments that can be unfolded. ------------------------------------------------------------------------------{-# LANGUAGE Safe #-}-module Data.Triunfoldable +module Data.Triunfoldable ( -- * Triunfoldable@@ -26,7 +25,7 @@ , randomDefault , arbitraryDefault - ) + ) where import Control.Applicative@@ -97,7 +96,7 @@ -- | Provides a QuickCheck generator, can be used as default instance for 'Arbitrary'. arbitraryDefault :: (Arbitrary a, Arbitrary b, Arbitrary c, Triunfoldable t) => Gen (t a b c)-arbitraryDefault = let Arb _ gen = triunfold arbUnit arbUnit arbUnit in +arbitraryDefault = let Arb _ gen = triunfold arbUnit arbUnit arbUnit in fromMaybe (error "Failed to generate a value.") <$> sized (\n -> resize (n + 1) gen) @@ -105,6 +104,6 @@ curry3 f a b c = f (a,b,c) instance Triunfoldable (,,) where- triunfold fa fb fc = choose + triunfold fa fb fc = choose [ (,,) <$> fa <*> fb <*> fc ]
src/Data/Unfoldable.hs view
@@ -10,10 +10,6 @@ -- -- Class of data structures that can be unfolded. ------------------------------------------------------------------------------{-# LANGUAGE CPP, Safe, TupleSections #-}-#ifdef GENERICS-{-# LANGUAGE TypeOperators, DefaultSignatures, FlexibleContexts, TypeApplications #-}-#endif module Data.Unfoldable ( @@ -52,10 +48,8 @@ import qualified Data.Sequence as S import qualified Data.Tree as T -#ifdef GENERICS import GHC.Generics import Generics.OneLiner-#endif -- | Data structures that can be unfolded. --@@ -91,7 +85,6 @@ -- | Given a way to generate elements, return a way to generate structures containing those elements. unfold :: Unfolder f => f a -> f (t a) -#ifdef GENERICS default unfold :: (ADT1 t, Constraints1 t Unfoldable, Unfolder f) => f a -> f (t a) unfold = choose . getCompose . createA1 @Unfoldable (Compose . pure . unfold . asum' . getCompose) . Compose . pure where@@ -99,7 +92,6 @@ asum' [a] = a asum' (a:as) = a <|> asum' as {-# INLINE unfold #-}-#endif -- | Unfold the structure, always using @()@ as elements. unfold_ :: (Unfoldable t, Unfolder f) => f (t ())
src/Data/Unfolder.hs view
@@ -13,17 +13,6 @@ -- allows the unfolder to do something special for the recursive positions -- of the data structure. ------------------------------------------------------------------------------{-# LANGUAGE- GeneralizedNewtypeDeriving- , RankNTypes- , Trustworthy- , CPP- #-}--#if !defined(MIN_VERSION_containers)-#define MIN_VERSION_containers(x,y,z) 0-#endif- module Data.Unfolder ( @@ -77,7 +66,6 @@ import Control.Applicative.Backwards import Control.Applicative.Lift import Control.Monad.Trans.Except-import Control.Monad.Trans.List import Control.Monad.Trans.Maybe import Control.Monad.Trans.RWS import Control.Monad.Trans.Reader@@ -191,14 +179,6 @@ instance (Functor m, Monad m, Monoid e) => Unfolder (ExceptT e m) -- | Derived instance.-instance Applicative f => Unfolder (ListT f) where- {-# INLINABLE chooseMap #-}- chooseMap f = ListT . foldr appRun (pure [])- where- appRun x ys = (++) <$> runListT (f x) <*> ys- chooseInt n = ListT $ pure [0 .. n - 1]---- | Derived instance. instance (Functor m, Monad m) => Unfolder (MaybeT m) where chooseMap _ [] = MaybeT (return Nothing) chooseMap f (a : as) = MaybeT $ do@@ -227,10 +207,7 @@ -- | Don't choose but return all items. instance Unfolder S.Seq where-#if MIN_VERSION_containers(0,5,6) chooseInt n = S.fromFunction n id-#endif- newtype Random g m a = Random { getRandom :: StateT g m a } deriving (Functor, Applicative, Monad)
unfoldable.cabal view
@@ -1,6 +1,6 @@-cabal-version: >= 1.10+cabal-version: 3.6 name: unfoldable-version: 1.0.1+version: 1.1 synopsis: Class of data structures that can be unfolded. description: Just as there's a Foldable class, there should also be an Unfoldable class. .@@ -15,17 +15,19 @@ Some examples can be found in the examples directory. homepage: https://github.com/sjoerdvisscher/unfoldable bug-reports: https://github.com/sjoerdvisscher/unfoldable/issues-license: BSD3+license: BSD-3-Clause license-file: LICENSE author: Sjoerd Visscher maintainer: sjoerd@w3future.com category: Generics build-type: Simple-tested-with: GHC==9.0.1, GHC==8.10.2, GHC==8.8.4+tested-with: GHC==9.6.7, GHC==9.8.4, GHC==9.10.3, GHC==9.12.2, GHC==9.14.1 -extra-Source-Files:+extra-doc-files: CHANGELOG.md++extra-source-files: examples/*.hs src/Data/Triunfoldable.hs @@ -39,31 +41,23 @@ Data.Biunfoldable build-depends:- base >= 4 && < 5- , containers >= 0.5 && < 0.7- , transformers >= 0.4 && < 0.6- , random >= 1.0 && < 1.2- , QuickCheck >= 2.7.3 && < 3.0-- if impl(ghc >= 7.6) && impl(ghc < 9)- cpp-options: -DGENERICS- build-depends:- ghc-prim >= 0.2- , one-liner >= 0.9 && < 2.0-- if impl(ghc >= 9.0)- cpp-options: -DGENERICS- build-depends:- ghc-prim >= 0.2- , one-liner >= 2.0 && < 3.0+ base == 4.*+ , containers >= 0.6 && < 0.8+ , one-liner == 2.*+ , random >= 1 && < 1.3+ , transformers >= 0.4 && < 0.7+ , QuickCheck >= 2.7.3 && < 3 - other-extensions:+ default-extensions: GeneralizedNewtypeDeriving , RankNTypes- , Safe , Trustworthy- , CPP+ , TupleSections+ , TypeOperators+ , DefaultSignatures+ , FlexibleContexts+ , TypeApplications source-repository head type: git- location: git://github.com/sjoerdvisscher/unfoldable.git+ location: https://github.com/sjoerdvisscher/unfoldable