Lingua Franca of Functional Programming (FP)

  • Peter Kourzanov
  • Henk Sips
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7829)

Abstract

Scheme is a minimalist language that brings its ancestor, LISP, on par with modern languages such as *ML and Haskell. Although it has very different tools in its repertoire (e.g., homoiconicity), many of the same techniques applied in other languages are also quite usable in Scheme. Some of them (e.g., pattern-matching, monadic and multi-stage programming, a notation for laziness) tend to be associated with other languages (primarily: Haskell and OCaml), and hence many programmers liking these constructs are drawn away from Scheme.

The concrete reason for this in FP community is the perceived verbosity of Scheme, while others (in particular, from the embedded community) have troubles adopting the more difficult concepts of FP in general. It is clear that there are approaches developed with FP that do help for productivity in hardware and software design. Transfer of this knowledge, however, is made difficult by an intellectual gap between the communities. In this paper we attempt to reconcile these two points of view by showing that (1) Scheme’s minimalistic but flexible approach can bring concrete benefits to the embedded community, and (2) none of these “advanced” features is particularly hard to replicate in a language such as Scheme. If one is willing to leverage Scheme’s hygienic macros, all of these features can be implemented separately as libraries and freely used together. No advanced compiler or interpreter modifications to implement such extensions are required for creating embedded DSLs in it.

