From 8589a69045e96e56f2f4e8cced1bdfc486355623 Mon Sep 17 00:00:00 2001 From: simonpj Date: Thu, 20 Feb 2003 18:27:16 +0000 Subject: [PATCH] [project @ 2003-02-20 18:27:13 by simonpj] Document {-# CORE #-} pragma (thanks to Hal Daume) --- ghc/docs/users_guide/glasgow_exts.sgml | 63 ++++++++++++++++++++++++++++++++ ghc/docs/users_guide/using.sgml | 4 ++ 2 files changed, 67 insertions(+) diff --git a/ghc/docs/users_guide/glasgow_exts.sgml b/ghc/docs/users_guide/glasgow_exts.sgml index 2b8dcdd..ba1d697 100644 --- a/ghc/docs/users_guide/glasgow_exts.sgml +++ b/ghc/docs/users_guide/glasgow_exts.sgml @@ -4396,6 +4396,69 @@ program even if fusion doesn't happen. More rules in PrelList.lhs + + CORE pragma + + CORE pragma + pragma, CORE + core, annotation + + + The external core format supports Note annotations; + the CORE pragma gives a way to specify what these + should be in your Haskell source code. Syntactically, core + annotations are attached to expressions and take a Haskell string + literal as an argument. The following function definition shows an + example: + + +f x = ({-# CORE "foo" #-} show) ({-# CORE "bar" #-} x) + + + Sematically, this is equivalent to: + + +g x = show x + + + + + However, when external for is generated (via + ), there will be Notes attached to the + expressions show and x. + The core function declaration for f is: + + + + f :: %forall a . GHCziShow.ZCTShow a -> + a -> GHCziBase.ZMZN GHCziBase.Char = + \ @ a (zddShow::GHCziShow.ZCTShow a) (eta::a) -> + (%note "hello" + %case zddShow %of (tpl::GHCziShow.ZCTShow a) + {GHCziShow.ZCDShow + (tpl1::GHCziBase.Int -> + a -> + GHCziBase.ZMZN GHCziBase.Char -> GHCziBase.ZMZN GHCziBase.Cha +r) + (tpl2::a -> GHCziBase.ZMZN GHCziBase.Char) + (tpl3::GHCziBase.ZMZN a -> + GHCziBase.ZMZN GHCziBase.Char -> GHCziBase.ZMZN GHCziBase.Cha +r) -> + tpl2}) + (%note "foo" + eta); + + + + Here, we can see that the function show (which + has been expanded out to a case expression over the Show dictionary) + has a %note attached to it, as does the + expression eta (which used to be called + x). + + + + diff --git a/ghc/docs/users_guide/using.sgml b/ghc/docs/users_guide/using.sgml index 54c77d7..adb992d 100644 --- a/ghc/docs/users_guide/using.sgml +++ b/ghc/docs/users_guide/using.sgml @@ -1901,6 +1901,10 @@ statements or clauses. files is different (though similar) to the Core output format generated for debugging purposes (). + The Core format natively supports notes which you can add to + your source code using the CORE pragma (see ). + -- 1.7.10.4