Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- assertExprEqualWithMessage ∷ (ToExpr a, Eq a, HasCallStack) ⇒ String → a → a → Assertion
- 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" []]]
Nothing
Instances
ToExpr Key | |
ToExpr Value | |
ToExpr Void | |
ToExpr Int16 | |
ToExpr Int32 | |
ToExpr Int64 | |
ToExpr Int8 | |
ToExpr Word16 | |
ToExpr Word32 | |
ToExpr Word64 | |
ToExpr Word8 | |
ToExpr ByteString |
|
Defined in Data.TreeDiff.Class toExpr ∷ ByteString → Expr Source # listToExpr ∷ [ByteString] → Expr Source # | |
ToExpr ByteString |
|
Defined in Data.TreeDiff.Class toExpr ∷ ByteString → Expr Source # listToExpr ∷ [ByteString] → Expr Source # | |
ToExpr ShortByteString |
|
Defined in Data.TreeDiff.Class toExpr ∷ ShortByteString → Expr Source # listToExpr ∷ [ShortByteString] → Expr Source # | |
ToExpr Version Source # | |
ToExpr CBORBytes Source # | |
ToExpr HexBytes Source # | |
ToExpr Term Source # | |
ToExpr IntSet | |
ToExpr ByteArray | Since: tree-diff-0.2.2 |
ToExpr Ordering | |
ToExpr IPv4 Source # | |
ToExpr IPv6 Source # | |
ToExpr Scientific |
|
Defined in Data.TreeDiff.Class toExpr ∷ Scientific → Expr Source # listToExpr ∷ [Scientific] → Expr Source # | |
ToExpr Text |
|
ToExpr Text |
|
ToExpr Day |
|
ToExpr UTCTime | |
ToExpr Expr | |
ToExpr UUID |
|
ToExpr Integer | |
ToExpr Natural | |
ToExpr () | |
Defined in Data.TreeDiff.Class | |
ToExpr Bool | |
ToExpr Char |
|
ToExpr Double | |
ToExpr Float | |
ToExpr Int | |
ToExpr Word | |
ToExpr a ⇒ ToExpr (KeyMap a) | |
ToExpr a ⇒ ToExpr (ZipList a) | |
ToExpr a ⇒ ToExpr (Identity a) |
|
ToExpr a ⇒ ToExpr (First a) | |
ToExpr a ⇒ ToExpr (Last a) | |
ToExpr a ⇒ ToExpr (First a) | |
ToExpr a ⇒ ToExpr (Last a) | |
ToExpr a ⇒ ToExpr (Max a) | |
ToExpr a ⇒ ToExpr (Min a) | |
ToExpr a ⇒ ToExpr (Dual a) | |
ToExpr a ⇒ ToExpr (Product a) | |
ToExpr a ⇒ ToExpr (Sum a) | |
(ToExpr a, Integral a) ⇒ ToExpr (Ratio a) |
|
ToExpr a ⇒ ToExpr (Sized a) Source # | |
ToExpr a ⇒ ToExpr (StrictMaybe a) Source # | |
Defined in Test.Cardano.Ledger.Binary.TreeDiff toExpr ∷ StrictMaybe a → Expr Source # listToExpr ∷ [StrictMaybe a] → Expr Source # | |
ToExpr a ⇒ ToExpr (StrictSeq a) Source # | |
ToExpr v ⇒ ToExpr (IntMap v) | |
ToExpr v ⇒ ToExpr (Seq v) | |
ToExpr k ⇒ ToExpr (Set k) | |
ToExpr a ⇒ ToExpr (Tree a) | |
ToExpr a ⇒ ToExpr (Hashed a) | |
ToExpr a ⇒ ToExpr (Maybe a) | |
ToExpr k ⇒ ToExpr (HashSet k) | |
ToExpr a ⇒ ToExpr (Vector a) | |
(ToExpr a, Prim a) ⇒ ToExpr (Vector a) | |
(ToExpr a, Storable a) ⇒ ToExpr (Vector a) | |
(ToExpr a, Unbox a) ⇒ ToExpr (Vector a) | |
ToExpr a ⇒ ToExpr (NonEmpty a) | |
ToExpr a ⇒ ToExpr (Maybe a) | |
ToExpr a ⇒ ToExpr [a] | |
Defined in Data.TreeDiff.Class | |
(ToExpr a, ToExpr b) ⇒ ToExpr (Either a b) | |
HasResolution a ⇒ ToExpr (Fixed a) | |
ToExpr (Proxy a) | |
DSIGNAlgorithm c ⇒ ToExpr (SignedDSIGN c index) Source # | |
Defined in Test.Cardano.Ledger.Binary.TreeDiff toExpr ∷ SignedDSIGN c index → Expr Source # listToExpr ∷ [SignedDSIGN c index] → Expr Source # | |
ToExpr (Hash c index) Source # | |
(ToExpr k, ToExpr v) ⇒ ToExpr (Map k v) | |
(ToExpr a, ToExpr b) ⇒ ToExpr (Either a b) | |
(ToExpr a, ToExpr b) ⇒ ToExpr (These a b) | |
(ToExpr a, ToExpr b) ⇒ ToExpr (Pair a b) | |
(ToExpr a, ToExpr b) ⇒ ToExpr (These a b) | |
(ToExpr k, ToExpr v) ⇒ ToExpr (HashMap k v) | |
(ToExpr a, ToExpr b) ⇒ ToExpr (a, b) | |
Defined in Data.TreeDiff.Class | |
ToExpr a ⇒ ToExpr (Const a b) | |
ToExpr a ⇒ ToExpr (Tagged t a) | |
(ToExpr a, ToExpr b, ToExpr c) ⇒ ToExpr (a, b, c) | |
Defined in Data.TreeDiff.Class | |
(ToExpr a, ToExpr b, ToExpr c, ToExpr d) ⇒ ToExpr (a, b, c, d) | |
Defined in Data.TreeDiff.Class | |
(ToExpr a, ToExpr b, ToExpr c, ToExpr d, ToExpr e) ⇒ ToExpr (a, b, c, d, e) | |
Defined in Data.TreeDiff.Class |
Wraps regular ByteString, but shows and diffs it as hex
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 #
Use this with HSpec, but with Tasty use assertExprEqualWithMessage
below
assertExprEqualWithMessage ∷ (ToExpr a, Eq a, HasCallStack) ⇒ String → a → a → Assertion Source #
Use this with Tasty, but with HSpec use expectExprEqualWithMessage
above
A untyped Haskell-like expression.
Having richer structure than just Tree
allows to have richer diffs.
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.
Pretty | |
|
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 =color
Green
<>
bold
styledDoc =annotate
style "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 Version Source # | |
ToExpr Term Source # | |
ToExpr IPv4 Source # | |
ToExpr IPv6 Source # | |
ToExpr a ⇒ ToExpr (Sized a) Source # | |
ToExpr a ⇒ ToExpr (StrictMaybe a) Source # | |
toExpr ∷ StrictMaybe a → Expr Source # listToExpr ∷ [StrictMaybe a] → Expr Source # | |
ToExpr a ⇒ ToExpr (StrictSeq a) Source # | |
DSIGNAlgorithm c ⇒ ToExpr (SignedDSIGN c index) Source # | |
toExpr ∷ SignedDSIGN c index → Expr Source # listToExpr ∷ [SignedDSIGN c index] → Expr Source # | |
ToExpr (Hash c index) Source # | |