diff --git a/AUTHORS b/AUTHORS
new file mode 100644
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,1 @@
+(c) Adrian HEY
diff --git a/CHANGELOG b/CHANGELOG
new file mode 100644
--- /dev/null
+++ b/CHANGELOG
@@ -0,0 +1,4 @@
+2.1
+---
+* Initial Hackage/Cabal release.
+  Version set to 2.1 to distinguish from the 2.0 (non-cabal) release on my home page.
diff --git a/COrdering.cabal b/COrdering.cabal
new file mode 100644
--- /dev/null
+++ b/COrdering.cabal
@@ -0,0 +1,46 @@
+Name:               COrdering
+Version:            2.1
+Cabal-Version:      >= 1.2
+Build-Type:         Simple
+License:            BSD3
+License-File:       LICENSE
+Copyright:          (c) Adrian Hey 2004-2008
+Author:             Adrian Hey
+Maintainer:         http://homepages.nildram.co.uk/~ahey/em.png
+Stability:          Stable
+Homepage:           http://www.haskell.org/haskellwiki/COrdering
+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.2, GHC == 6.8.1
+Data-Files:
+Extra-Source-Files: AUTHORS, CHANGELOG
+Extra-Tmp-Files:
+Author:             Adrian Hey
+
+Library
+ Buildable:          True
+ Build-Depends:      base
+ Exposed-Modules:    Data.COrdering
+ Other-Modules:
+ Extensions:         CPP
+ Hs-Source-Dirs:     .
+ Build-Tools:
+ Ghc-Options:        -O -Wall -split-objs
+ 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:
+
diff --git a/Data/COrdering.hs b/Data/COrdering.hs
new file mode 100644
--- /dev/null
+++ b/Data/COrdering.hs
@@ -0,0 +1,160 @@
+-----------------------------------------------------------------------------
+-- |
+-- 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\"
+-- 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..
+--
+-- @
+-- 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
+-- 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',
+
+        ) where
+
+import Data.Typeable
+
+-- | 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
+
+-- | 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
+
+-- | 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
+
+-- | 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
+
+-- | 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
+
+-- | 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
+
+-- | 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
+
+-- | 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
+
+-- | 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
+
+-- | 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
+
+-- | 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
+
+-- | 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).
+-- 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
+
+-- | 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).
+-- 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
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,31 @@
+See the AUTHORS file for a list of copyright holders.
+
+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 the copyright holders 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.
+
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,3 @@
+#!/usr/bin/runhaskell
+import Distribution.Simple
+main = defaultMain
