1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE RankNTypes #-}
3{-# LANGUAGE RecordWildCards #-}
5-- | Diffing GHC ASTs modulo span positions.
12import BasicTypes (SourceText)
15import Ormolu.Imports (sortImports)
16import Ormolu.Parser.Result
18-- | Return 'False' if two annotated ASTs are the same modulo span
21diff :: ParseResult -> ParseResult -> Bool
22diff ParseResult { prCommentStream = cstream0
23 , prParsedSource = ps0
25 ParseResult { prCommentStream = cstream1
26 , prParsedSource = ps1
28 not (matchIgnoringSrcSpans cstream0 cstream1)
29 || not (matchIgnoringSrcSpans ps0 ps1)
31-- | Compare two values for equality disregarding differences in 'SrcSpan's
32-- and the ordering of import lists.
34matchIgnoringSrcSpans :: Data a => a -> a -> Bool
35matchIgnoringSrcSpans = genericQuery
37 genericQuery :: GenericQ (GenericQ Bool)
38 genericQuery x y = (toConstr x == toConstr y)
39 && and (gzipWithQ (genericQuery
42 `extQ` sourceTextEq) x y)
44 srcSpanEq :: SrcSpan -> GenericQ Bool
47 hsModuleEq :: HsModule GhcPs -> GenericQ Bool
49 case cast hs1' :: Maybe (HsModule GhcPs) of
53 hs0 { hsmodImports = sortImports (hsmodImports hs0) }
54 hs1 { hsmodImports = sortImports (hsmodImports hs1) }
56 sourceTextEq :: SourceText -> GenericQ Bool
57 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