May 09, 2008

Javascript syntax highlighting for Haskell code

Lots of time passed since my last post. I've been busy but this week I got sick and had some time to hack a bit.

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!

50 comments:

願望 said...

Everyone fastens where there is gain.........................................

英文發音真難 said...

All roads lead to Rome. 堅持自己所選! ....................................................

book said...

不勞而獲的事情,並沒有價值........................................

皓云 said...

very popular to u! ........................................

于芷奇名 said...

It's great!!.............................................

AronSpriggs0223 said...

看看blog調整心情,又要來繼續工作,大家加油........................................

ParisH said...

激情成人聊天室情色成人辣妹胸部辣妹視訊露奶辣妹自拍三點全露內衣秀台灣成人貼圖成人電影院三點全裸免費視訊辣妹av圖裸體自拍色情聊天美女視訊g點色情訊息淫女火辣av辣妹圖片免費視訊聊天室情色天空調情上床圖片裸體自拍走光照片走光視訊情色成人18成人區火辣美女成人vcd成人影片下載本土av性愛情慾淫妹美女聊天性愛聊天室女生自慰影片免費看a圖淫婦巨乳辣妹視訊成人女生自慰方法免費情色限制級a片穿幫情色下載情色網站

銘雅婷木 said...

希望能常常看到你的更新 ........................................

許柏信 said...

It's great!!..........................................

裕以 said...

向小善致敬,它使人生旅程較為平順。........................................

雅伯 said...

卡通成人影片 免費視訊金瓶梅 中年聊天室 aio交友愛情館影片免費85 歐美交友 自拍女優 性感成人內衣表演秀 女同影片 援交偷拍實錄 激情免費視訊聊天室 女生愛愛影片 情趣按摩貼圖 18性愛 夢幻少女寫真館 線上成人影城 免費a片貼 杜雷斯 色情影片 一夜情 383成人網 完美女人視訊 玩美女人視訊 線上美女 辣妹裸體 人妻的秘密 人妻熟女館 情色視訊 空姐 a圖a片交流區 美女寫真貼圖區 85cc線上 微風視訊成人 嘟嘟聊天室 sp7777.com 絲襪貼圖 熟女援交留言板 成人情色網 Live173 免費ava片線上看 洪爺影城色情網線上看 大奶美女做愛影片 做愛sex 免費下載av片 成人巨乳圖片 成人 後宮電影a下載 限制級成人網 channel0204 高中性愛影片 模特兒走光露點寫真

韋于倫成 said...

問聲好~~ 祝福您的blog愈來愈熱鬧! ........................................

紫倫妍勳 said...

一個人最大的敵人常是自己。 ............................................................

佩GailBohanan1蓉 said...

Make yourself necessary to someone.............................................................

renew said...

找一個懂妳的人也期許自己做一個人懂別人的人..................................................

俊偉 said...

You are flattering me..............................................................

銘木 said...

very nice blog~~......................................................................

王邦鈺 said...

河水永遠是相同的,可是每一剎那又都是新的。......................................................................

亦妮亦妮 said...

良言一句三冬暖,惡語傷人六月寒。.................................................................

貴寶 said...

人生是故事的創造與遺忘。............................................................

sf信dg豪d王d佳d玲gdw謝 said...

成功多屬於那些很快做出決定,卻又不輕易變更的人。而失敗也經常屬於那些很難做出決定,卻又經常變更的人.................................................................

賢林賢林 said...

每次看完你的文章,總是回味許久,要經常發表喔。..................................................................

于倫 said...

留言支持你~希望能看到更好的作品 ..................................................................

yol22andarodgersyolandarodge33rs said...

人生是一連串的課程,必須活過才能明白。......................................................

萬宇萬宇 said...

部落格很棒唷~ 支持你歐^^..................................................................

張雅筑張雅筑 said...

真有內容的部落格~推推!............................................................

家榮家榮 said...

獲益不少,謝謝分享!............................................................

淑娟淑娟淑娟 said...

好的blog就是要回應!............................................................

lowe施cole鈺man駿 said...

Judge not of men and things at first sight................................................

劉智陳建霞堯 said...

所有的資產,在不被諒解時,都成了負債..................................................................

凱v胡倫 said...

我們能互相給予的最佳禮物是「真心的關懷」。.................................................

孟湖聿軒 said...

It is easier to get than to keep it.......................................................................

健林林豪 said...

thank you for your reminder.................................................................

邱思吳佳順翰 said...

生存乃是不斷地在內心與靈魂交戰;寫作是坐著審判自己。............................................................

凱v胡倫 said...

感謝您的分享!我也學到很多!..................................................................

冠陳儒 said...

你的部落格感覺很棒,nice job!............................................................

翊翊翊翊張瑜翊翊翊 said...

從人生中拿走友誼,猶如從生活中移走陽光......................................................................

文滢 said...

上班好累哦,看看部落格轉換心情~~~先謝謝啦!!............................................................

homeworkpando said...

it is too good from other post really appreciate all recmond all readers comments on post

eco 372 final exam


http://eco372finalexam.weebly.com/

0524

Haritha said...

Really an awesome post. I wondered by reading this blog post. Thanks a lot for posting this unique post which you have shared with us. Keep on posting like this exclusive post with us.

Dotnet Training in Chennai

karthika revathi said...


wow great,nowadays this type of blog id more important and informative technology,it was more impressive to read ,which helps to design more in effective ways



Salesforce Training in Chennai

Dhiya L said...

Here i had read the content you had posted. It is much interesting so please keep update like this.

Java Training in Chennai

Abiya Carol said...

It is really very excellent,I find all articles was amazing.Awesome way to get exert tips from everyone,not only i like that post all peoples like that post.Because of all given information was wonderful and it's very helpful for me.

ccna training in chennai thiruvanmiyur

Vignesh PV said...

Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..
PHP Training in Chennai

Abiya Carol said...

I just see the post i am so happy to the communication science post of information's.So I have really enjoyed and reading your blogs for these posts.Any way I’ll be replay for your great thinks and I hope you post again soon.

AWS Training in Chennai

Shalini said...

This blog is having the general information. Got a creative work and this is very different one.We have to develop our creativity mind.This blog helps for this. Thank you for this blog. This is very interesting and useful.

Digital Marketing Company in India

john stany said...


I am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.

Android App Development Company

john stany said...

Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.i am expecting more updated posts from your hands.
iOS App Development Company
iOS App Development Company

louis philip said...

Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
Fitness SMS
Fitness Text
Salon SMS
Salon Text
Investor Relation SMS
Investor Relation Text
Mobile Marketing Services
mobile marketing companies
Sms API

Sharon Sandy said...

great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
web design Company
web development Company
web design Company in chennai
web development Company in chennai
web design Company in India
web development Company in India