packages feed

portray-diff 0.1.0.1 → 0.1.1

raw patch · 3 files changed

+47/−27 lines, 3 filesdep ~basedep ~portraydep ~textPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base, portray, text

API changes (from Hackage documentation)

- Data.Portray.Diff: instance Data.Portray.Diff.Diff GHC.Integer.Type.Integer
+ Data.Portray.Diff: class GDiff a f
+ Data.Portray.Diff: class GDiffCtor f
+ Data.Portray.Diff: class GDiffRecord f
+ Data.Portray.Diff: gdiff :: GDiff a f => a -> a -> f x -> f x -> Maybe Portrayal
+ Data.Portray.Diff: gdiffCtor :: GDiffCtor f => f x -> f x -> (Any, DList Portrayal)
+ Data.Portray.Diff: gdiffRecord :: GDiffRecord f => f x -> f x -> DList (FactorPortrayal Portrayal)
+ Data.Portray.Diff: instance Data.Portray.Diff.Diff Data.Portray.Base
+ Data.Portray.Diff: instance Data.Portray.Diff.Diff Data.Portray.FloatLiteral
+ Data.Portray.Diff: instance Data.Portray.Diff.Diff Data.Portray.SpecialFloatVal
+ Data.Portray.Diff: instance Data.Portray.Diff.Diff GHC.Num.Integer.Integer

Files

