COrdering 2.3 → 2.3.1
raw patch · 5 files changed
+126/−146 lines, 5 filesdep ~basesetup-changednew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
- Data.COrdering: instance Eq a => Eq (COrdering a)
- Data.COrdering: instance Ord a => Ord (COrdering a)
- Data.COrdering: instance Read a => Read (COrdering a)
- Data.COrdering: instance Show a => Show (COrdering a)
- Data.COrdering: instance Typeable1 COrdering
+ Data.COrdering: instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.COrdering.COrdering a)
+ Data.COrdering: instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.COrdering.COrdering a)
+ Data.COrdering: instance GHC.Read.Read a => GHC.Read.Read (Data.COrdering.COrdering a)
+ Data.COrdering: instance GHC.Show.Show a => GHC.Show.Show (Data.COrdering.COrdering a)
- Data.COrdering: flipC :: (a -> b -> Ordering) -> (b -> a -> Ordering)
+ Data.COrdering: flipC :: (a -> b -> Ordering) -> b -> a -> Ordering
- Data.COrdering: flipCC :: (a -> b -> COrdering c) -> (b -> a -> COrdering c)
+ Data.COrdering: flipCC :: (a -> b -> COrdering c) -> b -> a -> COrdering c
- Data.COrdering: fstByCC :: (a -> b -> Ordering) -> (a -> b -> COrdering a)
+ Data.COrdering: fstByCC :: (a -> b -> Ordering) -> a -> b -> COrdering a
- Data.COrdering: fstCC :: Ord a => (a -> a -> COrdering a)
+ Data.COrdering: fstCC :: Ord a => a -> a -> COrdering a
- Data.COrdering: sndByCC :: (a -> b -> Ordering) -> (a -> b -> COrdering b)
+ Data.COrdering: sndByCC :: (a -> b -> Ordering) -> a -> b -> COrdering b
- Data.COrdering: sndCC :: Ord a => (a -> a -> COrdering a)
+ Data.COrdering: sndCC :: Ord a => a -> a -> COrdering a
- Data.COrdering: unitByCC :: (a -> b -> Ordering) -> (a -> b -> COrdering ())
+ Data.COrdering: unitByCC :: (a -> b -> Ordering) -> a -> b -> COrdering ()
- Data.COrdering: unitCC :: Ord a => (a -> a -> COrdering ())
+ Data.COrdering: unitCC :: Ord a => a -> a -> COrdering ()
- Data.COrdering: withByCC :: (a -> b -> Ordering) -> (a -> b -> c) -> (a -> b -> COrdering c)
+ Data.COrdering: withByCC :: (a -> b -> Ordering) -> (a -> b -> c) -> a -> b -> COrdering c
- Data.COrdering: withByCC' :: (a -> b -> Ordering) -> (a -> b -> c) -> (a -> b -> COrdering c)
+ Data.COrdering: withByCC' :: (a -> b -> Ordering) -> (a -> b -> c) -> a -> b -> COrdering c
- Data.COrdering: withCC :: Ord a => (a -> a -> b) -> (a -> a -> COrdering b)
+ Data.COrdering: withCC :: Ord a => (a -> a -> b) -> a -> a -> COrdering b
- Data.COrdering: withCC' :: Ord a => (a -> a -> b) -> (a -> a -> COrdering b)
+ Data.COrdering: withCC' :: Ord a => (a -> a -> b) -> a -> a -> COrdering b
Files
- CHANGELOG +0/−14
- CHANGELOG.md +18/−0
- COrdering.cabal +32/−43
- Data/COrdering.hs +76/−86
- Setup.hs +0/−3
− CHANGELOG
@@ -1,14 +0,0 @@-2.1 ---- -* Initial Hackage/Cabal release. - Version set to 2.1 to distinguish from the 2.0 (non-cabal) release on my home page. - -2.2 (Final release) -------------------- -* No code changes. -* Removed link to Haskell wiki homepage as this will never be done. -* Removed link to maintainer email. - -2.3 ---- -No code changes, just reclaiming ownership and bumping version No.
+ CHANGELOG.md view
@@ -0,0 +1,18 @@+# 2.3.1 + +* Class `Typeable1` is no longer a thing. + +# 2.3 + +* No code changes, just reclaiming ownership and bumping version No. + +# 2.2 (Final release) + +* No code changes. +* Removed link to Haskell wiki homepage as this will never be done. +* Removed link to maintainer email. + +# 2.1 + +* Initial Hackage/Cabal release. + Version set to 2.1 to distinguish from the 2.0 (non-cabal) release on my home page.
COrdering.cabal view
@@ -1,45 +1,34 @@-Name: COrdering-Version: 2.3-Cabal-Version: >= 1.2-Build-Type: Simple-License: BSD3-License-File: LICENSE-Copyright: (c) Adrian Hey 2004-2008-Author: Adrian Hey-Maintainer: Adrian Hey http://homepages.nildram.co.uk/~ahey/em.png-Stability: Stable-Homepage:-Package-Url:-Synopsis: An algebraic data type similar to Prelude Ordering.-Description: Typically this is used as the return type of a combining comparison, which combines two- values if they are deemed equal in some sense. Currently combining comparisons are used- extensively by the AVL tree package (AvlTree).-Category: Data-Tested-With: GHC == 6.8.3, GHC == 6.8.2, GHC == 6.8.1-Data-Files:-Extra-Source-Files: AUTHORS, CHANGELOG-Extra-Tmp-Files:+cabal-version: >=1.10+name: COrdering+version: 2.3.1+license: BSD3+license-file: LICENSE+copyright: (c) Adrian Hey 2004-2008+maintainer: Bodigrim+author: Adrian Hey+tested-with:+ ghc ==8.4.4 ghc ==8.6.5 ghc ==8.8.4 ghc ==8.10.1 ghc ==9.0.2+ ghc ==9.2.8 ghc ==9.4.8 ghc ==9.6.7 ghc ==9.8.4 ghc ==9.10.2+ ghc ==9.12.2 ghc ==9.14.1 -Library- Buildable: True- Build-Depends: base- Exposed-Modules: Data.COrdering- Other-Modules:- Extensions: CPP- Hs-Source-Dirs: .- Build-Tools:- Ghc-Options: -Wall- Ghc-Prof-Options:- Ghc-Shared-Options:- Hugs-Options:- Nhc98-Options:- Includes:- Install-Includes:- Include-Dirs:- C-Sources:- Extra-Libraries:- Extra-Lib-Dirs:- CC-Options:- LD-Options:- Pkgconfig-Depends:+synopsis: An algebraic data type similar to Prelude Ordering.+description:+ Typically this is used as the return type of a combining comparison, which combines two+ values if they are deemed equal in some sense. Currently combining comparisons are used+ extensively by the <https://hackage.haskell.org/package/AvlTree AVL tree package> +category: Data+build-type: Simple+extra-source-files:+ AUTHORS+ CHANGELOG.md++source-repository head+ type: git+ location: https://github.com/Bodigrim/COrdering.git++library+ exposed-modules: Data.COrdering+ default-language: Haskell2010+ ghc-options: -Wall+ build-depends: base >=4.11 && <5
Data/COrdering.hs view
@@ -1,160 +1,150 @@------------------------------------------------------------------------------ -- |--- Module : Data.COrdering -- Copyright : (c) Adrian Hey 2004-2008 -- License : BSD3 ----- Maintainer : http://homepages.nildram.co.uk/~ahey/em.png--- Stability : stable--- Portability : portable--- -- This module defines a useful variant of the "Prelude" `Ordering` data type. ----- Typically this data type is used as the result of a \"combining comparison\"+-- Typically this data type is used as the result of a "combining comparison" -- which combines values that are deemed to be equal (somehow). Note that the -- functions defined here adhere to the same ordering convention as the overloaded--- 'compare' (from the 'Ord' class). That is..+-- 'compare' (from the 'Ord' class): -- -- @ -- a \`compare\` b -> LT (or Lt) implies a < b -- a \`compare\` b -> GT (or Gt) implies a > b -- @ ----- The combinators exported from this module have a \"CC\" suffix if they--- return a combining comparison (most of them) and a \"C\" suffix if they return--- an ordinary comparison. All the combinators defined here are INLINEd, in the hope+-- The combinators exported from this module have a @CC@ suffix if they+-- return a combining comparison (most of them) and a @C@ suffix if they return+-- an ordinary comparison. All the combinators defined here are @INLINE@d, in the hope -- that the compiler can avoid the overhead of using HOFs for frequently--- used comparisons (dunno if this does any good though :-)-------------------------------------------------------------------------------module Data.COrdering- ( -- * Types- COrdering(..),-- -- * Useful combinators-- -- ** Misc.- unitCC,unitByCC,- fstCC,fstByCC,- sndCC,sndByCC,- flipC,flipCC,-- -- ** For combining \"equal\" values with a user supplied function.- withCC,withCC',withByCC,withByCC',+-- used comparisons.+module Data.COrdering (+ COrdering (..), - ) where+ -- * Useful combinators+ unitCC,+ unitByCC,+ fstCC,+ fstByCC,+ sndCC,+ sndByCC,+ flipC,+ flipCC, -import Data.Typeable+ -- ** For combining "equal" values with a user supplied function+ withCC,+ withCC',+ withByCC,+ withByCC',+) where -- | Result of a combining comparison.-data COrdering a = Lt | Eq a | Gt deriving (Eq,Ord,Read,Show)---- A name for the COrdering type constructor, fully qualified-cOrderingTyConName :: String-cOrderingTyConName = "Data.COrdering.COrdering"---- A Typeable1 instance-instance Typeable1 COrdering where- typeOf1 _ = mkTyConApp (mkTyCon cOrderingTyConName) []--#ifndef __GLASGOW_HASKELL__--- A Typeable instance (not needed by ghc, but Haddock fails to document this instance)-instance Typeable e => Typeable (COrdering e) where- typeOf = typeOfDefault-#endif+data COrdering a = Lt | Eq a | Gt deriving (Eq, Ord, Read, Show) --- | A combining comparison for an instance of 'Ord' which returns unit () where appropriate.+-- | A combining comparison for an instance of 'Ord' which returns unit @()@ where appropriate. {-# INLINE unitCC #-} unitCC :: Ord a => (a -> a -> COrdering ())-unitCC a b = case compare a b of LT -> Lt- EQ -> Eq ()- GT -> Gt+unitCC a b = case compare a b of+ LT -> Lt+ EQ -> Eq ()+ GT -> Gt --- | Create a combining comparison from an ordinary comparison by returning unit () where appropriate.+-- | Create a combining comparison from an ordinary comparison by returning unit @()@ where appropriate. {-# INLINE unitByCC #-} unitByCC :: (a -> b -> Ordering) -> (a -> b -> COrdering ())-unitByCC cmp a b = case cmp a b of LT -> Lt- EQ -> Eq ()- GT -> Gt+unitByCC cmp a b = case cmp a b of+ LT -> Lt+ EQ -> Eq ()+ GT -> Gt -- | A combining comparison for an instance of 'Ord' which keeps the first argument -- if they are deemed equal. The second argument is discarded in this case. {-# INLINE fstCC #-} fstCC :: Ord a => (a -> a -> COrdering a)-fstCC a a' = case compare a a' of LT -> Lt- EQ -> Eq a- GT -> Gt+fstCC a a' = case compare a a' of+ LT -> Lt+ EQ -> Eq a+ GT -> Gt -- | Create a combining comparison from an ordinary comparison by keeping the first argument -- if they are deemed equal. The second argument is discarded in this case. {-# INLINE fstByCC #-} fstByCC :: (a -> b -> Ordering) -> (a -> b -> COrdering a)-fstByCC cmp a b = case cmp a b of LT -> Lt- EQ -> Eq a- GT -> Gt+fstByCC cmp a b = case cmp a b of+ LT -> Lt+ EQ -> Eq a+ GT -> Gt -- | A combining comparison for an instance of 'Ord' which keeps the second argument -- if they are deemed equal. The first argument is discarded in this case. {-# INLINE sndCC #-} sndCC :: Ord a => (a -> a -> COrdering a)-sndCC a a' = case compare a a' of LT -> Lt- EQ -> Eq a'- GT -> Gt+sndCC a a' = case compare a a' of+ LT -> Lt+ EQ -> Eq a'+ GT -> Gt -- | Create a combining comparison from an ordinary comparison by keeping the second argument -- if they are deemed equal. The first argument is discarded in this case. {-# INLINE sndByCC #-} sndByCC :: (a -> b -> Ordering) -> (a -> b -> COrdering b)-sndByCC cmp a b = case cmp a b of LT -> Lt- EQ -> Eq b- GT -> Gt+sndByCC cmp a b = case cmp a b of+ LT -> Lt+ EQ -> Eq b+ GT -> Gt -- | Create a combining comparison using the supplied combining function, which is applied if -- 'compare' returns 'EQ'. See 'withCC'' for a stricter version of this function. {-# INLINE withCC #-} withCC :: Ord a => (a -> a -> b) -> (a -> a -> COrdering b)-withCC f a a' = case compare a a' of LT -> Lt- EQ -> Eq (f a a')- GT -> Gt+withCC f a a' = case compare a a' of+ LT -> Lt+ EQ -> Eq (f a a')+ GT -> Gt -- | Same as 'withCC', except the combining function is applied strictly. {-# INLINE withCC' #-} withCC' :: Ord a => (a -> a -> b) -> (a -> a -> COrdering b)-withCC' f a a' = case compare a a' of LT -> Lt- EQ -> let b = f a a' in b `seq` Eq b- GT -> Gt+withCC' f a a' = case compare a a' of+ LT -> Lt+ EQ -> let b = f a a' in b `seq` Eq b+ GT -> Gt -- | Create a combining comparison using the supplied comparison and combining function, -- which is applied if the comparison returns 'EQ'. See 'withByCC'' for a stricter version -- of this function. {-# INLINE withByCC #-} withByCC :: (a -> b -> Ordering) -> (a -> b -> c) -> (a -> b -> COrdering c)-withByCC cmp f a b = case cmp a b of LT -> Lt- EQ -> Eq (f a b)- GT -> Gt+withByCC cmp f a b = case cmp a b of+ LT -> Lt+ EQ -> Eq (f a b)+ GT -> Gt -- | Same as 'withByCC', except the combining function is applied strictly. {-# INLINE withByCC' #-} withByCC' :: (a -> b -> Ordering) -> (a -> b -> c) -> (a -> b -> COrdering c)-withByCC' cmp f a b = case cmp a b of LT -> Lt- EQ -> let c = f a b in c `seq` Eq c- GT -> Gt+withByCC' cmp f a b = case cmp a b of+ LT -> Lt+ EQ -> let c = f a b in c `seq` Eq c+ GT -> Gt -- | Converts a comparison to one which takes arguments in flipped order, but--- preserves the ordering that would be given by the \"unflipped\" version (disregarding type issues).+-- preserves the ordering that would be given by the "unflipped" version (disregarding type issues). -- So it's not the same as using the prelude 'flip' (which would reverse the ordering too). {-# INLINE flipC #-} flipC :: (a -> b -> Ordering) -> (b -> a -> Ordering)-flipC cmp b a = case cmp a b of LT -> GT- EQ -> EQ- GT -> LT+flipC cmp b a = case cmp a b of+ LT -> GT+ EQ -> EQ+ GT -> LT -- | Converts a combining comparison to one which takes arguments in flipped order, but--- preserves the ordering that would be given by the \"unflipped\" version (disregarding type issues).+-- preserves the ordering that would be given by the "unflipped" version (disregarding type issues). -- So it's not the same as using the prelude 'flip' (which would reverse the ordering too). {-# INLINE flipCC #-} flipCC :: (a -> b -> COrdering c) -> (b -> a -> COrdering c)-flipCC cmp b a = case cmp a b of Lt -> Gt- e@(Eq _) -> e- Gt -> Lt--+flipCC cmp b a = case cmp a b of+ Lt -> Gt+ e@(Eq _) -> e+ Gt -> Lt
− Setup.hs
@@ -1,3 +0,0 @@-#!/usr/bin/runhaskell-import Distribution.Simple-main = defaultMain