2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 FOSS documentation emacs fedora foss freedom gnome haskell laptop photo ruby travel verilog vhdl vlsi xmonad

[Published in Open Source For You (OSFY) magazine, August 2013 edition.]

Emacs is a popular text editor that can be extended and customized. Haskell is a statically typed, functional programming language. Haskell-mode is a Emacs major mode that provides support to write and use Haskell programs. This article explains interesting features and tips on using Haskell-mode with GNU Emacs.

You can install Haskell-mode using your distribution package manager. For example, on Fedora you can use:

$ sudo yum install emacs-haskell-mode


You can enter Haskell-mode when opening a Haskell source file that has an extension .hs, or it can be started within Emacs using:

M-x haskell-mode

On the modeline, you will now see “(Haskell)”, indicating that the Haskell mode has been activated. You can enter the indent mode using:

M-x haskell-indent-mode

The modeline will now show “(Haskell Ind)”.


To load a Haskell source file into the interpreter, use C-c C-l. It will create a new buffer, load the module in the current buffer and give a prompt to work with. Consider the following Square.hs program:

square :: Int -> int
square x = x * x

Opening a Square.hs file in an Emacs buffer, and running C-c C-l will produce the following in a new buffer:

GHCi, version 7.0.4:  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :load "/home/guest/Square.hs"
[1 of 1] Compiling Main             ( /home/guest/Square.hs, interpreted )
Ok, modules loaded: Main.

If you have multiple buffers opened within Emacs, you can directly switch from the (Haskell) mode buffer to the Haskell interpreter using C-c C-z.


The equal to (=) sign can be inserted, and the function type can be neatly aligned with the C-c C-= key stroke. If you type the following function:

volume :: Int -> Int -> Int
volume x

… and keep the cursor after ‘x’ and type C-c C-=, the equal to sign is inserted, and the code gets neatly aligned:

volume   :: Int -> Int -> Int
volume x = 

In the following code snippet, after ‘y’, if you hit Return followed by C-c C-|, a guard symbol is inserted:

max :: (Ord a) => a -> a -> a
max x y

After inserting the second guard in the above example, the ‘otherwise’ keyword can be inserted and the code is aligned using C-c C-o:

max :: (Ord a) => a -> a -> a
max x y
 | x > y     = x
 | otherwise = 

The ‘where’ clause is produced using C-c C-w. In the following example, pressing return after ‘r’, and using C-c C-w inserts the ‘where’ clause:

circleArea :: Float -> Float
circleArea r = pi * r * r

You can insert the type annotation for a function using C-u C-c C-t. Consider the sphereVolume function:

sphereVolume r = 4 / 3 * pi * r * r * r
    where pi = 3.1412

Placing the cursor on ‘sphereVolume’ and typing C-u C-c C-t produces the following:

sphereVolume :: Fractional a => a -> a
sphereVolume r = 4 / 3 * pi * r * r * r
    where pi = 3.1412


There are a number of shortcut commands that are useful for indentation. Let’s suppose you have the following function with the cursor position indicated by ‘_’:

greeting :: String -> String
greeting x = "Hello" ++ x ++

Hitting TAB will take you through the different possible positions for inserting code. When you press TAB for the first time, the cursor will move under ‘Hello’; if you wish to complete the string concatenation (++), issue the following code:

greeting :: String -> String
greeting x = "Hello" ++ x ++

Hitting TAB again prepends ‘greeting’ and the cursor will be placed under ‘x’ for you to add another test condition, as follows:

greeting :: String -> String
greeting x = "Hello" ++ x ++
greeting _

Hitting TAB again will move the cursor to the first column if you want to add any text:

greeting :: String -> String
greeting x = "Hello" ++ x ++

As you keep hitting TAB again and again, the above sequence will repeat. Comments in Haskell begin with ’- -’.

one -- 1
two -- 2
three -- 3
four -- 4
five -- 5
six -- 6
seven -- 7

