universe-reverse-instances (empty) → 1.0
raw patch · 8 files changed
+128/−0 lines, 8 filesdep +basedep +containersdep +universe-instances-basesetup-changed
Dependencies added: base, containers, universe-instances-base
Files
- Data/Universe/Instances/Eq.hs +11/−0
- Data/Universe/Instances/Ord.hs +13/−0
- Data/Universe/Instances/Read.hs +13/−0
- Data/Universe/Instances/Show.hs +10/−0
- Data/Universe/Instances/Traversable.hs +19/−0
- LICENSE +30/−0
- Setup.hs +2/−0
- universe-reverse-instances.cabal +30/−0
+ Data/Universe/Instances/Eq.hs view
@@ -0,0 +1,11 @@+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 view
@@ -0,0 +1,13 @@+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 view
@@ -0,0 +1,13 @@+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 view
@@ -0,0 +1,10 @@+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 view
@@ -0,0 +1,19 @@+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]
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2013, Daniel Wagner++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Daniel Wagner nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++! This software is provided by the copyright holders and contributors+! "as is" and any express or implied warranties, including, but not+! limited to, the implied warranties of merchantability and fitness for+! a particular purpose are disclaimed. In no event shall the copyright+! owner or contributors be liable for any direct, indirect, incidental,+! special, exemplary, or consequential damages (including, but not+! limited to, procurement of substitute goods or services; loss of use,+! data, or profits; or business interruption) however caused and on any+! theory of liability, whether in contract, strict liability, or tort+! (including negligence or otherwise) arising in any way out of the use+! of this software, even if advised of the possibility of such damage.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ universe-reverse-instances.cabal view
@@ -0,0 +1,30 @@+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+source-repository head+ type: git+ location: https://github.com/dmwit/universe+source-repository this+ type: git+ location: https://github.com/dmwit/universe+ tag: 1.0++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