Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mokus0/dependent-sum
Browse files Browse the repository at this point in the history
Conflicts:
	src/Data/Dependent/Sum.hs
	src/Data/GADT/Compare.hs
  • Loading branch information
mokus0 committed Mar 17, 2011
2 parents 8e9acb2 + 61e70d5 commit aaa2398
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Data/Dependent/Sum.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ infixr 1 :=>
-- > showTaggedPrec AnInt = showsPrec
--
class GShow tag => ShowTag tag where
-- |Given a value of type @tag a@, return the 'showsPrec' function for
-- the type parameter @a@.
showTaggedPrec :: tag a -> Int -> a -> ShowS

instance ShowTag tag => Show (DSum tag) where
Expand Down Expand Up @@ -82,6 +84,8 @@ instance ShowTag tag => Show (DSum tag) where
-- Note that 'eqTagged' is not called until after the tags have been
-- compared, so it only needs to consider the cases where 'gcompare' returns 'GEQ'.
class GEq tag => EqTag tag where
-- |Given two values of type @tag a@ (for which 'gcompare' returns 'GEQ'),
-- return the '==' function for the type @a@.
eqTagged :: tag a -> tag a -> a -> a -> Bool

instance EqTag tag => Eq (DSum tag) where
Expand All @@ -103,7 +107,12 @@ instance EqTag tag => Eq (DSum tag) where
-- > instance OrdTag Tag where
-- > compareTagged AString AString = compare
-- > compareTagged AnInt AnInt = compare
--
-- As with 'eqTagged', 'compareTagged' only needs to consider cases where
-- 'gcompare' returns 'GEQ'.
class (EqTag tag, GCompare tag) => OrdTag tag where
-- |Given two values of type @tag a@ (for which 'gcompare' returns 'GEQ'),
-- return the 'compare' function for the type @a@.
compareTagged :: tag a -> tag a -> a -> a -> Ordering

instance OrdTag tag => Ord (DSum tag) where
Expand Down
2 changes: 2 additions & 0 deletions src/Data/GADT/Compare.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ instance Show (GOrdering a b) where

-- |Type class for orderable GADT-like structures. When 2 things are equal,
-- must return a witness that their parameter types are equal as well (GEQ).
-- |Type class for comparable GADT-like structures. When 2 things are equal,
-- must return a witness that their parameter types are equal as well ('GEQ').
class GEq f => GCompare f where
gcompare :: f a -> f b -> GOrdering a b

Expand Down
2 changes: 2 additions & 0 deletions src/Data/GADT/Show.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module Data.GADT.Show where
-- type or should be expected to know how to do so already. For now, one will
-- be provided.
class GShow t where
-- |Given the 'showsPrec' function of the type parameter @a@, return a
-- 'showsPrec' function for the type @t a@.
gshowsPrec :: (Int -> a -> ShowS) -> Int -> t a -> ShowS


Expand Down

0 comments on commit aaa2398

Please sign in to comment.