$ sudo yum install ghc-data-reify-develA list [1,2,3] can be written using Cons, Nil, and In for recursion using:
In (Cons 1 (In (Cons 2 (In (Cons 3 (In Nil))))))An example when using data-reify for the above is given below:
{-# LANGUAGE TypeFamilies #-}
module Main where
import Control.Applicative hiding (Const)
import Data.Reify
import Control.Monad
data List a b = Nil | Cons a b
deriving Show
instance MuRef [a] where
type DeRef [a] = List a
mapDeRef f (x:xs) = Cons x <$> f xs
mapDeRef f [] = pure Nil
main = do
let g1 = [1, 2, 3]
reifyGraph g1 >>= print
Compile it using:
$ ghc --make Test.hs [1 of 1] Compiling Main ( Test.hs, Test.o ) Linking Test ...Run it using:
$ ./Test let [(1,Cons 1 2),(2,Cons 2 3),(3,Cons 3 4),(4,Nil)] in 1[Posted Wednesday April 25 2012]
$ sudo yum install ghc-dotgen-devel graphvizA binary search tree example is shown below:
module Main where
import Text.Dot
box label = node $ [ ("shape","record"),("height",".1"),("label",label) ]
main = putStrLn $ showDot $ do
c0 <- box "<f0> |<f1> G|<f2> "
c1 <- box "<f0> |<f1> E|<f2> "
c2 <- box "<f0> |<f1> B|<f2> "
c3 <- box "<f0> |<f1> F|<f2> "
c4 <- box "<f0> |<f1> R|<f2> "
c5 <- box "<f0> |<f1> H|<f2> "
c6 <- box "<f0> |<f1> Y|<f2> "
c7 <- box "<f0> |<f1> A|<f2> "
c8 <- box "<f0> |<f1> C|<f2> "
c0 .->. c4
c0 .->. c1
c1 .->. c2
c1 .->. c3
c2 .->. c8
c2 .->. c7
c4 .->. c6
c4 .->. c5
return ()
Compile, and run it using:
$ ghc --make Test.hs [1 of 1] Compiling Main ( Test.hs, Test.o ) Linking Test ... $ ./Test > test.dotYou can convert the generated .dot graph file into .png using:
$ dot -Tpng test.dot -o test.pngA screenshot of the generated png:

$ sudo yum install xmonad-gnomeHere is a screenshot of the same (click image):
import XMonad
import XMonad.Config.Gnome
import qualified XMonad.StackSet as W
import XMonad.Util.EZConfig
main = do
xmonad $ gnomeConfig {
workspaces = myWorkspaces
, modMask = mod4Mask
} `additionalKeysP` myKeys
myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
myKeys = [
-- other additional keys
] ++ -- (++) is needed here because the following list comprehension
-- is a list, not a single key binding. Simply adding it to the
-- list of key bindings would result in something like [ b1, b2,
-- [ b3, b4, b5 ] ] resulting in a type error. (Lists must
-- contain items all of the same type.)
[ (otherModMasks ++ "M-" ++ [key], action tag)
| (tag, key) <- zip myWorkspaces "123456789"
, (otherModMasks, action) <- [ ("", windows . W.view) -- was W.greedyView
, ("S-", windows . W.shift)]
]
[Posted Thursday April 5 2012]









$ sudo yum install ghc-netlist-develAn example usage from the sources is given below:
import Language.Netlist.AST
import Language.Netlist.Util
t :: Module
t = Module "foo" (f ins) (f outs) [] ds
where
f xs = [ (x, makeRange Down sz) | (x, sz) <- xs ]
ins = [("clk", 1), ("reset", 1), ("enable", 1), ("x", 16)]
outs = [("z", 16)]
ds :: [Decl]
ds = [ NetDecl "a" (makeRange Down 16) (Just (ExprVar "x"))
, NetDecl "b" (makeRange Down 16) (Just (sizedInteger 16 10))
, MemDecl "c" Nothing (makeRange Down 16) Nothing
, ProcessDecl (Event (ExprVar "clk") PosEdge)
(Just (Event (ExprVar "reset") PosEdge, (Assign (ExprVar "c") (sizedInteger 16 0))))
(If (ExprVar "enable")
(Assign (ExprVar "c") (ExprVar "x"))
Nothing)
]
Load it using ghci version 7.0.2 gives:
$ ghci Test.hs GHCi, version 7.0.2: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Main ( Test.hs, interpreted ) Ok, modules loaded: Main.You can check the value of 'ds' using:
*Main> ds Loading package array-0.3.0.2 ... linking ... done. Loading package bytestring-0.9.1.10 ... linking ... done. Loading package containers-0.4.0.0 ... linking ... done. Loading package binary-0.5.0.2 ... linking ... done. Loading package syb-0.3 ... linking ... done. Loading package netlist-0.3.1 ... linking ... done. [NetDecl "a" (Just (Range (ExprLit Nothing (ExprNum 15)) (ExprLit Nothing (ExprNum 0)))) (Just (ExprVar "x")),NetDecl "b" (Just (Range (ExprLit Nothing (ExprNum 15)) (ExprLit Nothing (ExprNum 0)))) (Just (ExprLit (Just 16) (ExprNum 10))),MemDecl "c" Nothing (Just (Range (ExprLit Nothing (ExprNum 15)) (ExprLit Nothing (ExprNum 0)))) Nothing,ProcessDecl (Event (ExprVar "clk") PosEdge) (Just (Event (ExprVar "reset") PosEdge,Assign (ExprVar "c") (ExprLit (Just 16) (ExprNum 0)))) (If (ExprVar "enable") (Assign (ExprVar "c") (ExprVar "x")) Nothing)] *Main>[Posted Sunday February 19 2012]
$ sudo yum install fritzing arduinoAfter lunch, I attended the talk on "Btrfs - The next Generation Filesystem on Linux" by Neependra Khare. He addressed the different problems in the current filesystems, and how Btrfs tries to solve them. For the last talk of the day I attended Dr. Abhijat Vichare's (from Computational Research Laboratories Pune) session on "Portability concepts in GCC". It was a detailed session on the internals of GCC.


