Hostname: page-component-78c5997874-v9fdk Total loading time: 0 Render date: 2024-11-16T05:02:59.941Z Has data issue: false hasContentIssue false

The Kansas University rewrite engine

A Haskell-Embedded Strategic Programming Language with Custom Closed Universes

Published online by Cambridge University Press:  03 July 2014

NEIL SCULTHORPE
Affiliation:
Information and Telecommunication Technology Center, The University of Kansas, USA (e-mail: neil@ittc.ku.edu, nfrisby@ittc.ku.edu, andygill@ittc.ku.edu)
NICOLAS FRISBY
Affiliation:
Information and Telecommunication Technology Center, The University of Kansas, USA (e-mail: neil@ittc.ku.edu, nfrisby@ittc.ku.edu, andygill@ittc.ku.edu)
ANDY GILL
Affiliation:
Information and Telecommunication Technology Center, The University of Kansas, USA (e-mail: neil@ittc.ku.edu, nfrisby@ittc.ku.edu, andygill@ittc.ku.edu)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

When writing transformation systems, a significant amount of engineering effort goes into setting up the infrastructure needed to direct individual transformations to specific targets in the data being transformed. Strategic programming languages provide general-purpose infrastructure for this task, which the author of a transformation system can use for any algebraic data structure. The Kansas University Rewrite Engine (KURE) is a typed strategic programming language, implemented as a Haskell-embedded domain-specific language. KURE is designed to support typed transformations over typed data, and the main challenge is how to make such transformations compatible with generic traversal strategies that should operate over any type. Strategic programming in a typed setting has much in common with datatype-generic programming. Compared to other approaches to datatype-generic programming, the distinguishing feature of KURE's solution is that the user can configure the behaviour of traversals based on the location of each datum in the tree, beyond their behaviour being determined by the type of each datum. This article describes KURE's approach to assigning types to generic traversals, and the implementation of that approach. We also compare KURE, its design choices, and their consequences, with other approaches to strategic and datatype-generic programming.

Type
Articles
Copyright
Copyright © Cambridge University Press 2014 

References

