Tag: programming

Using travis-ci

For quite some time, I have been meaning to set up travis-ci for some of my github projects. To get the ball rolling, I chose my projects with the simplest build systems and dependencies. As promised, it was very much a painless experience. I added my trivial .travis.yml files specifying Haskell as my language and asking for a few versions of ghc; everything else was automatic. I had to make a few tweaks here and there to update some old test suites that I had not run in a while. That alone…

(Programming) Language Interoperability

My advisor recently pointed me to an article in the ACM Queue about a familiar topic: interoperability between programming languages. My research for my thesis was very much in this area, and I am happy to see others thinking about the topic. I have not been able to find a whole lot of related work. Broadly speaking, I agree with the sentiment of the article and differ on a few minor points. For example, I don't think that mutability is a significant barrier to language interoperability. Cer…

Installing llvm-tools

In my last post I neglected to provide installation instructions. For most systems, it should be fairly straightforward: Ensure that dot, llvm-config, ghc, and cabal are in your PATH. The first is provided by the Haskell Platform. The 2012 releases should work. Additionally, ensure that ~/.cabal/bin is in your PATH, since the binaries will be installed there (and it may need to be in your path during the build process, too). Run the following script: REPOSITORIES="hbgl-experimental…

A Handy LLVM Tool (ViewIRGraph)

I realized that I forgot to mention another repository related to my last post: llvm-tools. As the name suggests, this repository contains some useful tools based on my llvm-analysis library. The most interesting tool for people who aren't me is ViewIRGraph, which makes it easy to visualize several interesting program graphs (anything supported by llvm-analysis). The help output gives a reasonable breakdown: ViewIRGraph - View different graphs for LLVM IR modules in a variety of formats U…

Divide and Conquer with Monad Par

Recently I decided to parallelize part of my set constraint solver ifscs, which I plan to write more about eventually. At one point, the constraint solver has a large set to process where each element is really independent: a prefect situation for simple coarse-grained parallelism. I had a good experience using monad-par at another place in my code, so I decided to try my luck again. After a bit of fooling around, I came up with the following: import Control.DeepSeq import Control.Monad.Par.S…

Blog Published to Github

I just put the code for this blog up on github. This gives me another backup and could serve as an example for how to use Hakyll. One more example of Hakyll 3 never hurt anyone.

GHC and C++

Recently I was getting error messages from GHC while building Haskell programs that complain about unknown symbols referring to C++ standard template library symbols. It turns out that these are weak symbols (since only one definition is required) and telling ghc to pass the extra (forbidden, deprecated, and evil) -fno-weak flag to gcc helps. I guess I am in trouble when this flag is finally removed. After changing this, the compiler complained that it could not find libstdc++.so. A ghc bug de…

C++ Calling Conventions

My advisor presented me with an interesting problem the other day. Calling some simple C++ free functions that took C++ objects by value using Python's ctypes produced strange results. We eventually narrowed the test case down to the following: 1#include <stdio.h> 2 3struct Simple { 4 int x,y,z; 5}; 6 7struct Fancy { 8 int x,y,z; 9 ~Fancy() { 10 printf("Destroying a Fancy\n"); 11 } 12}; 13 14extern "C" { 15 void printSimple(Simple s) { 16 fprintf(stderr, &qu…

Recent Bug Fixes

First, I finally went back and added support for clang in my whole-program-llvm wrapper. Usage is easy: just set LLVM_COMPILER=clang and it should Just Work. In the process of implementing this clang support I ended up feeling pretty bad about some of the old code. I ended up refactoring out quite a bit and it is definitely cleaner now. I'm still not sold on this whole "object-oriented programming" thing, but it worked tolerably for a small chunk of Python code. The resulting object…

Haskell in Emacs

Like many people, I use Emacs to edit my Haskell code. The standard haskell-mode works fine, but I always felt like I could use a bit more help from my editor. I recently ran across scion, which is something like a Haskell IDE library that provides deep information about programs to editors. It also happens to include Emacs integration. A few notable features: In-buffer error and warning highlighting Expression typechecking Completion of LANGUAGE pragmas Go-to-definition of symbols It does …

Whole Program LLVM Bitcode

Sometimes it is useful to be able to analyze an entire program at once, rather than analyzing individual compilation units. LLVM has some infrastructure in this: the llvm-link program (and associated library methods) combines multiple bitcode files into one as a linker might. Unfortunately, getting all of the bitcode to pass to llvm-link in the first place can be challenging in the face of strange and arcane build systems (e.g., autotools, libtool, and other impolite tools). Official Aside The…

Debugging Haskell

This is mostly just a note to myself. Every time I get to the point in a project where I need to debug some Haskell code, I forget some of the more useful methods. I always seem to remember the printf-debugging method: import Debug.Trace debug = flip trace f x = y `debug` (show y) This one just prints out the String returned by show y when y is evaluated. This is useful for some bugs, but rarely for the kind that I seem to inflict upon myself. The profiling infrastructure provides anothe…

Github

Today I finally decided to stop hosting my own git repositories and just move to GitHub. Hosting them on my VPS was never particularly difficult or demanding, but I was never happy with the web interface I had set up (cgit). cgit itself is great and easy enough to use. I had my web server just dispatch CGI requests to it and everything was fine. The only problem was that I didn't put enough effort into making it fit with the rest of my site visually. I was also never quite sure about the st…

Parsing in Python

I recently had to do some simple parsing in Python. Aside: the Python requirement isn't particularly principled (I am actually not a huge fan), but I go where matplotlib is. I don't think that I have seen a more useful plotting library or program yet. Having the full power of a programming language available to munge data into an appropriate form is a major improvement over ad-hoc data manipulation or selection primitives in tools like gnuplot. My only complaint at this point is that showing…

Another New Blog

Why a blog? Due to popular demand, I am trying to move some of my ranting and raving to more static and less visible media. At least here they are persistent beyond server logs. This seems fairly handy, though, and I think that I'll probably record some useful information here (if I ever happen to find any). Didn't we hear this before? It is true. In the not too distant past, I claimed that I would start a blog. I spent some time agonizing over choosing a platform, as you might expect. I ha…