| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Cardano.Ledger.Binary.TreeDiff
Contents
Synopsis
- class ToExpr a where
- toExpr ∷ a → Expr
- listToExpr ∷ [a] → Expr
- newtype CBORBytes = CBORBytes {}
- newtype HexBytes = HexBytes {}
- showExpr ∷ ToExpr a ⇒ a → String
- ansiExpr ∷ ToExpr a ⇒ a → Doc AnsiStyle
- ansiExprString ∷ ToExpr a ⇒ a → String
- diffExpr ∷ ToExpr a ⇒ a → a → Doc AnsiStyle
- diffExprString ∷ ToExpr a ⇒ a → a → String
- diffExprCompact ∷ ToExpr a ⇒ a → a → Doc AnsiStyle
- diffExprCompactString ∷ ToExpr a ⇒ a → a → String
- ansiDocToString ∷ Doc AnsiStyle → String
- hexByteStringExpr ∷ ByteString → [Expr]
- showHexBytesGrouped ∷ Int → ByteString → [String]
- assertColorFailure ∷ HasCallStack ⇒ String → IO a
- expectExprEqual ∷ (Eq a, ToExpr a) ⇒ a → a → Expectation
- expectExprEqualWithMessage ∷ (ToExpr a, Eq a, HasCallStack) ⇒ String → a → a → Expectation
- callStackToLocation ∷ CallStack → Maybe Location
- srcLocToLocation ∷ SrcLoc → Location
- data Expr
- = App ConstructorName [Expr]
- | Rec ConstructorName (OMap FieldName Expr)
- | Lst [Expr]
- defaultExprViaShow ∷ Show a ⇒ a → Expr
- trimExprViaShow ∷ Show a ⇒ Int → a → Expr
- tableDoc ∷ Maybe (Doc AnsiStyle) → [(String, Doc AnsiStyle)] → Doc AnsiStyle
- data Pretty doc = Pretty {}
- data Doc ann
- data AnsiStyle
- ansiWlPretty ∷ Pretty Doc
- ppEditExpr ∷ Pretty doc → Edit EditExpr → doc
- ediff ∷ ToExpr a ⇒ a → a → Edit EditExpr
Documentation
toExpr converts a Haskell value into
untyped Haskell-like syntax tree, Expr.
>>>toExpr ((1, Just 2) :: (Int, Maybe Int))App "_\215_" [App "1" [],App "Just" [App "2" []]]
Minimal complete definition
Nothing
Methods
listToExpr ∷ [a] → Expr Source #
Instances
Constructors
| CBORBytes | |
Fields | |
Wraps regular ByteString, but shows and diffs it as hex
Constructors
| HexBytes | |
Fields | |
ansiExprString ∷ ToExpr a ⇒ a → String Source #
diffExprString ∷ ToExpr a ⇒ a → a → String Source #
diffExprCompactString ∷ ToExpr a ⇒ a → a → String Source #
hexByteStringExpr ∷ ByteString → [Expr] Source #
showHexBytesGrouped ∷ Int → ByteString → [String] Source #
Show a ByteString as hex groups of 8bytes each. This is a slightly more useful form for debugging, rather than bunch of escaped characters.
assertColorFailure ∷ HasCallStack ⇒ String → IO a Source #
Similar to assertFailure, except hspec will not interfer with any escape sequences
that indicate color output.
expectExprEqual ∷ (Eq a, ToExpr a) ⇒ a → a → Expectation Source #
Check that two values are equal and if they are not raise an exception with the
ToExpr diff
expectExprEqualWithMessage ∷ (ToExpr a, Eq a, HasCallStack) ⇒ String → a → a → Expectation Source #
A untyped Haskell-like expression.
Having richer structure than just Tree allows to have richer diffs.
Constructors
| App ConstructorName [Expr] | application |
| Rec ConstructorName (OMap FieldName Expr) | record constructor |
| Lst [Expr] | list constructor |
defaultExprViaShow ∷ Show a ⇒ a → Expr Source #
An alternative implementation for literal types. We use show
representation of them.
Because we don't want to commit to single pretty printing library, we use explicit dictionary.
Constructors
| Pretty | |
Fields
| |
The abstract data type represents pretty documents that have
been annotated with data of type Doc annann.
More specifically, a value of type represents a non-empty set of
possible layouts of a document. The layout functions select one of these
possibilities, taking into account things like the width of the output
document.Doc
The annotation is an arbitrary piece of data associated with (part of) a document. Annotations may be used by the rendering backends in order to display output differently, such as
- color information (e.g. when rendering to the terminal)
- mouseover text (e.g. when rendering to rich HTML)
- whether to show something or not (to allow simple or detailed versions)
The simplest way to display a Doc is via the Show class.
>>>putStrLn (show (vsep ["hello", "world"]))hello world
Instances
Render the annotated document in a certain style. Styles not set in the annotation will use the style of the surrounding document, or the terminal’s default if none has been set yet.
style =colorGreen<>boldstyledDoc =annotatestyle "hello world"
Instances
| Monoid AnsiStyle |
|
| Semigroup AnsiStyle | Keep the first decision for each of foreground color, background color, boldness, italication, and underlining. If a certain style is not set, the terminal’s default will be used. Example:
is red because the first color wins, and not bold because (or if) that’s the terminal’s default. |
| Show AnsiStyle | |
| Eq AnsiStyle | |
| Ord AnsiStyle | |
Defined in Prettyprinter.Render.Terminal.Internal | |
ediff ∷ ToExpr a ⇒ a → a → Edit EditExpr Source #
Difference between two ToExpr values.
>>>let x = (1, Just 2) :: (Int, Maybe Int)>>>let y = (1, Nothing)>>>prettyEditExpr (ediff x y)_×_ 1 -(Just 2) +Nothing
>>>data Foo = Foo { fooInt :: Either Char Int, fooBool :: [Maybe Bool], fooString :: String } deriving (Eq, Generic)>>>instance ToExpr Foo
>>>prettyEditExpr $ ediff (Foo (Right 2) [Just True] "fo") (Foo (Right 3) [Just True] "fo")Foo {fooInt = Right -2 +3, fooBool = [Just True], fooString = "fo"}
>>>prettyEditExpr $ ediff (Foo (Right 42) [Just True, Just False] "old") (Foo (Right 42) [Nothing, Just False, Just True] "new")Foo { fooInt = Right 42, fooBool = [-Just True, +Nothing, Just False, +Just True], fooString = -"old" +"new"}
Orphan instances
| ToExpr DecoderError Source # | |
| ToExpr Version Source # | |
| ToExpr DeserialiseFailure Source # | |
| ToExpr Term Source # | |
| ToExpr IPv4 Source # | |
| ToExpr IPv6 Source # | |
| ToExpr a ⇒ ToExpr (Sized a) Source # | |
| ToExpr a ⇒ ToExpr (StrictMaybe a) Source # | |
| ToExpr a ⇒ ToExpr (StrictSeq a) Source # | |
| DSIGNAlgorithm c ⇒ ToExpr (SignedDSIGN c index) Source # | |
Methods toExpr ∷ SignedDSIGN c index → Expr Source # listToExpr ∷ [SignedDSIGN c index] → Expr Source # | |
| ToExpr (Hash c index) Source # | |