BirdPP (empty) → 1.0
raw patch · 5 files changed
+133/−0 lines, 5 filesdep +basedep +haskell98setup-changed
Dependencies added: base, haskell98
Files
- BirdPP.cabal +20/−0
- LICENSE +14/−0
- Main.lhs +60/−0
- README +36/−0
- Setup.lhs +3/−0
+ BirdPP.cabal view
@@ -0,0 +1,20 @@++Name: BirdPP+Version: 1.0+Description: Literate preprocessor that allows intuitive Haddock comments.+License: GPL+License-file: LICENSE+Author: Sean McLaughlin+Maintainer: seanmcl@gmail.com+Build-Type: Simple+Cabal-Version: >=1.6+bug-reports: http://github.com/seanmcl/BirdPP/issues+category: Development+Synopsis: A preprocessor for Bird-style Literate Haskell comments with Haddock markup.+Extra-source-files: LICENSE README +Executable BirdPP+ Main-is: Main.lhs+ Build-Depends: base >= 2 && < 4,+ haskell98++
+ LICENSE view
@@ -0,0 +1,14 @@+Copyright (C) 2009, Sean McLaughlin++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation, either version 3 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>.
+ Main.lhs view
@@ -0,0 +1,60 @@++| This file is for making Haddock cooperate with Bird-style literate+comments. The part for gluing the simple preprocessor into the+ghc pipeline is from "Syzygies"++http://hackage.haskell.org/trac/ghc/attachment/ticket/2776/dedent.lhs++Usage: ghc -pgmL BirdPP ...++This file contains some gratuitous Haddock markup so you can see it+in action. ++> module Main +> ( -- * The preprocessor+> literize +> -- * The glue+> , main )+> where++> import qualified System+> import qualified System.IO as IO+> import qualified System.Environment as Env+> import qualified Monad++| This comment will show up in the Haddock docs.++Replace literate comment lines by "-- " so Haddock can+understand that lines beginning with | are haddock comments.++> literize :: String -> String+> literize ('>' : ' ' : s) = s+> literize s = "-- " ++ s++| Main runs the preprocessor. ++> main :: IO ()+> main = do +> args <- System.getArgs++If we are calling BirdPP in the GHC pipeline, it passes a number+of arguments (see above URL).++> if length args >= 3 then +> do let [orig, src, out] = drop (length args - 3) args+> fi <- IO.openFile src IO.ReadMode+> fo <- IO.openFile out IO.WriteMode+> IO.hPutStrLn fo $ "{-# LINE 1 \"" ++ orig ++ "\" #-}"+> text <- IO.hGetContents fi+> mapM_ (IO.hPutStrLn fo . literize) (lines text)+> IO.hClose fi+> IO.hClose fo++To see the result of the preprocessor (for debugging) you can+just call BirdPP with a file to process.++> else case args of +> [f] -> do text <- IO.readFile f+> mapM_ (putStrLn . literize) (lines text)+> return ()+> _ -> putStrLn "usage: BirdPP file"
+ README view
@@ -0,0 +1,36 @@++Using Haddock markup with Literate Haskell commenting style doesn't +currently work. For instance, to get Haddock markup in an lhs file:++comments+comments++> code++comments++you'd need to write:++> -- | comments+> -- comments++> code++> -- | comments++This clearly defeats the purpose of Literate Haskell. BirdPP is+a preprocessor that works with GHC so you can write what you want:+++| comments+comments++> code++| comments++Compilation of this package will give you an executable called+bunlit. This can be used by ghc using the option -pgmL BirdPP.+E.g.++ghc -pgmL BirdPP --make Main.lhs
+ Setup.lhs view
@@ -0,0 +1,3 @@++> import Distribution.Simple+> main = defaultMain