Safe Haskell | None |
---|---|
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 {fooBool = [Just True], fooInt = Right -2 +3, fooString = "fo"}
>>>
prettyEditExpr $ ediff (Foo (Right 42) [Just True, Just False] "old") (Foo (Right 42) [Nothing, Just False, Just True] "new")
Foo {fooBool = [-Just True, +Nothing, Just False, +Just True], fooInt = Right 42, 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
toExpr :: (Generic a, All2 ToExpr (GCode a), GFrom a, GDatatypeInfo a) => a -> Expr Source #
listToExpr :: [a] -> Expr Source #
Instances
ToExpr Bool Source # | |
ToExpr Char Source # |
|
ToExpr Double Source # | |
ToExpr Float Source # | |
ToExpr Int Source # | |
ToExpr Int8 Source # | |
ToExpr Int16 Source # | |
ToExpr Int32 Source # | |
ToExpr Int64 Source # | |
ToExpr Integer Source # | |
ToExpr Natural Source # | |
ToExpr Ordering Source # | |
ToExpr Word Source # | |
ToExpr Word8 Source # | |
ToExpr Word16 Source # | |
ToExpr Word32 Source # | |
ToExpr Word64 Source # | |
ToExpr () Source # | |
Defined in Data.TreeDiff.Class | |
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 Scientific Source # |
|
Defined in Data.TreeDiff.Class toExpr :: Scientific -> Expr Source # listToExpr :: [Scientific] -> Expr Source # | |
ToExpr Text Source # |
|
ToExpr UTCTime Source # | |
ToExpr Value Source # | |
ToExpr Text Source # |
|
ToExpr Void Source # | |
ToExpr ShortByteString Source # |
|
Defined in Data.TreeDiff.Class toExpr :: ShortByteString -> Expr Source # listToExpr :: [ShortByteString] -> Expr Source # | |
ToExpr IntSet Source # | |
ToExpr Day Source # |
|
ToExpr UUID Source # |
|
ToExpr Expr Source # | |
ToExpr a => ToExpr [a] Source # | |
Defined in Data.TreeDiff.Class | |
ToExpr a => ToExpr (Maybe a) Source # | |
(ToExpr a, Integral a) => ToExpr (Ratio a) Source # |
|
HasResolution a => ToExpr (Fixed a) Source # | |
ToExpr a => ToExpr (Min a) Source # | |
ToExpr a => ToExpr (Max a) Source # | |
ToExpr a => ToExpr (First a) Source # | |
ToExpr a => ToExpr (Last a) Source # | |
ToExpr a => ToExpr (Option 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 (Dual a) Source # | |
ToExpr a => ToExpr (Sum a) Source # | |
ToExpr a => ToExpr (Product a) Source # | |
ToExpr a => ToExpr (NonEmpty a) Source # | |
ToExpr v => ToExpr (IntMap v) Source # | |
ToExpr a => ToExpr (Tree a) Source # | |
ToExpr v => ToExpr (Seq v) Source # | |
ToExpr k => ToExpr (Set k) Source # | |
ToExpr a => ToExpr (Hashed a) Source # | |
ToExpr k => ToExpr (HashSet k) Source # | |
(ToExpr a, Unbox a) => ToExpr (Vector a) Source # | |
(ToExpr a, Storable a) => ToExpr (Vector a) Source # | |
(ToExpr a, Prim a) => ToExpr (Vector a) Source # | |
ToExpr a => ToExpr (Vector a) Source # | |
(ToExpr a, ToExpr b) => ToExpr (Either a b) Source # | |
(ToExpr a, ToExpr b) => ToExpr (a, b) Source # | |
Defined in Data.TreeDiff.Class | |
(ToExpr k, ToExpr v) => ToExpr (HashMap k v) Source # | |
(ToExpr k, ToExpr v) => ToExpr (Map k v) Source # | |
ToExpr (Proxy a) Source # | |
(ToExpr a, ToExpr b, ToExpr c) => ToExpr (a, b, c) 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 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.