Abstract
This paper presents a new functional programming model for graph structures called structured graphs. Structured graphs extend conventional algebraic datatypes with explicit definition and manipulation of cycles and/or sharing, and offer a practical and convenient way to program graphs in functional programming languages like Haskell. The representation of sharing and cycles (edges) employs recursive binders and uses an encoding inspired by parametric higher-order abstract syntax. Unlike traditional approaches based on mutable references or node/edge lists, well-formedness of the graph structure is ensured statically and reasoning can be done with standard functional programming techniques. Since the binding structure is generic, we can define many useful generic combinators for manipulating structured graphs. We give applications and show how to reason about structured graphs.
- M. Abbott, T. Altenkirch, C. McBride, and N. Ghani. δ for data: Differentiating data structures. Fundam. Inf., 65:1--28, 2004. Google Scholar
Digital Library
- A. V. Aho, R. Sethi, and J. D. Ullman. Compilers: Principles, Techniques and Tools. Addison-Wesley, 1988. Google Scholar
Digital Library
- R. Atkey. Syntax for free: Representing syntax with binding using parametricity. In TLCA'09, 2009. Google Scholar
Digital Library
- A. Baars, S. Doaitse Swierstra, and M. Viera. Typed transformations of typed grammars: The left corner transform. Electron. Notes Theor. Comput. Sci., 253(7), 2010. Google Scholar
Digital Library
- R. Bird and R. Paterson. Generalised folds for nested datatypes. Formal Aspects of Computing, 11:11--2, 1999.Google Scholar
Digital Library
- R. S. Bird and L. G. L. T. Meertens. Nested datatypes. In MPC '98, 1998. Google Scholar
Digital Library
- J. A. Brzozowski. Derivatives of regular expressions. J. ACM, 11, 1964. Google Scholar
Digital Library
- P. P. Chen. The entity-relationship model - toward a unified view of data. ACM Trans. Database Syst., 1(1):9--36, 1976. Google Scholar
Digital Library
- A. Chlipala. Parametric higher-order abstract syntax for mechanized semantics. In ICFP'08, 2008. Google Scholar
Digital Library
- N. A. Danielsson. Total parser combinators. In ICFP'10, 2010. Google Scholar
Digital Library
- J. Despeyroux, A. Felty, and A. Hirschowitz. Higher-order abstract syntax in Coq. In TLCA'95, 1995. Google Scholar
Digital Library
- D. Devriese and F. Piessens. Explicitly recursive grammar combinators - a better model for shallow parser DSLs. In PADL 2011, 2011. Google Scholar
Digital Library
- M. Erwig. Inductive graphs and functional graph algorithms. J. Funct. Program., 11, 2001. Google Scholar
Digital Library
- L. Fegaras and T. Sheard. Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space). In POPL'96, 1996. Google Scholar
Digital Library
- N. Ghani, M. Hamana, T. Uustalu, and V Vene. Representing cyclic structures as nested datatypes. In TFP'06, 2006.Google Scholar
- J. Gibbons. An initial-algebra approach to directed acyclic graphs. In MPC '95, 1995. Google Scholar
Digital Library
- J. Gibbons. Datatype-generic programming. In Spring School on Datatype-Generic Programming, volume 4719 of Lecture Notes in Computer Science. Springer-Verlag, 2007. Google Scholar
Digital Library
- J. Gibbons and B. C. d. S. Oliveira. The essence of the iterator pattern. J. Funct. Program., 19(3-4), 2009. Google Scholar
Digital Library
- A. Gill. Type-safe observable sharing in Haskell. In Haskell'09, 2009. Google Scholar
Digital Library
- M. Hamana. Initial algebra semantics for cyclic sharing tree structures. Logical Methods in Computer Science, 6(3), 2010.Google Scholar
- F. Honsell, M. Miculan, and I. Scagnetto. An axiomatic approach to metareasoning on nominal algebras in hoas. In ICALP '01, 2001. Google Scholar
Digital Library
- J. Hughes. Lazy memo-functions. In FPCA'85, 1985. Google Scholar
Digital Library
- P. Jansson and J. Jeuring. Polyp - a polytypic programming language extension. In POPL'97, 1997. Google Scholar
Digital Library
- X. Leroy, D. Doligez, A. Frisch, J. Garrigue, D. Rémy, and J. Vouillon. The OCaml system (release 3.12): Documentation and user's manual. Institut National de Recherche en Informatique et en Automatique, 2011.Google Scholar
- C.Martin, J. Gibbons, and I. Bayley. Disciplined, efficient, generalised folds for nested datatypes. Form. Asp. Comput., 16, 2004. Google Scholar
Digital Library
- C. Mcbride and R. Paterson. Applicative programming with effects. J. Funct. Program., 18(1), 2008. Google Scholar
Digital Library
- E. Meijer and G. Hutton. Bananas in space: extending fold and unfold to exponential types. In FPCA'95, 1995. Google Scholar
Digital Library
- M. Might, D. Darais, and D. Spiewak. Parsing with derivatives: a functional pearl. In ICFP '11, 2011. Google Scholar
Digital Library
- R. Milner, M. Tofte, R. Harper, and D. Macqueen. The Definition of Standard ML - Revised. The MIT Press, 1997. Google Scholar
Cross Ref
- B. C. d. S. Oliveira and Andres Löh. Abstract syntax graphs for domain specific languages. Unpublished. Manuscript available at http://ropas.snu.ac.kr/~bruno/papers/ASGDSL.pdf, 2012.Google Scholar
- S. Peyton Jones et al. The Haskell 98 language and libraries: The revised report. Journal of Functional Programming, 13(1):0--255, 2003.Google Scholar
- S. Peyton Jones, D. Vytiniotis, S. Weirich, and M. Shields. Practical type inference for arbitrary-rank types. J. Funct. Program., 17:1--82, 2007. Google Scholar
Digital Library
- S. Peyton Jones, D. Vytiniotis, S. Weirich, and G. Washburn. Simple unification-based type inference for GADTs. In ICFP'06, 2006. Google Scholar
Digital Library
- F. Pfenning and C. Elliot. Higher-order abstract syntax. In PLDI '88, 1988. Google Scholar
Digital Library
- F. Pottier. Lazy least fixed points in ML. Unpublished. Manuscript available at http://gallium.inria.fr/~fpottier/publis/fpottier-fix.pdf, 2009.Google Scholar
- J. C. Reynolds. Types, abstraction and parametric polymorphism. In IFIP Congress, pages 513--523, 1983.Google Scholar
- P. Wadler. Theorems for free! In FPCA '89, 1989. Google Scholar
Digital Library
- P. Wadler. The essence of functional programming. In POPL'92, 1992. Google Scholar
Digital Library
- G. Washburn and S. Weirich. Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism. Journal of Functional Programming, 18:87--140, 2008. Google Scholar
Digital Library
Index Terms
Functional programming with structured graphs
Recommendations
Functional programming with structured graphs
ICFP '12: Proceedings of the 17th ACM SIGPLAN international conference on Functional programmingThis paper presents a new functional programming model for graph structures called structured graphs. Structured graphs extend conventional algebraic datatypes with explicit definition and manipulation of cycles and/or sharing, and offer a practical and ...
Abstract syntax graphs for domain specific languages
PEPM '13: Proceedings of the ACM SIGPLAN 2013 workshop on Partial evaluation and program manipulationThis paper presents a representation for embedded domain specific languages (EDSLs) using abstract syntax graphs (ASGs). The purpose of this representation is to deal with the important problem of defining operations that require observing or preserving ...
Layout-sensitive language extensibility with SugarHaskell
Haskell '12: Proceedings of the 2012 Haskell SymposiumProgrammers need convenient syntax to write elegant and concise programs. Consequently, the Haskell standard provides syntactic sugar for some scenarios (e.g., do notation for monadic code), authors of Haskell compilers provide syntactic sugar for more ...







Comments