I recently wanted to get the Haskell SDK bindings running on windows. It was a bit trickier than I thought it would be — mostly due to a terrible macro SDL used to redefine the
main() function. I used the SDL 1.2 bindings as they’re a little more mature than the SDL 2 bindings, which are pretty much brand new. Here is how I got things working:
1. Install the Haskell Platform
Download and run the installer from the Haskell website.
2. Get the msys Base Environment
mingw-get-setup.exe from the MinGW website and run it. You should only have to select the msys-base meta-package (which will install several other packages). Then from the menu, select “Installation” -> “Apply Changes” and press the “Apply” button to download and install. Once the changes are applied, you can close the installer. Read more on Haskell SDL Bindings on Windows…
Haskell is my language of choice, and one of the features that I miss the most when working in a different language is algebraic data types. I get particularly frustrated about the lack of algebraic data types (and the associated destructuring) because they are so simple. You don’t need any fancy runtime features to make them work. It would even be feasible to make them work in C, for goodness sake.
If you are unfamiliar with algebraic data types, you should check out Rust’s enum data type. Rusts’ enum’s are algebraic data types, and I’ve found them to be the gentlest introduction to their usefulness. The Algebraic data type wikipedia entry is also decent and a bit more thorough. Read more on Simple Algebraic Data Types for Ruby…
In one of my previous posts, I described an implementation of miniKanren in Haskell. I have since been improving the implementation.
I am currently working on the third iteration of my logic library. The first one was described by my previous post. The second is in a GitHub repository. I have yet to settle on a design that I really like, but I thought I’d post something about what I’ve been working on.
The key improvements in the second iteration were the ability to easily add custom data types and the addition of a
match function. The custom data type addition was pretty straightforward. Read more on Towards a Haskell Logic Library…
When I recommend learning Haskell to the uninitiated, I often get asked: “Why Haskell?” “Is it a practical language?” and “Is it something I can actually use?” My answer is definitely yes.
Haskell isn’t my primary language at work (I mostly write C code for embedded systems), I’ve still found it incredibly useful. And even if I never used Haskell at work, I would still consider learning it as time well spent. So, why Haskell?
1. Haskell Plays Well with C
It turns out Haskell is a very powerful tool for helping you write C. Haskell has let me do things I would normally not even consider to be, umm, practical.
Read more on Why Haskell Is Worth Learning…
I like to use Haskell to make little utilities for work. This can range from tools to analyze C code to code generation. When creating these utilities, the most tedious part for me is almost always the creation of some sort of command line interface to my code. Argument parsing is a pain in almost every language, and for some reason, it's always felt worse to me in Haskell.
Well, recently I discovered the CmdArgs package by Neil Mitchell. This package takes nearly all of the pain out of creating command line interfaces around Haskell applications. It takes about as much effort as Ruby's Thor library does to create something internally useful to your program and pleasing to the user.
Read more on Using Haskell’s CmdArgs Package...
This year at Strange Loop I was totally blown away by the miniKanren talk by Daniel Friedman and William Byrd. I highly recommend watching the presentation. It is simultaneously entertaining and mind blowing.
Friedman and Byrd used an extended version of miniKanren, a logic programming language (a la prolog) embedded in scheme, to do several remarkable things:
- Generate programs that evaluate to a given value,
- generate programs that satisfy a given type,
- and (most awesomely) generate Quines! — and Twines!!
This was something that I clearly did not know enough about yet. Usually when I want to really learn and understand something in CS, I try to implement it. So I grabbed a copy of The Reasoned Schemer and did just that!
My weapon of choice is Haskell, so here you go, a miniKanren monad transformer in Haskell: miniKanrenT.
Read more on miniKanren in Haskell…
A simple example of using the 'indents' library to implement indentation parsing with Haskell's Parsec library.
The tools for compiler construction have gotten so good that building a JIT or native code compiler for a custom language can be written in just a few hours. I’ve implemented an example compiler in about 220 lines of Haskell. It has a fair amount of commentary so it shouldn’t be too hard to follow.
Read more on How to Write a Compiler in an Afternoon…