diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2012-03-14 17:36:33 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2012-03-14 17:40:36 +0000 |
commit | 6f72869e180d0b0c88386adf1d6e75241596b2b5 (patch) | |
tree | 5c9214efaeaa17c1e428dbdf4eda1b3c30717416 | |
parent | 6d0454a068a34b1aecae76e820a338115efce071 (diff) | |
download | haskell-6f72869e180d0b0c88386adf1d6e75241596b2b5.tar.gz |
Add fixity declarations to Template Haskell (Trac #1541)
-rw-r--r-- | libraries/template-haskell/Language/Haskell/TH/Lib.hs | 9 | ||||
-rw-r--r-- | libraries/template-haskell/Language/Haskell/TH/Ppr.hs | 7 | ||||
-rw-r--r-- | libraries/template-haskell/Language/Haskell/TH/Syntax.hs | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Lib.hs b/libraries/template-haskell/Language/Haskell/TH/Lib.hs index 92f3dd4769..d98da91a30 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Lib.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Lib.hs @@ -354,6 +354,15 @@ forImpD cc s str n ty = do ty' <- ty return $ ForeignD (ImportF cc s str n ty') +infixLD :: Int -> Name -> DecQ +infixLD prec nm = return (InfixD (Fixity prec InfixL) nm) + +infixRD :: Int -> Name -> DecQ +infixRD prec nm = return (InfixD (Fixity prec InfixR) nm) + +infixND :: Int -> Name -> DecQ +infixND prec nm = return (InfixD (Fixity prec InfixN) nm) + pragInlD :: Name -> InlineSpecQ -> DecQ pragInlD n ispec = do diff --git a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs index 53f43ffcd7..5e8ad566ca 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs @@ -235,9 +235,10 @@ ppr_dec _ (ClassD ctxt c xs fds ds) $$ where_clause ds ppr_dec _ (InstanceD ctxt i ds) = text "instance" <+> pprCxt ctxt <+> ppr i $$ where_clause ds -ppr_dec _ (SigD f t) = ppr f <+> text "::" <+> ppr t -ppr_dec _ (ForeignD f) = ppr f -ppr_dec _ (PragmaD p) = ppr p +ppr_dec _ (SigD f t) = ppr f <+> text "::" <+> ppr t +ppr_dec _ (ForeignD f) = ppr f +ppr_dec _ (InfixD fx n) = pprFixity n fx +ppr_dec _ (PragmaD p) = ppr p ppr_dec isTop (FamilyD flav tc tvs k) = ppr flav <+> maybeFamily <+> ppr tc <+> hsep (map ppr tvs) <+> maybeKind where diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index 9c464cfdcc..61bbde8854 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -916,6 +916,8 @@ data Dec | SigD Name Type -- ^ @{ length :: [a] -> Int }@ | ForeignD Foreign + | InfixD Fixity Name -- ^ @{ infix 3 foo }@ + -- | pragmas | PragmaD Pragma -- ^ @{ {-# INLINE [1] foo #-} }@ |