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 more...

5 Comments

Working with Template Haskell in GHCi

14/12/2010

I’ve just started trying to learn and debug Template Haskell and found it a bit rough trying to explore TH interactively, but a couple of things have helped.

First and most obvious, we can use runQ to see the abstract TH syntax which a quasi-quoted expression expands to:

Prelude> :set -XTemplateHaskell
Prelude> :m + Language.Haskell.TH
Prelude Language.Haskell.TH> runQ [| \a -> a+1 |]
LamE [VarP a_1] (InfixE (Just (VarE a_1)) (VarE GHC.Num.+) (Just (LitE (IntegerL 1))))


» read more…

No Comments