After marking the above region, use M-x align-regexp followed by ’–’ for the regexp, and the comments will be aligned:

one    -- 1
two    -- 2
three  -- 3
four   -- 4
five   -- 5
six    -- 6
seven  -- 7

C-c C-. helps align the code neatly. Consider the Area.hs program:

area :: Int -> Int -> Int
area breadth height = breadth * height

After marking the above program, and using C-c C-., the code becomes:

area                :: Int -> Int -> Int
area breadth height = breadth * height


To know the Haskell-mode version, use M-x haskell-version. As an example:

  Using haskell-mode version v2.8.0

C-c C-i on a symbol will prompt for getting information about the symbol. For example, ‘Show info of (default Int):’ lists the following:

data Int = GHC.Types.I# GHC.Prim.Int# 	-- Defined in GHC.Types
instance Bounded Int -- Defined in GHC.Enum
instance Enum Int -- Defined in GHC.Enum
instance Eq Int -- Defined in GHC.Base
instance Integral Int -- Defined in GHC.Real
instance Num Int -- Defined in GHC.Num
instance Ord Int -- Defined in GHC.Base
instance Read Int -- Defined in GHC.Read
instance Real Int -- Defined in GHC.Real
instance Show Int -- Defined in GHC.Show

C-c C-t will obtain the type of the symbol with the prompt ‘Show type of (default pi):’. For example:

pi :: Floating a => a

C-c TAB on a symbol returns its definition at the interpreter prompt, as follows:

*Main> :info sphereVolume
sphereVolume :: Fractional a => a -> a
  	-- Defined at /home/guest/Sphere.hs:1:1-12

To find haddock information for a symbol, you can use C-c C-d. Searching for ‘Float’, for example, opens up file:///usr/share/doc/ghc/html/libraries/ghc-prim- on Fedora.

To use the Hayoo search engine, you can use M-x haskell-hayoo. It will prompt with:

  Hayoo query:

The query responses are shown in a browser. Similarily, the Hoogle engine can be queried using M-x haskell-hoogle. If you searched for ‘show’, it will open the URL with the search results.

Files ending with .lhs are literate Haskell programs. You can use Richard Bird style to separate text and code as follows:

Insert blank line before the code
> quicksort :: Ord a => [a] -> [a]
> quicksort []     = []
> quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)
>    where
>        lesser  = filter (< p) xs
>        greater = filter (>= p) xs

Insert blank line after the code

The modeline will indicate that you are in the ‘(LitHaskell/bird)’ minor mode.

The hasktag package needs to be installed to help generate TAGS file for source files. For example:

$ hasktags Test.hs

It will create both tags and TAGS files. You can use M-. in the Haskell buffer to search for a tag.


HLint is a tool that provides suggestions to improve Haskell programs. C-c C-v helps to run hlint on a buffer. Make sure you have the tool installed on your system before using it. For example, running C-c C-v on the above literate quicksort Haskell program suggests:

-*- mode: compilation; default-directory: "~/" -*-
Compilation started at Thu Jun  6 21:31:54

hlint QuickSort.lhs
QuickSort.lhs:6:22: Warning: Redundant bracket
  (quicksort lesser) ++ [p] ++ (quicksort greater)
Why not:
  quicksort lesser ++ [p] ++ (quicksort greater)

QuickSort.lhs:6:44: Warning: Redundant bracket
  [p] ++ (quicksort greater)
Why not:
  [p] ++ quicksort greater

2 suggestions

Compilation exited abnormally with code 1 at Thu Jun  6 21:31:54

[Published in Electronics For You (EFY) magazine, March 2013 edition.]

This tutorial demonstrates the use of eqntott software with some code examples.

eqntott (short for ‘equation to truth table’) is a software tool that can generate truth tables from Boolean equations, which can be used for programmable logic array (PLA) programming. It was initially written at Berkeley, and ported to work on GNU/Linux. It is released under the new BSD license.

Consider a simple AND example:

NAME = and;
INORDER = a b;

c = a & b;

