As I said in my last post, I was sick of Blogger's way of indenting my Haskell code. I was on the verge to move to wordpress.com, which provides seamless support for the excellent syntaxhighlighter. Too bad, syntaxhighlighter doesn't provide Haskell support out-of-the-box.
Hence, I decided to write one myself. Go get it! Then, follow these instructions to get it to work with Blogger.
Here's an example of what it can do:
{-dfhc: by jAS 000807-}
module Import (importOne) where
import IO
import PackedString(PackedString,packString,unpackPS)
import Flags
import OsOnly(fixImportNames,isPrelude)
import Extra
import Syntax(Module,ImpDecl,Type,Decls,Decl,FixId,InfixClass(..),Simple,
Context,Constr)
import Lex(Lex)
import TokenId(TokenId(..),tPrelude,rpsPrelude,extractV)
import ParseCore(Parser(..),ParseBad(..),ParseError(..),ParseGood(..),
ParseResult(..),parseit)
import ParseI
import Lexical(PosToken(..),PosTokenPre(..),LexState(..),lexical)
import State
import Error
import IExtract
import ImportState(ImportState,putModid2IS)
import IntState(dummyIntState)
import PPSyntax(ppModule,ppDecl,ppDecls,ppImpDecls,ppInterface,ppFun,ppClassCodes)
#if !defined(__HASKELL98__)
#define ioError fail
#endif
openImport:: Flags -> PackedString -> IO (String,String,String)
openImport flags mrps =
catch
(do
(fstr,finput) <- readFirst filenames
if sImport flags
then hPutStr stderr
("Importing module "++mstr++" from "++fstr++".\n")
else return ()
return (mstr,fstr,finput))
(\err -> ioError (userError (can'tOpenStr mstr filenames err)))
where
isUnix = sUnix flags
preludes = sPreludes flags
includes = sIncludes flags ++ preludes
mstr = (reverse . unpackPS) mrps
filenames =
fixImportNames isUnix mstr
(if isPrelude mstr then preludes else includes)
readFirst:: [String] -> IO (String,String)
readFirst [] = hPutStr stderr "Fail no filenames, probably no -I or -P" >> exit
readFirst [x] = do
finput <- readFile x
return (x,finput)
Of course, you can help improve it! While waiting for me to setup a page for this (which could take foerever), patches and comments are very welcomed!