New version of directory-tree on hackage

13/02/2011

In response to a request and my own review I’ve modified my directory-tree package as follows:

0.10.0

  • Eq and Ord instances now compare on free “contents” type variable
  • we provide `equalShape` function for comparison of shape and filenames
    of arbitrary trees (ignoring free “contents” variable)
  • provide a comparingShape used in sortDirShape
  • provide a `sortDirShape` function that sorts a tree, taking into
    account the free file “contents” data

Now that equality and comparison functions that ignore the contents of Files are out of the Eq and Ord instances, we can make those types of comparisons on DirTrees of different types.

You can pick it up with a

$ cabal install directory-tree

No Comments

Do Applicative Functors generalize the S & K Combinators?

2/01/2011

If the title hasn't scared you off yet, here's the story: I was hacking on someone else's code on the plane and trying to wrap my head around some Applicative class code; in particular the code in question used the Applicative instance for ((->) a) i.e. functions. This turned my brain to cream-of-wheat and I had to take a break.

If you aren't familiar with Applicative Functors, they are somewhere in between the familiar and simple Functor class and the Monad class; an abstraction for function application with a context. Check out here for more.
Read the rest of this article »

5 Comments

New version of ‘thrist’ package released

13/11/2010

I’ve been collaborating with Gabor Greif on a new version of his ‘thrist’ module, which was just released last night! I approached Gabor with some new ideas that came to me as I was writing a module that uses Thrists heavily, and he invited me to co-author this version. (See below for a brief explanation of Thrists).

I noticed that in the previous version, the function foldThrist was essentially a foldr with a type signature that was overly restrictive.

For instance, one could not define an identity function on Thrists in terms of the foldThrist function, the way one can with regular lists, e.g.:

foldr (:) [] [1..4] == [1,2,3,4]

Other additions followed as I tried to define the Thrist equivalent of many useful list functions. For example I wanted to define a foldl-like function that we could use to reverse a Thrist.

Check out the release announcement on Gabor’s blog, along with his draft paper on Thrists.
Read the rest of this article »

No Comments