Here NAME refers to the name of the PLA, and is called ‘and’. INORDER lists the input order of elements, while OUTORDER has the list of outputs in the truth table. Copy this example in a text editor and save it as ‘and.eqn.’

To run the above example, use ‘cd’ command in order to go to the directory where the example is saved. Now run the following command:

$ eqntott and.eqn

You will get the output as:

.i 2
.o 1
.p 1
11  1 

’.i’ in the output refers to the number of inputs defined, which refers to ‘a’ and ‘b’ in the above example. ’.o’ corresponds to the number of output variables, which is ‘c’. ’.p’ is the number of product terms. The truth table generated shows that the output is ‘1’ when bothe inputs are ‘1’.

You can use ’-l’ option with eqntott to output the PLA name, input, and output elements.

$ eqntott -l and.eqn

The output will be:

.i 2
.o 1
.na and
.ilb  a b
.ob  c
.p 1
11  1 

The name of the PLA is mentioned next to ’.na’ in the output. The order of inputs and outputs in the truth table is also listed.

The following expressions are allowed in the equations for eqntott:

Expression Meaning
& Logical AND operation
| Logical OR operation
! Logical NOT operation
ZERO or 0 False or the value zero
ONE or 1 True or the value one
() To enclose any expression
? Don’t care condition
name Any input/output in the expression

The half adder circuit adds two binary digits, and produces a sum and a carry. It can be implemented as follows:

NAME = half_adder;
INORDER = a b;
c = a & b;
s = (!a & b) | (a & !b);

When the above equation is run with eqntott:

$ eqntott -l half_adder.eqn

The output will be:

.i 2
.o 2
.na half_adder
.ilb  a b
.ob  s c
.p 3
01  1 0 
10  1 0 
11  0 1 

The sum is represented by ’s’ and carry with ‘c.’ When either the sum or carry is ‘1’, the sum is ‘1’ and carry is ‘0’. When both the sum and carry are ‘1’, then the sum is ‘0’ and carry is ‘1’.

The output of eqntott can be customized using the ’-.key’ argument. The default option is the string ‘iopte’. A few key code options with their output meaning are given below:

Character Output
e .e
f .f output-number input-number
h Human readable format
i .i number of inputs
l Truth table with PLA name, inputs and outputs
o .o number of outputs
p .p number-of-product-terms
v eqntott version number
S PLA connectivity summary

If the half adder example is run with the following key options:

$ eqntott -.lhptv half_adder.eqn

The output will be:

.na half_adder
.ilb  a b
.ob  s c
2 inputs, 2 outputs, 3 product terms.
s	!a	b
s	a	!b
c	a	b
.p 3
01  1 0 
10  1 0 
11  0 1 
eqntott 9.0

The PLA connectivity summary can be displayed using the ’-.S’ key code option. When used with ‘and.eqn’ example as:

$ eqntott -.S and.eqn

The output will be:

PLA Connectivity Summary
#pterms	input
1	b
1	a
#pterms	output
1	c
#out	#in	product term expression
1	2	a & b

’-s’ option allows you to use an output variable in another expression. Consider, for example:

NAME = s;
INORDER = a b;

c = a | b;
d = !c;

When you run the above example with ’-s’ option as:

$ eqntott -l -s s.eqn

The output will be:

.i 3
.o 2
.na s
.ilb  a b c
.ob  d c
.p 3
00-  1 0 
-1-  0 1 
1--  0 1 

When both the inputs ‘a’ and ‘b’ are zero, then the output ‘c’ is zero and ‘d’ is ‘1’. If either ‘a’ and ‘b’ is ‘1’, ‘c’ is ‘1’ and ‘d’ is ‘0’.

’-f’ option allows an input to also be present in the output, and used as though the value was observed at different times. Consider, for example:

NAME = f;

a = !a;

When you execute the above example as:

$ eqntott -l -f f.eqn

The output will be:

.i 1
.o 1
.na f
.ilb  a
.ob  a
.p 1
.f 1 1
0  1 

