HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleghc-9.10.3GHC2021

GHC.Iface.Ext.Utils

  • 3 types
  • 55 values
  • Packageghc-9.10.3
  • Exports58
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceUtils.hs
datadata EvidenceInfo a
#
Instances4Functor, Eq, Ord, Outputable
valuemergeAsts :: [HieAST Type] -> [HieAST Type] -> [HieAST Type]
#

Merge two sorted, disjoint lists of ASTs, combining when necessary.

In the absence of position-altering pragmas (ex: # line "file.hs" 3), different nodes in an AST tree should either have disjoint spans (in which case you can say for sure which one comes first) or one span should be completely contained in the other (in which case the contained span corresponds to some child node).

However, since Haskell does have position-altering pragmas it is possible for spans to be overlapping. Here is an example of a source file in which foozball and quuuuuux have overlapping spans:

module Baz where

# line 3 "Baz.hs"
foozball :: Int
foozball = 0

# line 3 "Baz.hs"
bar, quuuuuux :: Int
bar = 1
quuuuuux = 2

In these cases, we just do our best to produce sensible HieAST's. The blame should be laid at the feet of whoever wrote the line pragmas in the first place (usually the C preprocessor...).