Minimum Spanning Tree in Haskell
Created at 2015-12-19T20:21:09.000Z

I'm reading The Algorithm Design Manual. Spontaneously, I implement examples in the book by myself with the language, which is also spontaneously chosen.

I wrote Prim's algorithm to solve Minumum Spanning Tree by Haskell. The code is here.

What I learned

  • Data.Array.Diff: to update a pure array with O(1) time,
  • Data.Lens:
    • %=, .=, use: easy access to states wrapped by Monad
  • Data.Arrow:
    • >>>: intuitive chaining functions
  • Data.Function
    • &: to call functions as if it's object's method.

Combining & and >>> improved readability so much compared to writing only with .. This is an example:

Future Work

  • Use existing graph library in haskell
  • Use Kleisli arrows composition
  • Use mutable collection data for better performance with monadST