[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
10.1007/978-3-319-04132-2_5guideproceedingsArticle/Chapter ViewAbstractPublication PagesConference Proceedingsacm-pubtype
Article

Sunroof: A Monadic DSL for Generating JavaScript

Published: 20 January 2014 Publication History

Abstract

Sunroof is a Haskell-hosted Domain Specific Language (DSL) for generating JavaScript. The central feature of Sunroof is a JavaScript monad, which, like the Haskell IO-monad, allows access to external resources, but specifically JavaScript resources. As such, Sunroof is primarily a feature-rich foreign-function API to the browser's JavaScript engine, and all the browser-specific functionality, including HTML-based rendering, event handling, and drawing to the HTML5 canvas element.
In this paper, we give the design and implementation of Sunroof. Using monadic reification, we generate JavaScript from a deep embedding of the JavaScript monad. The Sunroof DSL has the feel of native Haskell, with a simple Haskell-based type schema to guide the Sunroof programmer. Furthermore, because we are generating code, we can offer Haskell-style concurrency patterns, such as MVars and Channels. In combination with a web-services package, the Sunroof DSL offers a robust platform to build interactive web applications.

References

[1]
http://asmjs.org/
[2]
http://taskjs.org/
[3]
HTML Living Standard - Timers, http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#timers
[4]
Apfelmus, H.: (2010), http://hackage.haskell.org/package/operational
[5]
Apfelmus, H.: The Operational Monad Tutorial. The Monad. Readerä15, 37—55 (2010)
[6]
Ashkenas, J.: CoffeeScript, http://coffeescript.org/
[7]
Bazerman, G.: JMacro, http://www.haskell.org/haskellwiki/Jmacro
[8]
Chakravarty, M.M.T., Keller, G., Peyton Jones, S.: Associated type synonyms. In: International Conference on Functional Programming, pp. 241—253. ACM (2005)
[9]
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)
[10]
Dijkstra, A., Stutterheim, J., Vermeulen, A., Swierstra, S.: Building JavaScript applications with Haskell. In: Hinze, R. (ed.) IFL 2012. LNCS, vol.ä8241, pp. 37—52. Springer, Heidelberg (2013)
[11]
Dijkstra, E.W.: Letters to the editor: go to statement considered harmful. Communications of the ACMä11(3), 147—148 (1968)
[12]
Domoszlai, L., Bruël, E., Jansen, J.M.: Implementing a non-strict purely functional language in JavaScript. Acta Universitatis Sapientiaeä3, 76—98 (2011)
[13]
Domoszlai, L., Plasmeijer, R.: Compiling Haskell to JavaScript through Clean's core. In: Selected papers of 9th Joint Conference on Mathematics and Computer Science (February 2012)
[14]
Done, C., Bergmark, A.: Fay, https://github.com/faylang/fay/wiki
[15]
Elliott, C.: Boolean, http://hackage.haskell.org/package/Boolean
[16]
Farmer, A., Gill, A.: Haskell DSLs for Interactive Web Services. In: First Workshop on Cross-model Language Design and Implementation (2012)
[17]
Gill, A.: Sunroof-active, https://github.com/ku-fpg/sunroof-active
[18]
Gill, A.: Type-Safe Observable Sharing in Haskell. In: Proceedings of the Second ACM SIGPLAN Haskell Symposium, Haskell 2009, pp. 117—128 (September 2009)
[19]
Gill, A.: (2013), http://hackage.haskell.org/package/blank-canvas
[20]
Gill, A., Farmer, A.: Kansas Comet, http://hackage.haskell.org/package/kansas-comet
[21]
Jones, S.P., Gordon, A., Finne, S.: Concurrent Haskell. In: Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, vol.ä21, pp. 295—308 (1996)
[22]
Kossakowski, G., Amin, N., Rompf, T., Odersky, M.: JavaScript as an Embedded DSL. In: Noble, J. (ed.) ECOOP 2012. LNCS, vol.ä7313, pp. 409—434. Springer, Heidelberg (2012)
[23]
Leijen, D., Meijer, E.: Domain Specific Embedded Compilers. In: Domain-Specific Languages, pp. 109—122. ACM (1999)
[24]
Lin, C.: Programming Monads Operationally with Unimo. In: International Conference on Functional Programming, pp. 274—285. ACM (2006)
[25]
Mahemoff, M.: HTTP Streaming, http://ajaxpatterns.org/Comet
[26]
Mainland, G.: Why It's Nice to be Quoted: Quasiquoting for Haskell. In: Proceedings of the ACM SIGPLAN Haskell Workshop, Haskell 2007, New York, NY, USA, pp. 73—82 (2007)
[27]
Moggi, E.: Computational lambda-calculus and monads. In: Logic in Computer Science, pp. 14—23. IEEE Press (1989)
[28]
Murakami, S., Ashkenas, J.: LiveScript, http://livescript.net/
[29]
Nazarov, V.: GHCJS Haskell to Javascript Compiler, https://github.com/ghcjs/ghcjs
[30]
Persson, A., Axelsson, E., Svenningsson, J.: Generic monadic constructs for embedded languages. In: Gill, A., Hage, J. (eds.) IFL 2011. LNCS, vol.ä7257, pp. 85—99. Springer, Heidelberg (2012)
[31]
Predescu, O.: Model-View-Controller in Cocoon using continuations-based control flow (2002), http://www.webweavertech.com/ovidiu/weblog/archives/000042.html
[32]
Rompf, T., Odersky, M.: Lightweight modular staging: a pragmatic approach to runtime code generation and compiled DSLs. In: Proceedings of the Ninth International Conference on Generative Programming and Component Engineering, GPCE 2010, pp. 127—136. ACM, New York (2010)
[33]
Finne, S., et al.: Calling hell from heaven and heaven from hell (1999)
[34]
Sculthorpe, N., Bracker, J., Giorgidze, G., Gill, A.: The Constrained-Monad Problem. In: International Conference on Functional Programming, pp. 287—298. ACM (2013)
[35]
Shields, M., Peyton Jones, S.: Object-oriented style overloading for Haskell. In: First Workshop on Multi-Language Inferastructure and Interoperability (BABEL 2001), Firenze, Italy (September 2001)
[36]
Stutterheim, J.: Improving the UHC JavaScript backend. Tech. rep., Utrecht University (2012), http://www.norm2782.com/improving-uhc-js-report.pdf
[37]
Svenningsson, J., Svensson, B.J.: Simple and compositional reification of monadic embedded languages. In: International Conference on Functional Programming, pp. 299—304. ACM (2013)
[38]
Yorgey, B.: Active, https://github.com/diagrams/active
[39]
Yorgey, B.: Active, https://github.com/diagrams
[40]
Zakai, A.: Emscripten: An LLVM-to-Javascript Compiler, http://emscripten.org/

Cited By

View all

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image Guide Proceedings
PADL 2014: Proceedings of the 16th International Symposium on Practical Aspects of Declarative Languages - Volume 8324
January 2014
231 pages
ISBN:9783319041315
  • Editors:
  • Matthew Flatt,
  • Hai-Feng Guo

Publisher

Springer-Verlag

Berlin, Heidelberg

Publication History

Published: 20 January 2014

Author Tags

  1. Cloud Computing
  2. DSLs
  3. JavaScript
  4. Web Technologies

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)0
  • Downloads (Last 6 weeks)0
Reflects downloads up to 14 Dec 2024

Other Metrics

Citations

Cited By

View all

View Options

View options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media