Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A ToExpr
class.
Documentation
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"}
ediff' :: (ToExpr a, ToExpr b) => a -> b -> Edit EditExpr Source #
Compare different types.
Note: Use with care as you can end up comparing apples with oranges.
>>>
prettyEditExpr $ ediff' ["foo", "bar"] [Just "foo", Nothing]
[-"foo", +Just "foo", -"bar", +Nothing]
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
listToExpr :: [a] -> Expr Source #
Instances
ToExpr Key Source # | |
ToExpr Value Source # | |
ToExpr Void Source # | |
ToExpr Int16 Source # | |
ToExpr Int32 Source # | |
ToExpr Int64 Source # | |
ToExpr Int8 Source # | |
ToExpr Word16 Source # | |
ToExpr Word32 Source # | |
ToExpr Word64 Source # | |
ToExpr Word8 Source # | |
ToExpr ByteString Source # |
|
Defined in Data.TreeDiff.Class toExpr :: ByteString -> Expr Source # listToExpr :: [ByteString] -> Expr Source # | |
ToExpr ByteString Source # |
|
Defined in Data.TreeDiff.Class toExpr :: ByteString -> Expr Source # listToExpr :: [ByteString] -> Expr Source # | |
ToExpr ShortByteString Source # |
|
Defined in Data.TreeDiff.Class toExpr :: ShortByteString -> Expr Source # listToExpr :: [ShortByteString] -> Expr Source # | |
ToExpr IntSet Source # | |
ToExpr ByteArray Source # | Since: 0.2.2 |
ToExpr Ordering Source # | |
ToExpr Scientific Source # |
|
Defined in Data.TreeDiff.Class toExpr :: Scientific -> Expr Source # listToExpr :: [Scientific] -> Expr Source # | |
ToExpr Text Source # |
|
ToExpr Text Source # |
|
ToExpr Day Source # |
|
ToExpr UTCTime Source # | |
ToExpr Expr Source # | |
ToExpr UUID Source # |
|
ToExpr Integer Source # | |
ToExpr Natural Source # | |
ToExpr () Source # | |
Defined in Data.TreeDiff.Class | |
ToExpr Bool Source # | |
ToExpr Char Source # |
|
ToExpr Double Source # | |
ToExpr Float Source # | |
ToExpr Int Source # | |
ToExpr Word Source # | |
ToExpr a => ToExpr (KeyMap a) Source # | |
ToExpr a => ToExpr (ZipList a) Source # | |
ToExpr a => ToExpr (Identity a) Source # |
|
ToExpr a => ToExpr (First a) Source # | |
ToExpr a => ToExpr (Last a) Source # | |
ToExpr a => ToExpr (First a) Source # | |
ToExpr a => ToExpr (Last a) Source # | |
ToExpr a => ToExpr (Max a) Source # | |
ToExpr a => ToExpr (Min a) Source # | |
ToExpr a => ToExpr (Dual a) Source # | |
ToExpr a => ToExpr (Product a) Source # | |
ToExpr a => ToExpr (Sum a) Source # | |
(ToExpr a, Integral a) => ToExpr (Ratio a) Source # |
|
ToExpr v => ToExpr (IntMap v) Source # | |
ToExpr v => ToExpr (Seq v) Source # | |
ToExpr k => ToExpr (Set k) Source # | |
ToExpr a => ToExpr (Tree a) Source # | |
ToExpr a => ToExpr (Hashed a) Source # | |
ToExpr a => ToExpr (Maybe a) Source # | |
ToExpr k => ToExpr (HashSet k) Source # | |
ToExpr a => ToExpr (Vector a) Source # | |
(ToExpr a, Prim a) => ToExpr (Vector a) Source # | |
(ToExpr a, Storable a) => ToExpr (Vector a) Source # | |
(ToExpr a, Unbox a) => ToExpr (Vector a) Source # | |
ToExpr a => ToExpr (NonEmpty a) Source # | |
ToExpr a => ToExpr (Maybe a) Source # | |
ToExpr a => ToExpr [a] Source # | |
Defined in Data.TreeDiff.Class | |
(ToExpr a, ToExpr b) => ToExpr (Either a b) Source # | |
HasResolution a => ToExpr (Fixed a) Source # | |
ToExpr (Proxy a) Source # | |
(ToExpr k, ToExpr v) => ToExpr (Map k v) Source # | |
(ToExpr a, ToExpr b) => ToExpr (Either a b) Source # | |
(ToExpr a, ToExpr b) => ToExpr (These a b) Source # | |
(ToExpr a, ToExpr b) => ToExpr (Pair a b) Source # | |
(ToExpr a, ToExpr b) => ToExpr (These a b) Source # | |
(ToExpr k, ToExpr v) => ToExpr (HashMap k v) Source # | |
(ToExpr a, ToExpr b) => ToExpr (a, b) Source # | |
Defined in Data.TreeDiff.Class | |
ToExpr a => ToExpr (Const a b) Source # | |
ToExpr a => ToExpr (Tagged t a) Source # | |
(ToExpr a, ToExpr b, ToExpr c) => ToExpr (a, b, c) Source # | |
Defined in Data.TreeDiff.Class | |
(ToExpr a, ToExpr b, ToExpr c, ToExpr d) => ToExpr (a, b, c, d) Source # | |
Defined in Data.TreeDiff.Class | |
(ToExpr a, ToExpr b, ToExpr c, ToExpr d, ToExpr e) => ToExpr (a, b, c, d, e) Source # | |
Defined in Data.TreeDiff.Class |
defaultExprViaShow :: Show a => a -> Expr Source #
An alternative implementation for literal types. We use show
representation of them.