skip to main content
research-article

Functional programming with structured graphs

Published:09 September 2012Publication History
Skip Abstract Section

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.

References

  1. M. Abbott, T. Altenkirch, C. McBride, and N. Ghani. δ for data: Differentiating data structures. Fundam. Inf., 65:1--28, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. A. V. Aho, R. Sethi, and J. D. Ullman. Compilers: Principles, Techniques and Tools. Addison-Wesley, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. R. Atkey. Syntax for free: Representing syntax with binding using parametricity. In TLCA'09, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. R. Bird and R. Paterson. Generalised folds for nested datatypes. Formal Aspects of Computing, 11:11--2, 1999.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. R. S. Bird and L. G. L. T. Meertens. Nested datatypes. In MPC '98, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. J. A. Brzozowski. Derivatives of regular expressions. J. ACM, 11, 1964. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. P. P. Chen. The entity-relationship model - toward a unified view of data. ACM Trans. Database Syst., 1(1):9--36, 1976. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. A. Chlipala. Parametric higher-order abstract syntax for mechanized semantics. In ICFP'08, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. N. A. Danielsson. Total parser combinators. In ICFP'10, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. J. Despeyroux, A. Felty, and A. Hirschowitz. Higher-order abstract syntax in Coq. In TLCA'95, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. D. Devriese and F. Piessens. Explicitly recursive grammar combinators - a better model for shallow parser DSLs. In PADL 2011, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. M. Erwig. Inductive graphs and functional graph algorithms. J. Funct. Program., 11, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. L. Fegaras and T. Sheard. Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space). In POPL'96, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. N. Ghani, M. Hamana, T. Uustalu, and V Vene. Representing cyclic structures as nested datatypes. In TFP'06, 2006.Google ScholarGoogle Scholar
  16. J. Gibbons. An initial-algebra approach to directed acyclic graphs. In MPC '95, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. J. Gibbons. Datatype-generic programming. In Spring School on Datatype-Generic Programming, volume 4719 of Lecture Notes in Computer Science. Springer-Verlag, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. J. Gibbons and B. C. d. S. Oliveira. The essence of the iterator pattern. J. Funct. Program., 19(3-4), 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. A. Gill. Type-safe observable sharing in Haskell. In Haskell'09, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. Hamana. Initial algebra semantics for cyclic sharing tree structures. Logical Methods in Computer Science, 6(3), 2010.Google ScholarGoogle Scholar
  21. F. Honsell, M. Miculan, and I. Scagnetto. An axiomatic approach to metareasoning on nominal algebras in hoas. In ICALP '01, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. J. Hughes. Lazy memo-functions. In FPCA'85, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. P. Jansson and J. Jeuring. Polyp - a polytypic programming language extension. In POPL'97, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle Scholar
  25. C.Martin, J. Gibbons, and I. Bayley. Disciplined, efficient, generalised folds for nested datatypes. Form. Asp. Comput., 16, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. C. Mcbride and R. Paterson. Applicative programming with effects. J. Funct. Program., 18(1), 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. E. Meijer and G. Hutton. Bananas in space: extending fold and unfold to exponential types. In FPCA'95, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. M. Might, D. Darais, and D. Spiewak. Parsing with derivatives: a functional pearl. In ICFP '11, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. R. Milner, M. Tofte, R. Harper, and D. Macqueen. The Definition of Standard ML - Revised. The MIT Press, 1997. Google ScholarGoogle ScholarCross RefCross Ref
  30. 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 ScholarGoogle Scholar
  31. S. Peyton Jones et al. The Haskell 98 language and libraries: The revised report. Journal of Functional Programming, 13(1):0--255, 2003.Google ScholarGoogle Scholar
  32. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  33. S. Peyton Jones, D. Vytiniotis, S. Weirich, and G. Washburn. Simple unification-based type inference for GADTs. In ICFP'06, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. F. Pfenning and C. Elliot. Higher-order abstract syntax. In PLDI '88, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. F. Pottier. Lazy least fixed points in ML. Unpublished. Manuscript available at http://gallium.inria.fr/~fpottier/publis/fpottier-fix.pdf, 2009.Google ScholarGoogle Scholar
  36. J. C. Reynolds. Types, abstraction and parametric polymorphism. In IFIP Congress, pages 513--523, 1983.Google ScholarGoogle Scholar
  37. P. Wadler. Theorems for free! In FPCA '89, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. P. Wadler. The essence of functional programming. In POPL'92, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Functional programming with structured graphs

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 47, Issue 9
          ICFP '12
          September 2012
          368 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2398856
          Issue’s Table of Contents
          • cover image ACM Conferences
            ICFP '12: Proceedings of the 17th ACM SIGPLAN international conference on Functional programming
            September 2012
            392 pages
            ISBN:9781450310543
            DOI:10.1145/2364527

          Copyright © 2012 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 9 September 2012

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!