packages feed

universe-reverse-instances 1.0 → 1.1

raw patch · 11 files changed

+129/−92 lines, 11 filesdep +universe-basedep −universe-instances-basedep ~basedep ~containersnew-uploaderPVP ok

version bump matches the API change (PVP)

Dependencies added: universe-base

Dependencies removed: universe-instances-base

Dependency ranges changed: base, containers

API changes (from Hackage documentation)

- Data.Universe.Instances.Eq: instance (Finite a, Eq b) => Eq (a -> b)
- Data.Universe.Instances.Ord: instance (Finite a, Ord b) => Ord (a -> b)
- Data.Universe.Instances.Read: class Read a
- Data.Universe.Instances.Read: instance (Finite a, Ord a, Read a, Read b) => Read (a -> b)
- Data.Universe.Instances.Read: readList :: Read a => ReadS [a]
- Data.Universe.Instances.Read: readsPrec :: Read a => Int -> ReadS a
- Data.Universe.Instances.Show: class Show a
- Data.Universe.Instances.Show: instance (Finite a, Show a, Show b) => Show (a -> b)
- Data.Universe.Instances.Show: show :: Show a => a -> String
- Data.Universe.Instances.Show: showList :: Show a => [a] -> ShowS
- Data.Universe.Instances.Show: showsPrec :: Show a => Int -> a -> ShowS
- Data.Universe.Instances.Traversable: class Foldable (t :: * -> *)
- Data.Universe.Instances.Traversable: class (Functor t, Foldable t) => Traversable (t :: * -> *)
- Data.Universe.Instances.Traversable: fold :: (Foldable t, Monoid m) => t m -> m
- Data.Universe.Instances.Traversable: foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m
- Data.Universe.Instances.Traversable: foldl :: Foldable t => (a -> b -> a) -> a -> t b -> a
- Data.Universe.Instances.Traversable: foldl' :: Foldable t => (a -> b -> a) -> a -> t b -> a
- Data.Universe.Instances.Traversable: foldl1 :: Foldable t => (a -> a -> a) -> t a -> a
- Data.Universe.Instances.Traversable: foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b
- Data.Universe.Instances.Traversable: foldr' :: Foldable t => (a -> b -> b) -> b -> t a -> b
- Data.Universe.Instances.Traversable: foldr1 :: Foldable t => (a -> a -> a) -> t a -> a
- Data.Universe.Instances.Traversable: instance (Ord e, Finite e) => Traversable ((->) e)
- Data.Universe.Instances.Traversable: instance Finite e => Foldable ((->) e)
- Data.Universe.Instances.Traversable: mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
- Data.Universe.Instances.Traversable: sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)
- Data.Universe.Instances.Traversable: sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)
- Data.Universe.Instances.Traversable: traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
+ Data.Universe.Instances.Eq: infix 4 /=
+ Data.Universe.Instances.Eq: instance (Data.Universe.Class.Finite a, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Semigroup.Internal.Endo a)
+ Data.Universe.Instances.Eq: instance (Data.Universe.Class.Finite a, GHC.Classes.Eq b) => GHC.Classes.Eq (a -> b)
+ Data.Universe.Instances.Ord: infix 4 <=
+ Data.Universe.Instances.Ord: instance (Data.Universe.Class.Finite a, GHC.Classes.Ord a) => GHC.Classes.Ord (Data.Semigroup.Internal.Endo a)
+ Data.Universe.Instances.Ord: instance (Data.Universe.Class.Finite a, GHC.Classes.Ord b) => GHC.Classes.Ord (a -> b)
+ Data.Universe.Instances.Read: instance (Data.Universe.Class.Finite a, GHC.Classes.Ord a, GHC.Read.Read a) => GHC.Read.Read (Data.Semigroup.Internal.Endo a)
+ Data.Universe.Instances.Read: instance (Data.Universe.Class.Finite a, GHC.Classes.Ord a, GHC.Read.Read a, GHC.Read.Read b) => GHC.Read.Read (a -> b)
+ Data.Universe.Instances.Show: instance (Data.Universe.Class.Finite a, GHC.Show.Show a) => GHC.Show.Show (Data.Semigroup.Internal.Endo a)
+ Data.Universe.Instances.Show: instance (Data.Universe.Class.Finite a, GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (a -> b)
+ Data.Universe.Instances.Traversable: instance (GHC.Classes.Ord e, Data.Universe.Class.Finite e) => Data.Traversable.Traversable ((->) e)
+ Data.Universe.Instances.Traversable: instance Data.Universe.Class.Finite e => Data.Foldable.Foldable ((->) e)

Files

− Data/Universe/Instances/Eq.hs
@@ -1,11 +0,0 @@-module Data.Universe.Instances.Eq (-	-- | An 'Eq' instance for functions, given the input is 'Finite' and the-	-- output is 'Eq'. Compares pointwise.-	Eq(..)-	) where--import Data.Monoid-import Data.Universe.Instances.Base--instance (Finite a, Eq b) => Eq (a -> b) where-	f == g = and [f x == g x | x <- universeF]
− Data/Universe/Instances/Ord.hs
@@ -1,13 +0,0 @@-module Data.Universe.Instances.Ord (-	-- | An 'Ord' instance for functions, given the input is 'Finite' and the-	-- output is 'Ord'. Compares pointwise, with higher priority to inputs-	-- that appear earlier in 'universeF'.-	Ord(..)-	) where--import Data.Monoid-import Data.Universe.Instances.Base-import Data.Universe.Instances.Eq--instance (Finite a, Ord b) => Ord (a -> b) where-	f `compare` g = mconcat [f x `compare` g x | x <- universeF]
− Data/Universe/Instances/Read.hs
@@ -1,13 +0,0 @@-module Data.Universe.Instances.Read (-	-- | A 'Read' instance for functions, given the input is 'Finite' and-	-- 'Ord' and both the input and output are 'Read'.-	Read(..)-	) where--import Data.Map (fromList, (!))-import Data.Universe.Instances.Base---- actually, the "Finite a" part of the context wouldn't be inferred if you--- asked GHC -- but it's kind of hopeless otherwise!-instance (Finite a, Ord a, Read a, Read b) => Read (a -> b) where-	readsPrec n s = [((fromList v !), s') | (v, s') <- readsPrec n s]
− Data/Universe/Instances/Show.hs
@@ -1,10 +0,0 @@-module Data.Universe.Instances.Show (-	-- | A 'Show' instance for functions, given the input is 'Finite' and both-	-- the input and output are 'Show'.-	Show(..)-	) where--import Data.Universe.Instances.Base--instance (Finite a, Show a, Show b) => Show (a -> b) where-	showsPrec n f = showsPrec n [(a, f a) | a <- universeF]
− Data/Universe/Instances/Traversable.hs
@@ -1,19 +0,0 @@-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'.-	Foldable(..), Traversable(..)-	) where--import Control.Applicative-import Data.Foldable-import Data.Map ((!), fromList)-import Data.Monoid-import Data.Traversable-import Data.Universe.Instances.Base--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]
+ src/Data/Universe/Instances/Eq.hs view
@@ -0,0 +1,14 @@+module Data.Universe.Instances.Eq (+  -- | An 'Eq' instance for functions, given the input is 'Finite' and the+  -- output is 'Eq'. Compares pointwise.+  Eq(..)+  ) where++import Data.Monoid+import Data.Universe.Class++instance (Finite a, Eq b) => Eq (a -> b) where+  f == g = and [f x == g x | x <- universeF]++instance (Finite a, Eq a) => Eq (Endo a) where+  Endo f == Endo g = f == g
+ src/Data/Universe/Instances/Ord.hs view
@@ -0,0 +1,16 @@+module Data.Universe.Instances.Ord (+  -- | An 'Ord' instance for functions, given the input is 'Finite' and the+  -- output is 'Ord'. Compares pointwise, with higher priority to inputs+  -- that appear earlier in 'universeF'.+  Ord(..)+  ) where++import qualified Data.Monoid as Mon+import Data.Universe.Class (Finite (..))+import Data.Universe.Instances.Eq++instance (Finite a, Ord b) => Ord (a -> b) where+  f `compare` g = Mon.mconcat [f x `compare` g x | x <- universeF]++instance (Finite a, Ord a) => Ord (Mon.Endo a) where+  compare (Mon.Endo f) (Mon.Endo g) = compare f g
+ src/Data/Universe/Instances/Read.hs view
@@ -0,0 +1,24 @@+-- | A 'Read' instance for functions, given the input is 'Finite' and+-- 'Ord' and both the input and output are 'Read'.+module Data.Universe.Instances.Read () where++import Data.Universe.Class (Finite (..))++import qualified Data.Map as Map+import qualified Data.Set as Set+import qualified Data.Monoid as Mon++instance (Finite a, Ord a, Read a, Read b) => Read (a -> b) where+  readsPrec n s =+    [ ((m Map.!), s')+    | (v, s') <- readsPrec n s+    , let m = Map.fromList v+    , Map.keysSet m == Set.fromList universeF+    ]++instance (Finite a, Ord a, Read a) => Read (Mon.Endo a) where+  readsPrec d = readParen (d > 10) $ \s0 ->+    [ (Mon.Endo f, s2)+    | ("Endo", s1) <- lex s0+    , (f, s2) <- readsPrec 11 s1+    ]
+ src/Data/Universe/Instances/Show.hs view
@@ -0,0 +1,14 @@+-- | A 'Show' instance for functions, given the input is 'Finite' and both+-- the input and output are 'Show'.+module Data.Universe.Instances.Show () where++import Data.Universe.Class (Universe (..), Finite (..))+import qualified Data.Monoid as Mon++instance (Finite a, Show a, Show b) => Show (a -> b) where+  showsPrec n f = showsPrec n [(a, f a) | a <- universeF]++instance (Finite a, Show a) => Show (Mon.Endo a) where+  showsPrec d (Mon.Endo f) = showParen (d > 10)+    $ showString "Endo "+    . showsPrec 11 f
+ src/Data/Universe/Instances/Traversable.hs view
@@ -0,0 +1,17 @@+-- | A 'Foldable' instance for functions, given the input is 'Finite', and+-- a 'Traversable' instance for functions, given the input is 'Ord' and+-- 'Finite'.+module Data.Universe.Instances.Traversable () where++import Control.Applicative+import Data.Foldable+import Data.Map ((!), fromList)+import Data.Monoid+import Data.Traversable+import Data.Universe.Class++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-reverse-instances.cabal view
@@ -1,30 +1,48 @@-name:                universe-reverse-instances-version:             1.0-synopsis:            instances of standard classes that are made possible by enumerations-homepage:            https://github.com/dmwit/universe-license:             BSD3-license-file:        LICENSE-author:              Daniel Wagner-maintainer:          me@dmwit.com-copyright:           Daniel Wagner 2014-category:            Data-build-type:          Simple-cabal-version:       >=1.10+name:          universe-reverse-instances+version:       1.1+synopsis:+  Instances of standard classes that are made possible by enumerations++description:+  For example this package provides a @Eq (a -> b)@ instance:+  .+  @+  instance (Finite a, Eq b) => Eq (a -> b) where+  f == g = and [f x == g x | x <- universeF]+  @++homepage:      https://github.com/dmwit/universe+license:       BSD3+license-file:  LICENSE+author:        Daniel Wagner+maintainer:    me@dmwit.com+copyright:     Daniel Wagner 2014+category:      Data+build-type:    Simple+cabal-version: >=1.10+tested-with:+  GHC ==8.8.1 || ==8.6.4 || ==8.4.4 || ==8.2.2 || ==8.0.2 || ==7.10.3 || ==7.8.4 || ==7.6.3 || ==7.4.2 || ==7.0.4+ source-repository head-    type:            git-    location:        https://github.com/dmwit/universe+  type:     git+  location: https://github.com/dmwit/universe+ source-repository this-    type:            git-    location:        https://github.com/dmwit/universe-    tag:             1.0+  type:     git+  location: https://github.com/dmwit/universe+  tag:      1.1  library-  exposed-modules:     Data.Universe.Instances.Eq,-                       Data.Universe.Instances.Ord,-                       Data.Universe.Instances.Read,-                       Data.Universe.Instances.Show,-                       Data.Universe.Instances.Traversable-  build-depends:       base                    >=4   && <5  ,-                       containers              >=0.5 && <0.6,-                       universe-instances-base >=1.0 && <1.1-  default-language:    Haskell2010+  default-language: Haskell2010+  hs-source-dirs:   src+  exposed-modules:+    Data.Universe.Instances.Eq+    Data.Universe.Instances.Ord+    Data.Universe.Instances.Read+    Data.Universe.Instances.Show+    Data.Universe.Instances.Traversable++  build-depends:+      base           >=4.3 && <4.13+    , containers     >=0.4 && <0.7+    , universe-base  >=1.1 && <1.1.1