2 % (c) The University of Glasgow 2006
3 % (c) The AQUA Project, Glasgow University, 1993-1998
5 \section[TcAnnotations]{Typechecking annotations}
8 module TcAnnotations ( tcAnnotations ) where
20 import {-# SOURCE #-} TcSplice ( runAnnotation )
28 tcAnnotations :: [LAnnDecl Name] -> TcM [Annotation]
29 tcAnnotations = mapM tcAnnotation
31 tcAnnotation :: LAnnDecl Name -> TcM Annotation
33 -- TODO: modify lexer so ANN pragmas are parsed as comments in a stage1 compiler, so developers don't see this error
34 tcAnnotation (L _ (HsAnnotation _ expr)) = pprPanic "Cant do annotations without GHCi" (ppr expr)
36 tcAnnotation ann@(L loc (HsAnnotation provenance expr)) = do
37 -- Work out what the full target of this annotation was
39 let target = annProvenanceToTarget mod provenance
41 -- Run that annotation and construct the full Annotation data structure
42 setSrcSpan loc $ addErrCtxt (annCtxt ann) $ addExprErrCtxt expr $ runAnnotation target expr
44 annProvenanceToTarget :: Module -> AnnProvenance Name -> AnnTarget Name
45 annProvenanceToTarget _ (ValueAnnProvenance name) = NamedTarget name
46 annProvenanceToTarget _ (TypeAnnProvenance name) = NamedTarget name
47 annProvenanceToTarget mod ModuleAnnProvenance = ModuleTarget mod
49 annCtxt :: OutputableBndr id => LAnnDecl id -> SDoc
51 = hang (ptext (sLit "In the annotation:")) 4 (ppr ann)