packages feed

universe 0.3 → 0.4

raw patch · 4 files changed

+28/−4 lines, 4 files

Files

Data/Universe.hs view
@@ -50,6 +50,10 @@ instance (Universe a, Universe b, Universe c, Universe d) => Universe (a, b, c, d) where universe = [(a,b,c,d) | (((a,b),c),d) <- universe +*+ universe +*+ universe +*+ universe] instance (Universe a, Universe b, Universe c, Universe d, Universe e) => Universe (a, b, c, d, e) where universe = [(a,b,c,d,e) | ((((a,b),c),d),e) <- universe +*+ universe +*+ universe +*+ universe +*+ universe] +instance Finite a => Universe [a] where universe = [] : interleave [[h:t | t <- universe] | h <- universe]+-- probably also possible, but wait until somebody demands it:+-- instance Universe a => Universe [a] where universe = {- something using choices and diagonal and replicate n universe -}+ instance Universe All where universe = map All universe instance Universe Any where universe = map Any universe instance Universe a => Universe (Sum     a) where universe = map Sum     universe
Data/Universe/Instances.hs view
@@ -1,10 +1,11 @@ module Data.Universe.Instances ( 	-- | A convenience module that imports the submodules @Eq@, @Ord@, @Show@,-	-- and @Read@ to provide instances of these classes for functions over-	-- finite inputs.+	-- @Read@, and @Traversable@ to provide instances of these classes for+	-- functions over finite inputs. 	) where  import Data.Universe.Instances.Eq import Data.Universe.Instances.Ord import Data.Universe.Instances.Show import Data.Universe.Instances.Read+import Data.Universe.Instances.Traversable
+ Data/Universe/Instances/Traversable.hs view
@@ -0,0 +1,18 @@+module Data.Universe.Instances.Traversable (+	-- | A 'Foldable' instance for functions, given the input is 'Finite', and+	-- a 'Traversable' instance for functions, given the input is 'Ord' and+	-- 'Finite'.+	) where++import Control.Applicative+import Data.Foldable+import Data.Map ((!), fromList)+import Data.Monoid+import Data.Traversable+import Data.Universe++instance Finite e => Foldable ((->) e) where+	foldMap f g = mconcat $ map (f . g) universeF++instance (Ord e, Finite e) => Traversable ((->) e) where+	sequenceA f = (!) . fromList <$> sequenceA [(,) x <$> f x | x <- universeF]
universe.cabal view
@@ -1,5 +1,5 @@ name:                universe-version:             0.3+version:             0.4 synopsis:            Classes for types where we know all the values description:         A small package, in the spirit of data-default, which allows the munging of finite and recursively enumerable types license:             BSD3@@ -27,7 +27,8 @@                        Data.Universe.Instances.Eq,                        Data.Universe.Instances.Ord,                        Data.Universe.Instances.Read,-                       Data.Universe.Instances.Show+                       Data.Universe.Instances.Show,+                       Data.Universe.Instances.Traversable   other-modules:       Data.Universe.Class   hs-source-dirs:      .   if impl(ghc >= 7.4)