compare-type 0.1 → 0.1.1
raw patch · 2 files changed
+30/−11 lines, 2 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- compare-type.cabal +4/−4
- src/Type/Compare.hs +26/−7
compare-type.cabal view
@@ -1,6 +1,6 @@ name: compare-type category: Dependent Types -version: 0.1 +version: 0.1.1 license: BSD3 license-file: LICENSE cabal-version: >= 1.10 @@ -10,10 +10,10 @@ stability: provisional homepage: https://github.com/Kinokkory/compare-type bug-reports: https://github.com/Kinokkory/compare-type/issues -copyright: (c) Yusuke Matsushita 2014 +copyright: (c) Yusuke Matsushita 2015 synopsis: compare types of any kinds in haskell description: - Compare types of any kinds in Haskell. + Compare two types of any (possibly different) kinds in Haskell. . More information can be found in the <http://hackage.haskell.org/package/compare-type hackage's haddock> or the <http://kinokkory.github.io/compare-type/ updated haddock>. @@ -33,6 +33,6 @@ TypeFamilies, UndecidableInstances build-depends: - base ==4.* + base >= 4.7 && < 5 exposed-modules: Type.Compare ghc-options: -Wall
src/Type/Compare.hs view
@@ -4,10 +4,27 @@ TypeFamilies, UndecidableInstances #-} +-------------------------------------------------------------------------------- +-- | +-- Module: Type.Compare +-- Copyright: (c) Yusuke Matsushita 2015 +-- License: BSD3 +-- Maintainer: Yusuke Matsushita +-- Stability: provisional +-- Portability: portable +-- +-- Compare two types of any (possibly different) kinds. +-------------------------------------------------------------------------------- + module Type.Compare ( - -- * Comparison - Compare, LargestK(Largest), SmallestK(Smallest), CompareUser, - OrdCase, CompareCase, type (<!), type (>=!), type (>!), type (<=!), Max, Min + -- * Base + Compare, + LargestK(Largest), SmallestK(Smallest), + CompareUser, + -- * Utility + OrdCase, CompareCase, + type (<!), type (>=!), type (>!), type (<=!), + Max, Min ) where import Data.Ord @@ -24,8 +41,12 @@ -- | The smallest type (and kind) on 'Compare'. data SmallestK = Smallest --- | Compare two types. +-- | Compare two types of any (possibly different) kinds. +-- Since `Compare` itself is a closed type family, add instances to `CompareUser` if you want to compare other types. type family Compare (a :: k) (b :: k') :: Ordering where + + Compare (Down a) (Down b) = Compare b a + Compare Largest Largest = EQ Compare _' Largest = LT Compare Largest _' = GT @@ -33,8 +54,6 @@ Compare _' Smallest = GT Compare Smallest _' = LT - Compare (Down a) (Down b) = Compare b a - Compare False False = EQ Compare False True = LT Compare True False = GT @@ -93,7 +112,7 @@ Compare a b = CompareUser a b --- | Compare two types. Users can add instances. +-- | Compare two types, of any kinds, which are not compared within `Compare`. Users can add instances. type family CompareUser (a :: k) (b :: k') :: Ordering type family OrdCase (o :: Ordering) (x :: l1) (y :: l2) (z :: l3) :: l where