Several TH/quasiquote changes
[ghc-hetmet.git] / compiler / hsSyn / HsTypes.lhs
index d3f5ce8..4417751 100644 (file)
@@ -12,6 +12,7 @@ module HsTypes (
        HsExplicitForAll(..),
        HsContext, LHsContext,
        HsPred(..), LHsPred,
+       HsQuasiQuote(..),
 
        LBangType, BangType, HsBang(..), 
         getBangType, getBangStrictness, 
@@ -33,6 +34,7 @@ module HsTypes (
 import {-# SOURCE #-} HsExpr ( HsSplice, pprSplice )
 
 import Type
+import Coercion
 import HsDoc
 import BasicTypes
 import SrcLoc
@@ -60,6 +62,28 @@ placeHolderType  = panic "Evaluated the place holder for a PostTcType"
 
 %************************************************************************
 %*                                                                     *
+       Quasi quotes; used in types and elsewhere
+%*                                                                     *
+%************************************************************************
+
+\begin{code}
+data HsQuasiQuote id = HsQuasiQuote 
+                          id           -- The quasi-quoter
+                          SrcSpan      -- The span of the enclosed string
+                          FastString   -- The enclosed string
+
+instance OutputableBndr id => Outputable (HsQuasiQuote id) where
+    ppr = ppr_qq
+
+ppr_qq :: OutputableBndr id => HsQuasiQuote id -> SDoc
+ppr_qq (HsQuasiQuote quoter _ quote) =
+    char '[' <> ppr quoter <> ptext (sLit "|") <>
+    ppr quote <> ptext (sLit "|]")
+\end{code}
+
+
+%************************************************************************
+%*                                                                     *
 \subsection{Bang annotations}
 %*                                                                     *
 %************************************************************************
@@ -156,9 +180,13 @@ data HsType name
                        Kind            -- A type with a kind signature
 
   | HsSpliceTy         (HsSplice name)
+  | HsQuasiQuoteTy     (HsQuasiQuote name)
 
   | HsDocTy             (LHsType name) LHsDocString -- A documented type
 
+  | HsSpliceTyOut       Kind           -- Used just like KindedTyVar, just between 
+                                       --   kcHsType and dsHsType
+
   | HsBangTy   HsBang (LHsType name)   -- Bang-style type annotations 
   | HsRecTy [ConDeclField name]                -- Only in data type declarations
 
@@ -369,17 +397,19 @@ ppr_mono_ty ctxt_prec (HsForAllTy exp tvs ctxt ty)
   = maybeParen ctxt_prec pREC_FUN $
     sep [pprHsForAll exp tvs ctxt, ppr_mono_lty pREC_TOP ty]
 
-ppr_mono_ty _         (HsBangTy b ty)     = ppr b <> ppr ty
-ppr_mono_ty _         (HsRecTy flds)      = pprConDeclFields flds
-ppr_mono_ty _         (HsTyVar name)      = ppr name
-ppr_mono_ty ctxt_prec (HsFunTy ty1 ty2)   = ppr_fun_ty ctxt_prec ty1 ty2
-ppr_mono_ty _         (HsTupleTy con tys) = tupleParens con (interpp'SP tys)
-ppr_mono_ty _         (HsKindSig ty kind) = parens (ppr_mono_lty pREC_TOP ty <+> dcolon <+> pprKind kind)
-ppr_mono_ty _         (HsListTy ty)      = brackets (ppr_mono_lty pREC_TOP ty)
-ppr_mono_ty _         (HsPArrTy ty)      = pabrackets (ppr_mono_lty pREC_TOP ty)
-ppr_mono_ty _         (HsPredTy pred)     = ppr pred
-ppr_mono_ty _         (HsNumTy n)         = integer n  -- generics only
-ppr_mono_ty _         (HsSpliceTy s)      = pprSplice s
+ppr_mono_ty _    (HsBangTy b ty)     = ppr b <> ppr ty
+ppr_mono_ty _    (HsQuasiQuoteTy qq) = ppr qq
+ppr_mono_ty _    (HsRecTy flds)      = pprConDeclFields flds
+ppr_mono_ty _    (HsTyVar name)      = ppr name
+ppr_mono_ty prec (HsFunTy ty1 ty2)   = ppr_fun_ty prec ty1 ty2
+ppr_mono_ty _    (HsTupleTy con tys) = tupleParens con (interpp'SP tys)
+ppr_mono_ty _    (HsKindSig ty kind) = parens (ppr_mono_lty pREC_TOP ty <+> dcolon <+> pprKind kind)
+ppr_mono_ty _    (HsListTy ty)      = brackets (ppr_mono_lty pREC_TOP ty)
+ppr_mono_ty _    (HsPArrTy ty)      = pabrackets (ppr_mono_lty pREC_TOP ty)
+ppr_mono_ty _    (HsPredTy pred)     = ppr pred
+ppr_mono_ty _    (HsNumTy n)         = integer n  -- generics only
+ppr_mono_ty _    (HsSpliceTy s)      = pprSplice s
+ppr_mono_ty _    (HsSpliceTyOut k)   = text "<splicety>" <> dcolon <> ppr k
 
 ppr_mono_ty ctxt_prec (HsAppTy fun_ty arg_ty)
   = maybeParen ctxt_prec pREC_CON $