Adams, M. D., Farmer, A. & Magalhães, J. P. (2014) Optimizing SYB is easy! In Workshop on Partial Evaluation and Program Manipulation. New York, NY: ACM, pp. 7182.Google Scholar
Balland, E., Moreau, P.-E. & Reilles, A. (2008) Rewriting strategies in Java. In Eighth International Workshop on Rule Based Programming, Electronic Notes in Theoretical Computer Science, vol. 219. Amsterdam: Elsevier, pp. 97111.Google Scholar
Bravenboer, M., Kalleberg, K. T., Vermaas, R. & Visser, E. (2008) Stratego/XT 0.17. A language and toolset for program transformation. Sci. Comput. Program. 72 (1–2), 5270.Google Scholar
Bringert, B. & Ranta, A. (2008) A pattern for almost compositional functions. J. Funct. Program. 18 (5–6), 567598.Google Scholar
Brown, N. C. C. & Sampson, A. T. (2009) Alloy: Fast generic transformations for Haskell. In Haskell Symposium. New York, NY: ACM, pp. 105116.Google Scholar
Burstall, R. M. & Darlington, J. (1977) A transformation system for developing recursive programs. J. ACM 24 (1), 4467.CrossRefGoogle Scholar
Culpepper, R. (2012) Fortifying macros. J. Funct. Program. 22 (4–5), 439476.CrossRefGoogle Scholar
Culpepper, R. & Felleisen, M. (2010) Fortifying macros. In International Conference on Functional Programming. New York, NY: ACM, pp. 235246.Google Scholar
Dolstra, E. (2001) First Class Rules and Generic Traversals for Program Transformation Languages, Master's thesis, Utrecht University.Google Scholar
Dolstra, E. & Visser, E. (2001) First-Class Rules and Generic Traversal. Tech. rept. UU-CS-2001-38. Utrecht University, Utrecht.Google Scholar
Ellison, C. & Roşu, G. (2012) An executable formal semantics of C with applications. In Symposium on Principles of Programming Languages. New York, NY: ACM, pp. 533544.Google Scholar
Erdweg, S., Rendel, T., Kästner, C. & Ostermann, K. (2011) SugarJ: Library-based syntactic language extensibility. In International Conference on Object-Oriented Programming, Systems, Languages, and Applications. New York, NY: ACM, pp. 391406.Google Scholar
Erdweg, S. & Rieger, F. (2013) A framework for extensible languages. In International Conference on Generative Programming: Concepts & Experiences. New York, NY: ACM, pp. 312.Google Scholar
Erdweg, S., Rieger, F., Rendel, T. & Ostermann, K. (2012) Layout-sensitive language extensibility with SugarHaskell. In Haskell Symposium. New York, NY: ACM, pp. 149160.Google Scholar
Erdweg, S., Vergu, V., Mezini, M. & Visser, E. (2014) Modular specification and dynamic enforcement of syntactic language constraints when generating code. In International Conference on Modularity. New York, NY: ACM, pp. 241252.CrossRefGoogle Scholar
Farmer, A., Gill, A., Komp, E. & Sculthorpe, N. (2012) The HERMIT in the machine: A plugin for the interactive transformation of GHC core language programs. In Haskell Symposium. New York, NY: ACM, pp. 112.Google Scholar
Felleisen, M., Findler, R. B. & Flatt, M. (2009) Semantics Engineering with PLT Redex. Cambridge, MA: MIT Press.Google Scholar
Frisby, N., Gill, A. & Alexander, P. (2012) A pattern for almost homomorphic functions. In Workshop on Generic Programming. New York, NY: ACM, pp. 112.Google Scholar
Gibbons, J. (2005) Patterns in datatype-generic programming. In Workshop on Declarative Programming in the Context of Object-Oriented Languages 2003, Striegnitz, J. & Davis, K. (eds), NIC Series, vol. 27. Jülich: NIC, pp. 277289.Google Scholar
Gill, A. (2006) Introducing the Haskell equational reasoning assistant. In Haskell Workshop. New York, NY: ACM, pp. 108109.Google Scholar
Gill, A. (2009) A Haskell hosted DSL for writing transformation systems. In Working Conference on Domain-Specific Languages, Taha, W. (ed), Lecture Notes in Computer Science, vol. 5658. Berlin: Springer, pp. 285309.Google Scholar
Girard, J.-Y.. (1972) Interprétation fonctionelle et élimination des coupures de l'arithmétique d'ordre supérieur. Ph.D. thesis, Université Paris Diderot, Paris.Google Scholar
Hinze, R. & Löh, A. (2007) Generic programming, now! International spring school on datatype-generic programming 2006, Backhouse, R., Gibbons, J., Hinze, R. & Jeuring, J. (eds), Lecture Notes in Computer Science, vol. 4719. Berlin: Springer, pp. 150208.Google Scholar
Hinze, R. & Löh, A. (2009) Generic programming in 3D. Sci. Comput. Program. 74 (8), 590628.Google Scholar
Hughes, R. J. M. (1986) A novel representation of lists and its application to the function “reverse”. Inf. Process. Lett. 22 (3), 141144.Google Scholar
Kats, L. C. L. & Visser, E. (2010) The Spoofax language workbench. Rules for declarative specification of languages and IDEs. In International Conference on Object-Oriented Programming, Systems, Languages, and Applications. New York, NY: ACM, pp. 444463.CrossRefGoogle Scholar
Kiselyov, O. (2006) Smash your boiler-plate without class and typeable. http://article.gmane.org/gmane.comp.lang.haskell.general/14086.Google Scholar
Klein, C., Clements, J., Dimoulas, C., Eastlund, C., Felleisen, M., Flatt, M., McCarthy, J. A., Rafkind, J., Tobin-Hochstadt, S. & Findler, R. B. (2012) Run your research: On the effectiveness of lightweight mechanization. In Symposium on Principles of Programming Languages. New York, NY: ACM, pp. 285296.Google Scholar
Lämmel, R. & Peyton, Jones, S. (2003) Scrap your boilerplate: A practical design pattern for generic programming. In Types in Languages Design and Implementation. New York, NY: ACM, pp. 2637.Google Scholar
Lämmel, R. & Visser, J. (2002) Typed combinators for generic traversal. International Symposium on Practical Aspects of Declarative Programming, Krishnamurthi, S. & Ramakrishnan, C. R. (eds), Lecture Notes in Computer Science, vol. 2257. Berlin: Springer, pp. 137154.Google Scholar
Lazar, D., Arusoaie, A., Serbanuta, T. F., Ellison, C., Mereuta, R., Lucanu, D. & Roşu, G. (2012) Executing formal semantics with the K tool. In International symposium on formal methods, Giannakopoulou, D. & Méry, D. (eds), Lecture Notes in Computer Science, vol. 7436. Berlin: Springer, pp. 267271.Google Scholar
Liang, S., Hudak, P. & Jones, M. (1995) Monad transformers and modular interpreters. In Symposium on Principles of Programming Languages. New York, NY: ACM, pp. 333343.Google Scholar
Löh, A. & Magalhães, J. P. (2011) Generic programming with indexed functors. In Workshop on Generic Programming. New York, NY: ACM, pp. 112.Google Scholar
Magalhães, J. P., Dijkstra, A., Jeuring, J. & Löh, A. (2010) A generic deriving mechanism for Haskell. In Haskell Symposium. New York, NY: ACM, pp. 3748.Google Scholar
McBride, C. & Paterson, R. (2008) Applicative programming with effects. J. Funct. Program. 18 (1), 113.Google Scholar
Mitchell, N. & Runciman, C. (2007) Uniform boilerplate and list processing. In Haskell Workshop. New York, NY: ACM, pp. 4960.Google Scholar
Moors, A., Piessens, F. & Joosen, W. (2006) An object-oriented approach to datatype-generic programming. In Workshop on Generic Programming. New York, NY: ACM, pp. 96106.Google Scholar
van Noort, T., Rodriguez Yakushev, A., Holdermans, S., Jeuring, J., Heeren, B. & Magalhães, J. P. (2010) A lightweight approach to datatype-generic rewriting. J. Funct. Program. 20 (3–4), 375413.Google Scholar
O'Connor, R. (2011) Functor is to Lens as Applicative is to Biplate: Introducing Multiplate. Workshop on generic programming. Available at http://arxiv.org/abs/1103.2841.Google Scholar
Oliveira, B. C. D. S. & Gibbons, J. (2010) Scala for generic programmers. J. Funct. Program. 20 (3–4), 303352.Google Scholar
Peyton Jones, S. (2007) Call-pattern specialisation for Haskell programs. In International Conference on Functional Programming. New York, NY: ACM, pp. 327337.Google Scholar
Peyton Jones, S., Vytiniotis, D., Weirich, S. & Shields, M. (2007) Practical type inference for arbitrary-rank types. J. Funct. Program. 17 (1), 182.Google Scholar
Reynolds, J. C. (1974) Towards a theory of type structure. In Colloque sur la programmation, Robinet, B. (ed), Lecture Notes in Computer Science, vol. 19. Berlin: Springer, pp. 408423.Google Scholar
Rodriguez Yakushev, A., Jeuring, J., Jansson, P., Gerdes, A., Kiselyov, O. & Oliveira, B. (2008) Comparing libraries for generic programming in Haskell. In Haskell Symposium. New York, NY: ACM, pp. 111122.Google Scholar
Santos, A. (1995) Compilation by Transformation in Non-Strict Functional Languages. Ph.D. thesis, University of Glasgow, Glasgow.Google Scholar
Schmidt, U., Schmidt, M. & Kuseler, T. (2012) http://hackage.haskell.org/package/hxt.Google Scholar
Sculthorpe, N., Farmer, A. & Gill, A. (2013) The HERMIT in the tree: Mechanizing program transformations in the GHC core language. In International Symposium on Implementation and Application of Functional Languages 2012, Hinze, R. (ed), Lecture Notes in Computer Science, vol. 8241. Berlin: Springer, pp. 86103.Google Scholar
Sheard, T. & Peyton Jones, S. (2002) Template metaprogramming for Haskell. In Haskell Workshop. New York, NY: ACM, pp. 116.Google Scholar
Strachey, C. (1967) Fundamental Concepts in Programming Languages. Lecture Notes, International Summer School in Computer Programming, Copenhagen. Reprinted in Higher-Order and Symbolic Computation, 13 (1–2), 1149, 2000.Google Scholar
Sulzmann, M., Chakravarty, M. M. T., Peyton Jones, S. & Donnelly, K. (2007) System F with type equality coercions. In International Workshop on Types in Language Design and Implementation. New York, NY: ACM, pp. 5366.Google Scholar
Swierstra, W. (2008) Data types à la carte. J. Funct. Program, 18 (4), 423436.Google Scholar
Tseitin, G. S. (1968). On the complexity of derivations in the propositional calculus. In Structures in Constructive Mathematics and Mathematical Logic, Part II, Slisenko, A.O. (ed), Seminars in Mathematics, vol. 8. Moscow: Steklov Mathematical Institute, pp. 115125. Reprinted in Pages 466–483 of: Automation of reasoning, Springer, 1983.Google Scholar
Visser, E. (2004) Program transformation with Stratego/XT: Rules, strategies, tools, and systems in StrategoXT-0.9. In International Seminar on Domain-Specific Program Generation 2003, Lengauer, C., Batory, D., Consel, C. & Odersky, M. (eds), Lecture Notes in Computer Science, vol. 3016. Berlin: Springer, pp. 216238.Google Scholar
Visser, E. (2005) A survey of strategies in rule-based program transformation systems. J. Symb. Comput. 40 (1), 831873.Google Scholar
Visser, E. (2013). Personal communication.Google Scholar
Visser, E., Benaissa, Zine-el-Abidine, & Tolmach, A. (1998) Building program optimizers with rewriting strategies. In International Conference on Functional Programming. New York, NY: ACM, pp. 1326.Google Scholar
Wadler, P. (1992) The essence of functional programming. Symposium on Principles of Programming Languages. New York, NY: ACM, pp. 114.Google Scholar
Wadler, P. & Blott, S. (1989) How to make ad-hoc polymorphism less ad hoc. In Symposium on Principles of Programming Languages. New York, NY: ACM, pp. 6076.Google Scholar
Supplementary material: File

Sculthorpe Supplementary Material

Supplementary Material

Download Sculthorpe Supplementary Material(File)
File 30.6 KB
Submit a response

Discussions

No Discussions have been published for this article.