The truth table output is ‘1’ only when the input is ‘0’. The ’-s’ and ’-f’ options are mutually exclusive.

eqntott can attempt to minimize the logic terms in the equations. ’-r’ option will try to reduce the minterms in the output. Consider the example:

NAME = reduce;
INORDER = x y;

z = x & y | x;

When you use the above example with ’-l’ option as:

$ eqntott -l reduce.eqn

The output will be:

.i 2
.o 1
.na reduce
.ilb  x y
.ob  z
.p 2
1-  1 
11  1 

Using ’-r’ option, eqntott will try to minimize the truth table output:

$ eqntott -l -r reduce.eqn

The output will be:

.i 2
.o 1
.na reduce
.ilb  x y
.ob  z
.p 1
1-  1 

The output ‘z’ is ‘1’ whenever ‘x’ is ‘1’.

You can define expressions using ‘define’ keyword. The XOR logic takes two binary inputs, and returns ‘1’ only when either input is ‘1’ but not both. It can be expressed as:

#define xor(a,b) (a&!b | !a&b)

NAME = xor;
INORDER = a b;

c = xor (a,b);

On running the example as:

$ eqntott -l xor.eqn

The output will be:

.i 2
.o 1
.na xor
.ilb  a b
.ob  c
.p 2
01  1 
10  1 

As a final example, consider generating an odd parity bit for three inputs. The parity bit is set to ‘1’ when the number of ‘1’s’ in the input is even, so as to make the total number of ‘1’s’ odd. We can define the logic using:

#define xor(a,b) (a&!b | !a&b)

NAME = parity;
INORDER = x y z;

p = !( xor (xor(x,y), z) );

When you run the above example with ’-l’ and ’-s’ option as:

$ eqntott -l -s parity.eqn

The output will be:

.i 3
.o 1
.na parity
.ilb  x y z
.ob  p
.p 4
000  1 
011  1 
101  1 
110  1 

You can refer the manual page of eqntott for more documentation. Sources are available from the eqntott webpage.

I am happy to announce my first self-published book on working with free and open source software projects, titled, “i want 2 do project. tell me wat 2 do.”

Shaks with book

Topics covered in the book:

  1. Mailing List Guidelines
  2. Attention to Detail
  3. Project Communication
  4. Project Guidelines
  5. Development Guidelines
  6. Methodology of Work
  7. Tools
  8. Reading and Writing
  9. Art of Making Presentations
  10. Sustenance

The product details are as follows:

  • Price: ₹ 399
  • Pages: 135 pages
  • Publisher: Self-published (June 2014)
  • Language: English
  • ISBN-13: 978-93-5174-187-9
  • Size: 6 x 9 inches
  • Binding: Paperback (Perfect Binding)
  • Availability: In Stock (Indian edition)

You can order the book at

The home page for the book is at:

If you have any comments or queries, please feel free to write to me at

Steps to install VirtualBox 4.3.10 on Fedora 20. You need to first open a terminal and become root user:

$ su -

Install dkms package:

# yum install dkms

If Virtual Machine Manager is running, stop the same, and uninstall it.

# yum remove virt-manager

Remove the KVM modules if already loaded:

# rmmod kvm_intel

Download and install rpmfusion-free repo from

# yum install rpmfusion-free-release-20.noarch.rpm

Install VirtualBox:

# yum install VirtualBox

Install the required VirtualBox kernel module for your running kernel. For example, on Fedora 20 with kernel 3.11.10-301, you can run:

# yum install kmod-VirtualBox-3.11.10-301.fc20.x86_64

Load the vboxdrv driver:

# modprobe vboxdrv

You can now start VirtualBox and use it. To convert Virt-manager images to VirtualBox, you can use:

$ VBoxManage convertdd ubuntu1204-lts.img ubuntu1204-lts.vdi
Red Hat, Westford
Residence Inn
Boeing Lufthansa

More photos available in my /gallery.

