Abstract
Web interfaces are an important part of many applications but their implementation is full of pitfalls due to the client/server nature of web programming. This paper presents a lightweight approach to web programming based on a standard infrastructure, in particular, the common CGI protocol between client and server. No specific additions are necessary on the server side. Our approach exploits declarative programming features to provide a high-level API for server-side web scripting. This API allows to check many programming errors at compile time by using functional (static typing, higher-order functions) as well as logic (free variables) programming features. Together with further abstractions, like session handling, persistence, and typeful database access, it is used for non-trivial web applications.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
Actually, this was the approach taken in a very early continuation-based library for web programming in Curry [6]. The practical problems caused by the web-server processes motivated the current approach.
- 2.
Variables and function names usually start with lowercase letters and the names of type and data constructors start with an uppercase letter. The application of f to e is denoted by juxtaposition (“f e”).
- 3.
Actually, Curry is intended as an extension of Haskell although not all of the numerous features of Haskell are actually supported.
- 4.
Actually, there is a simple script to wrap such web page definitions with showHtmlPage before compiling and installing it.
- 5.
The actual definition in our library contains more operations which are not relevant here.
- 6.
- 7.
Of course, this game can be implemented on the client side, but a realistic example with database access needs too much space.
- 8.
The preprocessor is used since contemporary Curry implementations do not provide access to entities of the program at run time.
- 9.
- 10.
References
Antoy, S., Echahed, R., Hanus, M.: A needed narrowing strategy. J. ACM 47(4), 776–822 (2000)
Antoy, S., Hanus, M.: Functional logic programming. Commun. ACM 53(4), 74–85 (2010)
Cabeza, D., Hermenegildo, M.: Distributed WWW programming using (CIAO-)Prolog and the PiLLoW library. Theory Pract. Log. Program. 1(3), 251–282 (2001)
Cooper, E., Lindley, S., Wadler, P., Yallop, J.: Links: web programming without tiers. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2006. LNCS, vol. 4709, pp. 266–296. Springer, Heidelberg (2007). https://doi.org/10.1007/978-3-540-74792-5_12
Ekblad, A., Claessen, K.: A seamless, client-centric programming model for type safe web applications. In: Proceedings of the 2014 ACM SIGPLAN Symposium on Haskell, pp. 79–89. ACM Press (2014)
Hanus, M.: High-level server side web scripting in curry. In: Ramakrishnan, I.V. (ed.) PADL 2001. LNCS, vol. 1990, pp. 76–92. Springer, Heidelberg (2001). https://doi.org/10.1007/3-540-45241-9_6
Hanus, M.: Type-oriented construction of web user interfaces. In: Proceedings of the 8th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP 2006), pp. 27–38. ACM Press (2006)
Hanus, M.: Putting declarative programming into the web: translating curry to JavaScript. In: Proceedings of the 9th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP 2007), pp. 155–166. ACM Press (2007)
Hanus, M.: Functional logic programming: from theory to curry. In: Voronkov, A., Weidenbach, C. (eds.) Programming Logics. LNCS, vol. 7797, pp. 123–168. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-37651-1_6
Hanus, M., Kluß, C.: Declarative programming of user interfaces. In: Gill, A., Swift, T. (eds.) PADL 2009. LNCS, vol. 5418, pp. 16–30. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-92995-6_2
Hanus, M., Koschnicke, S.: An ER-based framework for declarative web programming. Theory Pract. Log. Program. 14(3), 269–291 (2014)
Hanus, M., Krone, J.: A typeful integration of SQL into curry. In: Proceedings of the 24th International Workshop on Functional and (Constraint) Logic Programming, volume 234 of Electronic Proceedings in Theoretical Computer Science, pp. 104–119. Open Publishing Association (2017)
Hanus, M. (eds.): Curry: an integrated functional logic language (vers. 0.9.0) (2016). http://www.curry-lang.org
Huseby, S.H.: Innocent Code: A Security Wake-Up Call for Web Programmers. Wiley (2003)
Krishnamurthi, S., McCarthy, J.A., Graunke, P.T., Pettyjohn, G., Felleisen, M.: Implementation and use of the PLT scheme web server. High. Order Symbol. Comput. 20(4), 431–460 (2007)
Ladd, D.A., Ramming, J.C.: Programming the web: an application-oriented language for hypermedia service programming. World Wide Web J. 1(1) (1996)
Meijer, E.: Server side web scripting in Haskell. J. Funct. Program. 10(1), 1–18 (2000)
Peyton Jones, S. (ed.) Haskell 98 Language and Libraries-The Revised Report. Cambridge University Press (2003)
Plasmeijer, R., Achten, P.: iData for the world wide web – programming interconnected web forms. In: Hagiya, M., Wadler, P. (eds.) FLOPS 2006. LNCS, vol. 3945, pp. 242–258. Springer, Heidelberg (2006). https://doi.org/10.1007/11737414_17
Sandholm, A., Schwartzbach, M.I.: A type system for dynamic web documents. In: Proceedings of the 27th ACM Symposium on Principles of Programming Languages, pp. 290–301 (2000)
Thiemann, P.: A typed representation for HTML and XML documents in Haskell. J. Funct. Program. 12(4–5), 435–468 (2002)
Thiemann, P.: WASH/CGI: server-side web scripting with sessions and typed, compositional forms. In: Krishnamurthi, S., Ramakrishnan, C.R. (eds.) PADL 2002. LNCS, vol. 2257, pp. 192–208. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45587-6_13
Thiemann, P.: WASH server pages. In: Hagiya, M., Wadler, P. (eds.) FLOPS 2006. LNCS, vol. 3945, pp. 277–293. Springer, Heidelberg (2006). https://doi.org/10.1007/11737414_19
Wadler, P.: How to declare an imperative. ACM Comput. Surv. 29(3), 240–263 (1997)
Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad hoc. In: Proceedings of POPL 1989, pp. 60–76 (1989)
Wielemaker, J., Huang, Z., van der Meij, L.: SWI-Prolog and the web. Theory Pract. Log. Program. 8(3), 363–392 (2008)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2021 Springer Nature Switzerland AG
About this paper
Cite this paper
Hanus, M. (2021). Lightweight Declarative Server-Side Web Programming. In: Morales, J.F., Orchard, D. (eds) Practical Aspects of Declarative Languages. PADL 2021. Lecture Notes in Computer Science(), vol 12548. Springer, Cham. https://doi.org/10.1007/978-3-030-67438-0_7
Download citation
DOI: https://doi.org/10.1007/978-3-030-67438-0_7
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-67437-3
Online ISBN: 978-3-030-67438-0
eBook Packages: Computer ScienceComputer Science (R0)