Thursday, December 17, 2009

Installing gtk2hs on Snow Leopard

Installed gtk2hs today on Snow leopard. It took a lot of work. Here's my summary:

Follow the Instructions on the HaskellWiki (download gtk2hs, install the GTK+ framework, install pkgconfig)

Add the following variable to you environment.plist file:

PKG_CONFIG_PATH=/Library/Frameworks/Cairo.framework/Resources/dev/lib/pkgconfig:
/Library/Frameworks/GLib.framework/Resources/dev/lib/pkgconfig:
/Library/Frameworks/Gtk.framework/Resources/dev/lib/pkgconfi

In the gtk2hs directory run:

./configure --disable-split-objs --disable-gio
make
sudo make install

Useful Sites
HaskellWiki
Haskell Cafe from Mail Archive.com

Friday, December 11, 2009

My First Haskell word in line finder

I stuck at it, and here is my finished haskell program to find all lines that contain a certain word:
findStrb :: String -> String -> Bool
findStrb key str = if key `isInfixOf` str then True else False
printList :: [String] -> IO ()
printList (x:xs) = do
putStrLn x
printList xs
main :: IO ()
main = do
infile <- readFile "ec2_list"
printList [x | x <- lines infile, findStrb "kernel" x]