1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE RankNTypes #-}
3{-# LANGUAGE RecordWildCards #-}
5-- | Diffing GHC ASTs modulo span positions.
12import BasicTypes (SourceText)
15import Ormolu.CommentStream
16import Ormolu.Imports (sortImports)
18-- | Return 'False' if two annotated ASTs are the same modulo span
22 :: (CommentStream, ParsedSource) -- ^ First comment stream and AST
23 -> (CommentStream, ParsedSource) -- ^ Second comment stream and AST
25diff (cstream0, ps0) (cstream1, ps1) =
26 not (matchIgnoringSrcSpans cstream0 cstream1)
27 || not (matchIgnoringSrcSpans ps0 ps1)
29-- | Compare two values for equality disregarding differences in 'SrcSpan's
30-- and the ordering of import lists.
32matchIgnoringSrcSpans :: Data a => a -> a -> Bool
33matchIgnoringSrcSpans = genericQuery
35 genericQuery :: GenericQ (GenericQ Bool)
36 genericQuery x y = (toConstr x == toConstr y)
37 && and (gzipWithQ (genericQuery
40 `extQ` sourceTextEq) x y)
42 srcSpanEq :: SrcSpan -> GenericQ Bool
45 hsModuleEq :: HsModule GhcPs -> GenericQ Bool
47 case cast hs1' :: Maybe (HsModule GhcPs) of
51 hs0 { hsmodImports = sortImports (hsmodImports hs0) }
52 hs1 { hsmodImports = sortImports (hsmodImports hs1) }
54 sourceTextEq :: SourceText -> GenericQ Bool
55 sourceTextEq _ _ = True
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list