One of the pleasant new features in GHC 6.10 is the long-awaited addition of view patterns. This feature is usually advertised as making it possible to pattern match against the values of an abstract type. An essential aspect of modular software design is that we don't want to expose the implementation of complex code. Someone will surely come along and start making decisions based on bits of our code that they can see, thus limiting our future room to manoeuvre. This is all amply explained on the view pattern wiki page and in the GHC User's Guide. how do they diff from f# active pats
This article is part three in a series on introductory Haskell programming. In the first article, we wrote a small program to recursively scan file-system directories and print their contents as ASCII-art trees. In the second article, we refactored the program to make its logic more reusable by separating the directory-scanning logic from the tree-printing logic. In this article, we will address a shortcoming of the refactored version: It must scan directory hierarchies completely before printing their trees, i.e., it must scan and then print, when doing both simultaneously is both more efficient and more user friendly. Recall from the previous article that our directory-printing program is factored into three pieces of logic: