Observable Sharing for Functional Circuit Description

  • Koen Claessen
  • David Sands
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1742)


Pure functional programming languages have been proposed as a vehicle to describe, simulate and manipulate circuit specifications. We propose an extension to Haskell to solve a standard problem when manipulating data types representing circuits in a lazy functional language. The problem is that circuits are finite graphs but viewing them as an algebraic (lazy) datatype makes them indistinguishable from potentially infinite regular trees. However, implementations of Haskell do indeed represent cyclic structures by graphs. The problem is that the sharing of nodes that creates such cycles is not observable by any function which traverses such a structure. In this paper we propose an extension to call-by-need languages which makes graph sharing observable. The extension is based on non updatable reference cells and an equality test (sharing detection) on this type. We show that this simple and practical extension has well-behaved semantic properties, which means that many typical source-to-source program transformations, such as might be performed by a compiler, are still valid in the presence of this extension.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [AFM+95]
    Z. Ariola, M. Felleisen, J. Maraist, M. Odersky, and P. Wadler. A call-byneed lambda calculus. In Proc. POPL’95, ACM Press, 1995.Google Scholar
  2. [AS98]
    Z. M. Ariola and A. Sabry. Correctness of monadic state: An imperative call-by-need calculus. In Proc. POPL’98, pages 62–74. ACM Press, 1998.Google Scholar
  3. [BCSS98]
    P. Bjesse, K. Claessen, M. Sheeran, and S. Singh. Lava: Hardware design in Haskell. In ICFP’98. ACM Press, 1998.Google Scholar
  4. [CLM98]
    B. Cook, J. Launchbury, and J. Matthews. Specifying superscalar microprocessors in Hawk. In Formal Techniques for Hardware and Hardware-like Systems. Marstrand, Sweden, 1998.Google Scholar
  5. [FH92]
    Matthias Felleisen and Robert Hieb. The revised report on the syntactic theories of sequential control and state. TCS, 103:235–271, 1992.MATHCrossRefMathSciNetGoogle Scholar
  6. [Hud96]
    Paul Hudak. Building domain-specific embedded languages. ACM Computing Surveys, 28(4):196, December 1996.CrossRefGoogle Scholar
  7. [Lau93]
    J. Launchbury. A natural semantics for lazy evaluation. In Proc. POPL’93, pages 144–154. ACM Press, 1993.Google Scholar
  8. [Mil77]
    R. Milner. Fully abstract models of the typed λcalculus. TCS 4:1–22, 1977.MATHCrossRefMathSciNetGoogle Scholar
  9. [MS99]
    Andrew Moran and David Sands. Improvement in a lazy context: An operational theory for call-by-need. In Proc. POPL’99, ACM Press, 1999.Google Scholar
  10. [MT91]
    I. Mason and C. Talcott. Equivalence in functional languages with effects. Journal of Functional Programming, 1(3):287–327, July 1991.MATHMathSciNetCrossRefGoogle Scholar
  11. [O’D93]
    J. O’Donnell. Generating netlists from executable circuit specifications in a pure functional language. In Functional Programming Glasgow, Springer-Verlag Workshops in Computing, pages 178–194, 1993.Google Scholar
  12. [O’D96]
    J. O’ Donnell. From transistors to computer architecture: Teaching functional circuit specification in Hydra. In Functional Programming Languagues in Education, LNCS vol 1125, pages 221–234. Springer Verlag, 1996.Google Scholar
  13. [Ode94]
    Martin Odersky. A functional theory of local names. In POPL’94, pages 48–59, ACM Press, 1994.Google Scholar
  14. [Pit96]
    A. M. Pitts. Reasoning about local variables with operationally-based logical relations. In 11th Annual Symposium on Logic in Computer Science, pages 152–163. IEEE Computer Society Press, 1996.Google Scholar
  15. [PJPS96]
    S. Peyton Jones, W. Partain, and A. Santos. Let-floating: moving bindings to give faster programs. In Proc. ICFP’96, pages 1–12. ACM Press, 1996.Google Scholar
  16. [PJS98]
    S. Peyton Jones and A. Santos. A transformation-based optimiser for Haskell. Science of Computer Programming, 32(1-3):3–47, 1998.MATHCrossRefGoogle Scholar
  17. [PS93]
    A. M. Pitts and I. D. B. Stark. Observable properties of higher order functions that create local names, or: What’s new? In MFCS’93, LNCS vol 711, pages 122–141, Springer-Verlag, 1993.Google Scholar
  18. [Ses97]
    P. Sestoft. Deriving a lazy abstract machine. Journal of Functional Pro-gramming, 7(3:231–264, May 1997.MATHCrossRefMathSciNetGoogle Scholar
  19. [She85]
    M. Sheeran. Designing regular array architectures using higher order functions. In FPCS’95, LNCS vol 201, Springer Verlag, 1985.Google Scholar
  20. [Wad92]
    P. Wadler. Monads for Functional Programming. In Lecture notes for Marktoberdorf Summer School on Program Design Calculi, NATO ASI Series F: Computer and systems sciences. Springer Verlag, August 1992.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1999

Authors and Affiliations

  • Koen Claessen
    • 1
  • David Sands
  1. 1.Department of Computing SciencesChalmers University of Technology and Göteborg UniversitySweden

Personalised recommendations