A Fedora workshop was organised at St. Joseph’s College of Engineering, Chennai, Tamil Nadu, India on Friday, June 14, 2013. The participants were students from the Master of Computer Applications (MCA) department.

The forenoon session began with an introduction to Free/Open Source Software (F/OSS) and Fedora. I explained the various project and communication guidelines that students need to follow, and mentioned the various Fedora sub-projects that they can contribute to. System architecture, and compilation concepts were also discussed. The need to use free and open standards was emphasized. Copyright, and licensing were briefly addressed.

MCA lab

After lunch, a programming lab session was held to see how students solve problems. Their code was reviewed, and suggestions for improvement were given. Klavaro was shown to students to learn touch typing. I also gave an overview of GCC using the “Introduction to GCC” presentation. The concept of using revision control systems was illustrated. A demo of Fedora 18 (x86_64) was shown, and the same was installed on the lab desktops.

Thanks to Prof. Parvathavarthini Mam for working with me in organizing this workshop. Thanks also to Prof. Shirley for managing the logistics.

Few photos taken during the trip are available in my /gallery.

A Fedora Activity Day was held at Sri Jayachamarajendra College Of Engineering, Mysore, Karnataka, India on Saturday, April 20, 2013.


The agenda included talks in the morning, and practical sessions in the afternoon. I started the day’s proceedings on best practices to be followed when working with free/open source software projects, giving examples on effective project, and communication guidelines. The various Fedora sub-projects that students can contribute to were mentioned. This was followed by an introductory session on Python by Aravinda V K. The “Python: Introduction for Programmers” presentation was given to the students. Vijaykumar Koppad then gave an overview, and a demo of the Gluster file system.

After lunch, we had a Q&A session with the participants. Questions on working with free/open source software projects, differences between file systems, GNU/Linux distributions, and programming languages were answered. Basic installation and troubleshooting techniques were discussed. I addressed system architecture design concepts, compilation, cross-compilation, and revision control systems, and briefed them on copyright, and licensing. Students had brought their laptops to work on Python scripting, and GlusterFS. I also worked on few bug fixes, package builds for ARM, and package updates:

  • Bug 928059 - perl-Sys-CPU 0.54 tests fail on ARM
  • Bug 926079 - linsmith: Does not support aarch64 in f19 and rawhide
  • Bug 925483 - gputils: Does not support aarch64 in f19 and rawhide
  • Bug 922397 - flterm-debuginfo-1.2-1 is empty
  • Bug 925202 - csmith: Does not support aarch64 in f19 and rawhide
  • Bug 925247 - dgc: Does not support aarch64 in f19 and rawhide
  • Bug 925208 - CUnit: Does not support aarch64 in f19 and rawhide
  • Bug 901632 - ghc-smallcheck-1.0.2 is available
  • Bug 926213 - nesc: Does not support aarch64 in f19 and rawhide
  • Bug 953775 - ghc-data-inttrie-0.1.0 is available

Thanks to Vijay Bellur and Vijaykumar Koppad for working with me in organizing this workshop. Thanks also to the Fedora project for sponsoring my travel and accommodation.

Few photos taken during the trip are available in my /gallery.

Ajanta caves
Daulatabad fort
Ellora caves

More photos available in the respective albums - Ajanta caves, Daulatabad fort, and Ellora caves.

I had organized a Fedora and OpenStack workshop at P.E.S. College of Engineering, Nagsen Vana, Aurangabad, Maharashtra on Saturday, March 2, 2013.

P.E.S. College of Engineering

After a formal inauguration at 1000 IST, I introduced the students to communication guidelines, mailing list etiquette, and project guidelines using the “i-want-2-do-project. tell-me-wat-2-do” presentation. The different Fedora sub-projects to which they can contribute to were mentioned. I showed the various free/open source software tools available for them to learn and use. The career options with free/open source software were also discussed. I had asked them to write down any questions they had on the forenoon session, so I could answer them in the afternoon session. Few of their questions:

  • If I do a project in Java, what are my career options?
  • What is the difference between open source and Microsoft?
  • Is Linux popular only because of security, or are there other reasons too?
  • I am interested in mainframes. How should I learn?
  • I am interested in a career in animation. What free/open source software can I use?
  • What are the steps to become a good software engineer?
  • Can I patent a software product?