To really see what Scheme (and homoiconicity) can bring to the domain of automated program construction, and to apply these ideas in practice to Software-Defined Radio (SDR) stacks, we have re-implemented a multi-staged, monadic FFT generator. In this paper we supplement it with a straightforward implementation of the C code-generation and Graphviz visualization back-ends and argue for a homoiconic, pure and total language to combine the best features of Scheme, Haskell and *ML.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Adams IV, N.I., Bartley, D.H., Brooks, G., Dybvig, R.K., Friedman, D.P., Halstead, R., Hanson, C., Haynes, C.T., Kohlbecker, E., Oxley, D., Pitman, K.M., Rozas, G.J., Steele Jr., G.L., Sussman, G.J., Wand, M., Abelson, H.: Revised5 report on the algorithmic language scheme. SIGPLAN Not. 33(9), 26–76 (1998)CrossRefGoogle Scholar
  2. 2.
    Alexandrescu, A.: Better template error messages. C/C++ Users J. 17(3), 37–47 (1999)Google Scholar
  3. 3.
    Bender, J.: sxml-match.ss. InternetGoogle Scholar
  4. 4.
    Calypto. Catapult c. InternetGoogle Scholar
  5. 5.
    Carette, J., Kiselyov, O.: Multi-stage programming with functors and monads: Eliminating abstraction overhead from generic code. Sci. Comput. Program. 76(5), 349–375 (2011)MathSciNetMATHCrossRefGoogle Scholar
  6. 6.
    Cohen, A., Donadio, S., Garzaran, M.-J., Herrmann, C., Kiselyov, O., Padua, D.: In search of a program generator to implement generic transformations for high-performance computing. Sci. Comput. Program. 62, 25–46 (2006)MathSciNetMATHCrossRefGoogle Scholar
  7. 7.
    Erwig, M.: Active patterns. In: Kluge, W.E. (ed.) IFL 1996. LNCS, vol. 1268, pp. 21–40. Springer, Heidelberg (1997)CrossRefGoogle Scholar
  8. 8.
    Filinski, A.: Representing monads. In: POPL, pp. 446–457 (1994)Google Scholar
  9. 9.
    Foltzer, A.C., Friedman, D.P.: A schemers view of monads. Partial draft (2011)Google Scholar
  10. 10.
    Forte, D.S.: Cynthesizer. InternetGoogle Scholar
  11. 11.
    Friedman, D., Hilsdale, E., Ganz, S., Dybvig, K.: match.ss. InternetGoogle Scholar
  12. 12.
    Gabriel, R.P.: The why of y. SIGPLAN Lisp Pointers 2(2), 15–25 (1988)CrossRefGoogle Scholar
  13. 13.
    Kiselyov, O.: Monadic programming in scheme. Internet (2005)Google Scholar
  14. 14.
    Kiselyov, O., Swadi, K.N., Taha, W.: A methodology for generating verified combinatorial circuits. In: Proceedings of the 4th ACM International Conference on Embedded Software, EMSOFT 2004, pp. 249–258. ACM, New York (2004)Google Scholar
  15. 15.
    Krishnamurthi, S.: Educational pearl: Automata via macros. J. Funct. Program. 16(3), 253–267 (2006)MATHCrossRefGoogle Scholar
  16. 16.
    Lindley, S., Wadler, P., Yallop, J.: Idioms are oblivious, arrows are meticulous, monads are promiscuous. Electr. Notes Theor. Comput. Sci. 229(5), 97–117 (2011)MathSciNetCrossRefGoogle Scholar
  17. 17.
    Meijer, E., Hutton, G.: Bananas in space: Extending fold and unfold to exponential types. In: FPCA, pp. 324–333 (1995)Google Scholar
  18. 18.
    Moggi, E.: Notions of computation and monads. Inf. Comput. 93(1), 55–92 (1991)MathSciNetMATHCrossRefGoogle Scholar
  19. 19.
    Queinnec, C.: Compilation of non-linear, second order patterns on s-expressions. In: Deransart, P., Małuszyński, J. (eds.) PLILP 1990. LNCS, vol. 456, pp. 340–357. Springer, Heidelberg (1990)CrossRefGoogle Scholar
  20. 20.
    Queinnec, C., Geffroy, P.: Partial evaluation applied to symbolic pattern matching with intelligent backtrack. In: WSA, pp. 109–117 (1992)Google Scholar
  21. 21.
    Rompf, T., Odersky, M.: Lightweight modular staging: a pragmatic approach to runtime code generation and compiled dsls. In: Visser, E., Järvi, J. (eds.) GPCE, pp. 127–136. ACM (2010)Google Scholar
  22. 22.
    Serrano, M., Weis, P.: Bigloo: A portable and optimizing compiler for strict functional languages. In: Mycroft, A. (ed.) SAS 1995. LNCS, vol. 983, pp. 366–381. Springer, Heidelberg (1995)CrossRefGoogle Scholar
  23. 23.
    Shinn, A.: match.scm. InternetGoogle Scholar
  24. 24.
    Siskind, J.M.: Flow-directed lightweight closure conversion. Technical Report 99-190R, NEC Research Institute, Inc. (1999)Google Scholar
  25. 25.
    Stroustrup, B.: The c++0x “remove concepts” decision. InternetGoogle Scholar
  26. 26.
    Sutton, A., Stroustrup, B.: Design of concept libraries for c++. In: Sloane, A., Aßmann, U. (eds.) SLE 2011. LNCS, vol. 6940, pp. 97–118. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  27. 27.
    Swadi, K.N., Taha, W., Kiselyov, O., Pasalic, E.: A monadic approach for avoiding code duplication when staging memoized functions. In: Hatcliff, J., Tip, F. (eds.) PEPM, pp. 160–169. ACM (2006)Google Scholar
  28. 28.
    Tobin-Hochstadt, S.: Extensible pattern matching in an extensible language. CoRR, abs/1106.2578 (2011)Google Scholar
  29. 29.
    Tobin-Hochstadt, S., St-Amour, V., Culpepper, R., Flatt, M., Felleisen, M.: Languages as libraries. In: Hall, M.W., Padua, D.A. (eds.) PLDI, pp. 132–141. ACM (2011)Google Scholar
  30. 30.
    Wadler, P.: Comprehending monads. Mathematical Structures in Computer Science 2(4), 461–493 (1992)MathSciNetMATHCrossRefGoogle Scholar
  31. 31.
    Wright, A.K., Duba, B.F.: Pattern matching for scheme. Technical Report TX 77251-1892, Rice University (May 1995)Google Scholar
  32. 32.
    Yallop, J.: Ocaml patterns extesions. InternetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Peter Kourzanov
    • 1
  • Henk Sips
    • 1
  1. 1.NXP Semiconductors ResearchTU DelftThe Netherlands

Personalised recommendations