Tag: haskell
I just pushed a new release of haggle to Hackage today. The haggle library implements a number of different representations of graph data structures with different capability and efficiency tradeoffs. It is inspired by both fgl and boost::graph, with the goal of enabling users to choose the right graph representation for their needs, while avoiding the partial functions that are used in fgl.
This release largely adds some instances contributed by users (including some Unbox instances). The one …
This is part two of the presumably unending type errors series. The previous entry involved an amusing type error. This time the error is a bit less amusing:
ghc: panic! (the 'impossible' happened)
(GHC version 8.8.3 for x86_64-unknown-linux):
exprToType
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
pprPanic, called at compiler/coreSyn/CoreSyn.hs:1997:28 in ghc:CoreSyn
Please …
I find that I run into a large number of what I would consider Funny Type Errors while using GHC. This is the first post in what will presumably be a long series of posts on the topic.
Today I was working on trying to improve the performance of a codebase that uses a large number of the type system extensions provided by modern GHC including -XGADTs and -XTypeInType. Seeing strange type errors in this code is expected on a daily basis. However, the code I was working in today was not doing an…
Instead of writing about something productive, I am going to again write about writing. Or at least the infrastructure for writing. First, I decided to switch comments from Disqus to utteranc.es, which is a clever approach to hosting comments for statically-generated sites. For each post, the script creates a GitHub issue and adds each comment to the issue. There are no ads, and it is all around more civilized. Moreover, I appreciate the simplicity of the model. Not that I expect an excess…
I periodically try to use TAGS to navigate round my code in emacs.
When it works, it is very convenient. I have not been using them
lately, partly because generating the tags and keeping them up-to-date
has always been a bit fiddly. In the past, I have tried to get emacs
to automatically regenerate my tags when I save changes to a file. I
have had solutions that work to a greater or lesser extent, but they
are always a bit unsatisfying. Inevitably, I end up having to write
an extra shell scr…
Relative to many other languages, the humble array is underrepresented
in Haskell. That may follow from the difficulty of fitting arrays
into pure code; an entire array to update a single element rarely
makes sense. There are some immutable data structures that
look like arrays,
but are not actually. Mutable arrays (in ST or IO) make more
sense, so I want to write up a few notes about them.
Haskell has two general purpose array libraries:
array and
vector. There are also
some special-purpose…
I just released version 0.2.0.2 of my datalog library to
hackage.
Datalog is a declarative query language similar in spirit to Prolog,
though less expressive. If you have a problem that can be expressed
as
dynamic transitive closure,
Datalog is one way to express your problem. I believe Datalog is
equivalent to SQL with recursive queries. My implementation is
currently fairly basic; I hope to add some more sophistication in the
near future. The primary feature of my implementation is that it…
Recently, I cut a long overdue release of Taffybar, my desktop bar for xmonad (or any window manager, really). The changes are in the changelog. A few highlights are:
Better support for resizing screens
A few new widgets
A completely new pager built on EWMH
Vastly improved power usage
Fixed an annoying bug where time zone changes are not picked up
More recent fixes deal with breakage from the network/network-uri split. Now on a Hackage near you.
I have no specific plans for interesting new …
This blog is built on hakyll, a static
site generator written in Haskell. I have been running on Hakyll 3.x
for quite some time now, but Hakyll 4 was released in January. I kept
telling myself that I would update - I even had the port mostly
working a few months ago. I never got around to finishing it, though.
Until today, that is. There should be no visible changes if I did
everything right, but the code is
much cleaner. It was essentially a rewrite, so it was a good
opportunity to make so…
Right after my hoopl
experience in
February, I meant to write more about
GADTs
and how I have found them to fit into API design. Obviously, I got a bit
distracted. Broadly speaking, before I get into too many details, GADTs are
very powerful, but seem most useful within a module and not exposed to
clients of an API. I will try to detail a few reasons why I came to feel that
way, though obviously I might change my mind one day.
Introduction to GADTs
Before I start, I will introduce the basic i…
During my (ongoing) vim experiment, I found myself missing some of the
amenities of haskell-mode for emacs. Namely great syntax highlighting and
pretty good indentation. vim2hs looked
reasonably nice, but did not handle indentation. It also made scrolling very
slow, perhaps because it just does too many fancy things.
haskellmode-vim had slightly
worse syntax highlighting and was also a bit slow; it also did not have much of
an indentation story.
In response, I wrote hasksyn, which has
both go…
Introduction
I have read about Generalized Algebraic Data Types (GADTs) before, at
least
as implemented in GHC.
The standard type-safe expression evaluator was interesting, but it
never left much of an impression on me. Last week, I ran into them in
real code for the first time while I was playing with
hoopl, a library for
representing control-flow graphs and performing dataflow analysis and
graph rewriting. The use of GADTs in the hoopl code was enlightening
and now I think I have a reasonabl…
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…
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…
Introduction
I have had the code on github for quite some time, so it seems like I
should say something about my LLVM program analysis tools. The
primary repository is
llvm-analysis, which
provides a Haskell interface for analyzing the LLVM IR. The LLVM IR
is a high-level assembly language for a virtual machine with infinite
registers. This is a virtual machine as in a piece of hardware that
does not exist rather than a JVM-style virtual machine that programs
run on. LLVM IR is converted dir…
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…
I finally feel like a real programming languages person. I just used
unification to solve a problem besides type checking a variant of the
lambda calculus. I used the excellent
unification-fd
package; it is a bit light on documentation but the included tests
were enough for me to figure out how to use it. I might post
something more detailed later on.
My problem arose due to the type system rewrite in LLVM 3.0. Prior to
this, types were all uniqued: there was one instance of each
structurall…
Another year, another blog. It seems that I just re-wrote my blog for
the third time.
The Second Rewrite
I never deployed the second rewrite, which was mostly for fun and to
play with yesod. Despite my reservations
about its use of Template Haskell and quasiquotes, I eventually came
around to the whole model suggested by the framework. Type-safe URLs
are very pleasant and the automatic routing of requests to typed
handlers is a huge time and boilerplate saver. After I got the hang
of the fra…
It looks like the
documentation for my taffybar package
is finally being built on Hackage. I am confused because I certainly
didn't change anything relevant in my packaging. It works, though, so
I'm not going to complain.
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…
I've been an XMonad user for a while now. The window manager doesn't
include any status bar-type functionality, instead relying on external
programs. The two most common bars in use seem to be dzen and xmobar.
I didn't like the methods for feeding data into dzen, so I went with
xmobar. It was tolerable. I added a freedesktop.org notification
widget a few months ago and it got a little better. Unfortunately,
the text-only interface bothered me a little bit, and there was no
easy way to get a …
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 …
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…
In lieu of writing about something useful, I'll spend some words on
this silly blog. I seem to spend more time maintaining it than adding
content, so that seems fitting.
Snap version 0.3 was released in
December. Unfortunately, I was too busy at the time to update this
site to use it. Perhaps that was fortunate, though, since version 0.4
was just released a few days ago. In celebration, I took a little
time and updated everything to use 0.4. Version 0.3 introduced the
feature that I had rea…
I am an XMonad user. There, I said it. I don't use any components of
the typical desktop environments except for one: notification-daemon.
Notifications from various applications are useful, even in a minimal
environment.
The Problem
Unfortunately, the normal notification daemon is rather unpleasant to
look at. The popups are intrusive and tend to appear wherever I am
looking. I've tried to configure them to appear in every corner of
both monitors at various times, and it seems that I just l…
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…