Post-lunch, I answered their queries in the Q&A session, to the best of my knowledge. I also gave them an introduction on copyright, trademark and patents, and mentioned that IANAL. I then introduced them to the architecture of OpenStack, explaining the individual components, and their functionality. The OpenStack Lab Guide was provided to them to setup their own OpenStack cloud. Some of them had brought their laptops to try it hands-on. I demonstrated the Horizon web interface after starting the required services.

Fedora Labs

All their computer labs have been migrated to Fedora 17. Thanks to Prof. Nitin Ujgare for working with me in organizing this workshop, and for maintaining the Fedora labs at the Institute. Aurangabad is around 230 km from Pune, and takes around 4 1/2 hours by road. There are frequent bus services between Pune and Aurangabad. You can book bus tickets at Maharashtra State Road Transport Corporation (MSRTC) web site. There are a number of historic places to visit in and around Aurangabad. Few photos taken during the trip are available in my /gallery.

I had presented an introduction to Magit, “Emacs + Magit = Git Magic”, at the Pune Emacs Users’ group meetup on Friday, February 22, 2013. Magit is an Emacs mode that interfaces with Git. Magit doesn’t provide all the interfaces of Git, but the frequently used commands. The user manual was used as a reference. Magit is available in Fedora. You can install it using:

$ sudo yum install emacs-magit

The talk was centered around the notion of writing a poem on Emacs in Emacs, and using magit to revision it. I started an Emacs session, created a directory with Dired mode, and used magit (M-x magit-status) to initialize a git repo. After adding a stanza in the poem, I used the magit commands to stage (s) and commit the same (c, C-c C-c) from the magit-buffer. Another stanza and a README file were then added, and the different untracked, and tracked section visibility options (TAB, S-TAB, {1-4}, M-{1-4}) were illustrated. After adding the third stanza, and committing the same, the short (l l) and long (l L) history formatted outputs were shown. The return (RET) key on a commit in the magit-log history buffer opens a new magit-commit buffer, displaying the changes made in the commit. The sha1 can be copied using the (C-w) shortcut.


The reflogs are visible with the (l h) option from the magit-buffer. The (d) command was used to show the difference between the master and a revision, and (D) for the diff between any two revisions. Annotated tags (t a) and lightweight tags (t t) can be created in magit. Resetting the working tree and discarding the current changes is possible with (X). Stashing (z z) the present changes, applying a stash (a), and killing the stash (k) were demonstrated. An org branch was then created (b n) to write a stanza on org-mode, and then merged (m m) with the master branch. An example of rebasing (R) was also illustrated. The magit-buffer can be refreshed (g) to check the current status of the git repo. Anytime, the magit buffers can be closed with the (q) command. A git command can be invoked directly using (:), and the corresponding output can be viewed with ($), which is shown in a magit-process buffer.

A summary of the various shortcuts are available in the presentation. The poem that I wrote on Emacs, and used in the talk:

Emacs is, an operating system
Which unlike many others, is truly, a gem
Its goodies can be installed, using RPM
Or you can use ELPA, which has already packaged them
You can customize it, to your needs
You can also check EmacsWiki, for more leads
Your changes work, as long as reload succeeds
And helps you with, your daily deeds
People say, it lacks a decent editor
But after using its features, they might want to differ
Using Magit’s shortcuts, you might infer
That it is something, you definitely prefer
Plan your life, with org-mode
You don’t necessarily need, to write code
TODO lists and agenda views, can easily be showed
Reading the documentation, can help you come aboard
Emacs is, a double-edged sword
Its powerful features, can never be ignored
Customization is possible, because of Free Software code
And this is, my simple ode.