summer 0.3.7.0 → 0.3.7.1
raw patch · 4 files changed
+28/−31 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Prodder: instance (Data.Prodder.Contains x y, Data.Prodder.HasIndexIn x xs) => Data.Prodder.Contains (Data.Prodder.Prod xs) (Data.Prodder.Nested y)
- Data.Prodder: instance (GHC.TypeNats.KnownNat (Data.Prodder.Length xs'), Data.Prodder.Strengthen xs xs') => Data.Prodder.Contains (Data.Prodder.Prod xs) (Data.Prodder.Prod xs')
- Data.Prodder: instance Data.Prodder.HasIndexIn x xs => Data.Prodder.Contains (Data.Prodder.Prod xs) x
- Data.Summer: instance (GHC.Show.Show x, Data.Typeable.Internal.Typeable x, GHC.Show.Show (Data.Summer.Sum xs)) => GHC.Show.Show (Data.Summer.Sum (x : xs))
- Data.Summer: instance GHC.Show.Show (Data.Summer.Sum '[])
+ Data.Summer: instance (GHC.Show.Show x, Data.Typeable.Internal.Typeable x) => Data.Summer.ShowTypeable x
+ Data.Summer: instance Data.Summer.ApplyFunction Data.Summer.ShowTypeable xs => GHC.Show.Show (Data.Summer.Sum xs)
Files
- src/Data/Prodder.hs +0/−14
- src/Data/Summer.hs +11/−10
- summer.cabal +1/−1
- test/Test.hs +16/−6
src/Data/Prodder.hs view
@@ -330,17 +330,3 @@ toList :: forall c xs a. FoldProd c xs => (forall x. c x => x -> a) -> Prod xs -> [a] toList f = foldProd @c (pure . f) {-# INLINE CONLIKE toList #-}--class x `Contains` y where- uncontain :: x -> y--instance {-# OVERLAPPABLE #-} x `HasIndexIn` xs => Prod xs `Contains` x where- uncontain = extract--instance {-# OVERLAPPABLE #-} (KnownNat (Length xs'), Strengthen xs xs') => Prod xs `Contains` Prod xs' where- uncontain = strengthen--newtype Nested a = Nested { unNest :: a }--instance {-# OVERLAPPABLE #-} (x `Contains` y, x `HasIndexIn` xs) => Prod xs `Contains` Nested y where- uncontain = Nested . uncontain @x @y . uncontain @(Prod xs) @x
src/Data/Summer.hs view
@@ -219,17 +219,18 @@ (==) = error "(==) base case: impossible by construction" {-# INLINE CONLIKE (==) #-} +class (Show x, Typeable x) => ShowTypeable x+instance (Show x, Typeable x) => ShowTypeable x+ -- | Showing extensible sums.-instance Show (Sum '[]) where- showsPrec n uv = error "show base case: impossible by construction"-instance (Show x, Typeable x, Show (Sum xs)) => Show (Sum (x ': xs)) where- showsPrec d uv@(UnsafeInj tag' x)- | tag' == 0 = showParen (d > 10) $- showString "Inj @"- . showParen True (showsPrec (d + 1) (typeRep (Proxy @x)))- . showString " "- . showParen True (showsPrec @x (d + 1) (unsafeCoerce x))- | otherwise = showsPrec @(Sum xs) d (unsafeForgetFirst uv)+instance ApplyFunction ShowTypeable xs => Show (Sum xs) where+ showsPrec d v = showParen (d > 10) $+ showString "Inj @"+ . apply @ShowTypeable (\(x :: x) ->+ showsPrec (d + 1) (typeRep (Proxy @x))+ . showString " "+ . showParen True (showsPrec (d + 1) x)+ ) v -- | Transforming one sum into a sum which contains all of the same types class Weaken xs ys where
summer.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: summer-version: 0.3.7.0+version: 0.3.7.1 synopsis: An implementation of extensible products and sums description: An implementation of extensible products and sums. license: MIT
test/Test.hs view
@@ -167,10 +167,12 @@ considerTest = do let x :: Sum '[Int, Bool] = Inj (10 :: Int) y :: Sum '[Int, Bool] = Inj True- requires- [ (consider @Int x == Right 10, "x at Int is not considered to be 10"),- (consider @Int y == Left (Inj True), "x is not considered to be Left (Inj True)"),- (consider @Bool y == Right True, "x at Bool is not considered to be Right True")+ z :: Sum '[Int, Bool, Char] = Inj @Int 10+ requires' "consider"+ [ consider @Int x == Right 10+ , consider @Int y == Left (Inj True)+ , consider @Bool y == Right True+ , consider @Bool z == Left (Inj @Int 10) ] inmapTest = do let x :: Sum '[Int, Bool] = Inj (10 :: Int)@@ -197,7 +199,15 @@ require (apply @Show show x == "False") "apply does not work 0" unorderedMatchTest = do let x :: Sum '[Int, Bool] = Inj False- require (unorderedMatch x not (\(x :: Int) -> x == 10)) "unordered match does not work 0"+ requires' "unordered match"+ [ unorderedMatch x not (\(x :: Int) -> x == 10)+ , unorderedMatch x (\(x :: Int) -> x == 10) not+ ] showTest = do let x :: Sum '[Int, Bool] = Inj False- require (show x == "Inj @Bool False") "show sum does not work 0"+ let y :: Sum '[Int, Bool] = Inj @Int 1+ requires' "show sum"+ [ show x == "Inj @Bool False"+ , show y == "Inj @Int 1"+ ]+