@@ -1,3 +1,6 @@
1+{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE RankNTypes #-}
1-- | Diffing GHC ASTs modulo span positions.
4-- | Diffing GHC ASTs modulo span positions.
3module Ormolu.Diff
6module Ormolu.Diff
@@ -5,6 +8,7 @@ module Ormolu.Diff
9import Language.Haskell.GHC.ExactPrint.Types
13import Language.Haskell.GHC.ExactPrint.Types
@@ -15,4 +19,17 @@ diff
15 :: (Anns, ParsedSource) -- ^ First annotated AST
19 :: (Anns, ParsedSource) -- ^ First annotated AST
16 -> (Anns, ParsedSource) -- ^ Second annotated AST
20 -> (Anns, ParsedSource) -- ^ Second annotated AST
18−diff _ _ = False -- TODO
22+diff (_, ps0) (_, ps1) =
23+ not (matchParsedSources ps0 ps1)
25+-- | Compare two 'ParsedSource' values disregarding differences in
28+matchParsedSources :: ParsedSource -> ParsedSource -> Bool
29+matchParsedSources x0 y0 = geq' x0 y0
31+ geq' :: GenericQ (GenericQ Bool)
32+ geq' x y = (toConstr x == toConstr y)
33+ && and (gzipWithQ (geq' `extQ` srcSpanEq) x y)
34+ srcSpanEq :: SrcSpan -> GenericQ Bool