CHANGELOG.md view
@@ -1,7 +1,12 @@-# 0.1.0.0+# 0.1.1 (2022-09-24) -Initial version.+* Update to `portray-0.3.0`.+* Added instances for new `portray` types (thus the minor version bump). -# 0.1.0.1+# 0.1.0.1 (2021-09-17) -* Update to portray-0.2.0.+* Update to `portray-0.2.0`.++# 0.1.0.0 (2021-09-02)++Initial version.
portray-diff.cabal view
@@ -1,23 +1,21 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: 84c038bd3ae071ca5d8573d57e88e5ed82ec69dfc2c67a8fe1c79712c0bab245  name:           portray-diff-version:        0.1.0.1-synopsis:       Visualize the structural differences between two values.+version:        0.1.1+synopsis:       Pretty structural diffs between two values description:    This uses @GHC.Generics@ to provide structural diffs between two values in                 pretty-printed form.  This is primarily useful for test assertions and manual                 inspection of values. category:       Data-homepage:       https://github.com/google/hs-portray#readme-bug-reports:    https://github.com/google/hs-portray/issues-author:         Reiner Pope <reinerp@google.com>, Andrew Pritchard <awpr@google.com>-maintainer:     Reiner Pope <reinerp@google.com>, Andrew Pritchard <awpr@google.com>-copyright:      2018-2021 Google LLC+homepage:       https://github.com/awpr/portray#readme+bug-reports:    https://github.com/awpr/portray/issues+author:         Reiner Pope <reinerp@google.com>, Andrew Pritchard <awpritchard@gmail.com>+maintainer:     Reiner Pope <reinerp@google.com>, Andrew Pritchard <awpritchard@gmail.com>+copyright:      2018-2021 Google LLC; 2022 Andrew Pritchard license:        Apache-2.0 license-file:   LICENSE build-type:     Simple@@ -26,21 +24,19 @@  source-repository head   type: git-  location: https://github.com/google/hs-portray+  location: https://github.com/awpr/portray   subdir: portray-diff  library   exposed-modules:       Data.Portray.Diff-  other-modules:-      Paths_portray_diff   hs-source-dirs:       src   build-depends:-      base >=4.12 && <4.16-    , containers >=0.6 && <0.7+      base >=4.12 && <4.17+    , containers ==0.6.*     , dlist >=0.6 && <1.1-    , portray >=0.2 && <0.3-    , text >=0.1 && <1.3-    , wrapped >=0.1 && <0.2+    , portray ==0.3.*+    , text >=0.1 && <2.1+    , wrapped ==0.1.*   default-language: Haskell2010
src/Data/Portray/Diff.hs view
@@ -1,4 +1,5 @@ -- Copyright 2018-2021 Google LLC+-- Copyright 2022 Andrew Pritchard -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License.@@ -53,7 +54,14 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} -module Data.Portray.Diff (Diff(..), diffAtom, DiffAtom(..), diffVs) where+module Data.Portray.Diff+         ( -- * Structural Diffs+           Diff(..), diffAtom+           -- * Atomic Diff+         , DiffAtom(..), diffVs+           -- * Generic+         , GDiff(..), GDiffRecord(..), GDiffCtor(..)+         ) where  import Prelude hiding (zipWith) @@ -79,13 +87,15 @@  import Data.Portray          ( Portray(..), Portrayal(..), PortrayalF(..), Fix(..)-         , IdentKind(..), Ident(..)+         , IdentKind(..), Ident(..), Base(..)+         , FloatLiteral(..), SpecialFloatVal(..)          , Infixity(..), Assoc(..), FactorPortrayal(..)          , showAtom, portrayType          ) import qualified Data.DList as D import Data.Wrapped (Wrapped(..), Wrapped1(..)) +-- | Structural comparison between values giving a description of differences. class Diff a where   -- | Returns 'Nothing' when equal; or a 'Portrayal' showing the differences.   diff :: a -> a -> Maybe Portrayal@@ -95,6 +105,7 @@ instance (Generic a, GDiff a (Rep a)) => Diff (Wrapped Generic a) where   diff (Wrapped x) (Wrapped y) = gdiff x y (from x) (from y) +-- | Produce a 'Portrayal' describing a single atomic difference. vs, diffVs :: Portrayal -> Portrayal -> Portrayal vs a b = Binop (Ident OpIdent "/=") (Infixity AssocNope 4) a b diffVs = vs@@ -106,7 +117,7 @@   | a == b = Nothing   | otherwise = Just (portray a `vs` portray b) --- Diff record fields, creating docs only for fields that differ.+-- | Diff record fields, creating docs only for fields that differ. class GDiffRecord f where   gdiffRecord :: f x -> f x -> D.DList (FactorPortrayal Portrayal) @@ -123,8 +134,8 @@ instance (GDiffRecord f, GDiffRecord g) => GDiffRecord (f :*: g) where   gdiffRecord (fa :*: ga) (fb :*: gb) = gdiffRecord fa fb <> gdiffRecord ga gb --- Diff constructor fields, filling equal fields with "_" and reporting whether--- any diffs were detected.+-- | Diff constructor fields, filling equal fields with "_" and reporting+-- whether any diffs were detected. -- -- N.B. this works fine on record constructors, too, in case we want to support -- configuring whether to use record syntax or constructor application syntax.@@ -147,6 +158,10 @@ instance (GDiffCtor f, GDiffCtor g) => GDiffCtor (f :*: g) where   gdiffCtor (fa :*: ga) (fb :*: gb) = gdiffCtor fa fb <> gdiffCtor ga gb +-- | Generic implementation of 'Diff'.+--+-- This is primarily exported to appease Haddock; use @via Wrapped Generic T@+-- to access this functionality. class GDiff a f where   gdiff :: a -> a -> f x -> f x -> Maybe Portrayal @@ -210,6 +225,7 @@ instance Diff Text where diff = diffAtom instance (Eq a, Portray a) => Diff (Ratio a) where diff = diffAtom +-- | A @DerivingVia@ wrapper for providing 'Diff' by 'Eq' and 'Portray'. newtype DiffAtom a = DiffAtom a   deriving newtype (Eq, Portray) @@ -267,6 +283,9 @@ deriving via Wrapped Generic IdentKind instance Diff IdentKind deriving via Wrapped Generic Ident instance Diff Ident deriving via Wrapped Generic Infixity instance Diff Infixity+deriving via Wrapped Generic Base instance Diff Base+deriving via Wrapped Generic FloatLiteral instance Diff FloatLiteral+deriving via Wrapped Generic SpecialFloatVal instance Diff SpecialFloatVal deriving via Wrapped Generic (FactorPortrayal a)   instance Diff a => Diff (FactorPortrayal a) deriving via Wrapped Generic (PortrayalF a)