1{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE RankNTypes #-}
3{-# LANGUAGE RecordWildCards #-}
5-- | Diffing GHC ASTs modulo span positions.
14import Ormolu.CommentStream
15import Ormolu.Imports (sortImports)
17-- | Return 'False' if two annotated ASTs are the same modulo span
21 :: (CommentStream, ParsedSource) -- ^ First comment stream and AST
22 -> (CommentStream, ParsedSource) -- ^ Second comment stream and AST
24diff (cstream0, ps0) (cstream1, ps1) =
25 not (matchIgnoringSrcSpans cstream0 cstream1)
26 || not (matchIgnoringSrcSpans ps0 ps1)
28-- | Compare two values for equality disregarding differences in 'SrcSpan's
29-- and the ordering of import lists.
31matchIgnoringSrcSpans :: Data a => a -> a -> Bool
32matchIgnoringSrcSpans = genericQuery
34 genericQuery :: GenericQ (GenericQ Bool)
35 genericQuery x y = (toConstr x == toConstr y)
36 && and (gzipWithQ (genericQuery `extQ` srcSpanEq `extQ` hsModuleEq) x y)
38 srcSpanEq :: SrcSpan -> GenericQ Bool
41 hsModuleEq :: HsModule GhcPs -> GenericQ Bool
43 case cast hs1' :: Maybe (HsModule GhcPs) of
47 hs0 { hsmodImports = sortImports (hsmodImports hs0) }
48 hs1 { hsmodImports = sortImports (hsmodImports hs1) }
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