A filestore is a structured collection of data files housed in a conventional hierarchical file system. Many applications use filestores as a poor-man's database, and the correct execution of these applications requires that the collection of files, directories, and symbolic links stored on disk satisfy a variety of precise invariants. Moreover, all of these structures must have acceptable ownership, permission, and timestamp attributes. Unfortunately, current programming languages do not provide support for documenting assumptions about filestores, detecting errors in them, or safely loading from and storing to them.
This paper describes the design, implementation, and semantics of Forest, a new domain-specific language for describing filestores. The language uses a type-based metaphor to specify the expected structure, attributes, and invariants of filestores. Forest generates loading and storing functions that make it easy to connect data on disk to an isomorphic representation in memory that can be manipulated as if it were any other data structure. Forest also generates metadata that describes the degree to which the structures on the disk conform to the specification, making error detection easy. In a nutshell, Forest extends the rigorous discipline of typed programming languages to the untyped world of file systems.
We have implemented Forest as an embedded domain-specific language in Haskell. In addition to generating infrastructure for reading, writing and checking file systems, our implementation generates type class instances that make it easy to build generic tools that operate over arbitrary filestores. We illustrate the utility of this infrastructure by building a file system visualizer, a file access checker, a generic query interface, description-directed variants of several standard UNIX shell tools and (circularly) a simple Forest description inference engine. Finally, we formalize a core fragment of Forest in a semantics inspired by classical tree logics and prove round-tripping laws showing that the loading and storing functions behave sensibly.
[1]
David Walker,et al.
PADS/ML: a functional data description language
,
2007,
POPL '07.
[2]
David Walker,et al.
The next 700 data description languages
,
2006,
POPL '06.
[3]
Simon L. Peyton Jones,et al.
Template meta-programming for Haskell
,
2002,
Haskell '02.
[4]
S-C. Mu,et al.
An algebraic approach to bidirectional updating
,
2004
.
[5]
S. Buraga,et al.
An XML-based Semantic Description of Distributed File Systems
,
2003
.
[6]
Emden R. Gansner,et al.
An open graph visualization system and its applications to software engineering
,
2000,
Softw. Pract. Exp..
[7]
Daan Leijen,et al.
Parsec: direct style monadic parser combinators for the real world
,
2001
.
[8]
Shin-Cheng Mu,et al.
An Algebraic Approach to Bi-directional Updating
,
2004,
APLAS.
[9]
Geoffrey Mainland.
Why it's nice to be quoted: quasiquoting for haskell
,
2007,
Haskell '07.
[10]
Philippa Gardner,et al.
Context logic and tree update
,
2005,
POPL '05.
[11]
Benjamin C. Pierce,et al.
Combinators for bi-directional tree transformations: a linguistic approach to the view update problem
,
2005,
POPL '05.
[12]
David Walker,et al.
The PADS project: an overview
,
2011,
ICDT '11.
[13]
Kazutaka Matsuda,et al.
Bidirectionalizing graph transformations
,
2010,
ICFP '10.
[14]
Michael J. Freedman,et al.
Experiences with CoralCDN: A Five-Year Operational View
,
2010,
NSDI.
[15]
David Mazières,et al.
Democratizing Content Publication with Coral
,
2004,
NSDI.
[16]
Robert Gruber,et al.
PADS: a domain-specific language for processing ad hoc data
,
2005,
PLDI '05.
[17]
Simon L. Peyton Jones,et al.
Scrap your boilerplate: a practical design pattern for generic programming
,
2003,
TLDI '03.
[18]
Russell W. Quong,et al.
ANTLR: A predicated‐LL(k) parser generator
,
1995,
Softw. Pract. Exp..