I solved it without using Dijkstra's algorithm. I simply used a matrix and updated the minimum distance looking at the four neighbours over and over again, until no updates were made. (I have no idea how to do this in Haskell.) It is a rather dumb algorith and looks not very efficient, but it does not require you to keep a set of unvisted nodes and their smallest tentative distance.