Abstract
Typed functional programming allows us to write interesting programs without sacrificing type safety. Programs that expose their API to an open world, however, are faced with the problem of dynamic type checking. In Haskell, existing techniques that address this problem, such as Typeable and Dynamic, are often closed and difficult to extend. We have constructed an extensible Haskell library for describing APIs using annotated type representations. As a result, API calls can be interpreted in a type-safe manner without extra programming effort. In addition, the user has full control over the universe of allowed types, which helps to catch misconceptions in an early stage. We have applied our technique to connect a real-world DSL (GRACe) to a JavaScript GUI.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
The Saint library: https://github.com/GRACeFUL-project/Saint, and the case study: https://github.com/GRACeFUL-project/SaintCaseStudy.
References
Axelsson, E., et al.: Feldspar: a domain specific language for digital signal processing algorithms. In: 8th IEEE/ACM International Conference on Formal Methods and Models for Codesign (MEMOCODE 2010), pp. 169–178. IEEE (2010). https://doi.org/10.1109/MEMCOD.2010.5558637
Baars, A.I., Swierstra, S.D.: Typing dynamic typing. In: Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming, ICFP 2002, pp. 157–166. ACM, New York (2002). https://doi.org/10.1145/581478.581494
Bahr, P., Hvitved, T.: Compositional data types. In: Proceedings of the Seventh ACM SIGPLAN Workshop on Generic Programming, WGP 2011, pp. 83–94. ACM, New York (2011). https://doi.org/10.1145/2036918.2036930
Cheney, J., Hinze, R.: A lightweight implementation of generics and dynamics. In: Proceedings of the 2002 ACM SIGPLAN Workshop on Haskell, Haskell 2002, pp. 90–104. ACM, New York (2002). https://doi.org/10.1145/581690.581698
Damas, L., Milner, R.: Principal type-schemes for functional programs. In: Proceedings of the 9th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1982, pp. 207–212. ACM, New York (1982). https://doi.org/10.1145/582153.582176
Eisenberg, R.A., Weirich, S.: Dependently typed programming with singletons. In: Proceedings of the 2012 Haskell Symposium, Haskell 2012, pp. 117–130. ACM, New York (2012). https://doi.org/10.1145/2364506.2364522
Heeren, B., Jeuring, J., Gerdes, A.: Specifying rewrite strategies for interactive exercises. Math. Comput. Sci. 3(3), 349–370 (2010). https://doi.org/10.1007/s11786-010-0027-4
Henderson, P.: Functional geometry. In: Proceedings of the 1982 ACM Symposium on LISP and Functional Programming, LFP 1982, pp. 179–187. ACM, New York (1982). https://doi.org/10.1145/800068.802148
Henderson, P.: Functional geometry. High.-Order Symbolic Comput. 15(4), 349–365 (2002). https://doi.org/10.1023/A:1022986521797
Hinze, R., Jeuring, J., Löh, A.: Typed contracts for functional programming. In: Hagiya, M., Wadler, P. (eds.) FLOPS 2006. LNCS, vol. 3945, pp. 208–225. Springer, Heidelberg (2006). https://doi.org/10.1007/11737414_15
Jansson, P., et al.: D4.2: a domain specific language for GRACeFUL concept maps (2017). https://github.com/GRACeFUL-project/DSL-WP/raw/master/deliverables/d4.2.pdf, deliverable of the GRACeFUL project (640954)
Kiselyov, O.: Typed tagless final interpreters. In: Gibbons, J. (ed.) Generic and Indexed Programming. LNCS, vol. 7470, pp. 130–174. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-32202-0_3
Krishna Murthy, D.R., Wiens, V., Lohmann, S., Asmat, R.: D3.3: VA EDA tool prototype (2017). Deliverable of the GRACeFUL project. FETPROACT-1-2014 Grant No. 640954
Lämmel, R., Peyton Jones, S.: Scrap your boilerplate: a practical design pattern for generic programming. In: Proceedings of the 2003 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, TLDI 2003, pp. 26–37. ACM, New York (2003). https://doi.org/10.1145/604174.604179
Lohmann, S.: D2.5: CRUD RAT prototype (2017). Deliverable of the GRACeFUL project. FETPROACT-1-2014 Grant No. 640954
Mestanogullari, A., Hahn, S., Arni, J.K., Löh, A.: Type-level web APIs with servant: an exercise in domain-specific generic programming. In: Proceedings of the 11th ACM SIGPLAN Workshop on Generic Programming, pp. 1–12. ACM (2015). https://doi.org/10.1145/2808098.2808099
Peyton Jones, S., Weirich, S., Eisenberg, R.A., Vytiniotis, D.: A reflection on types. In: Lindley, S., McBride, C., Trinder, P., Sannella, D. (eds.) A List of Successes That Can Change the World. LNCS, vol. 9600, pp. 292–317. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-30936-1_16
Swierstra, W.: Data types à la carte. J. Funct. Program. 18(4), 423–436 (2008). https://doi.org/10.1017/S0956796808006758
Wadler, P.: The expression problem (1998). http://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt, appeared on the Java-genericity mailing list
Acknowledgements
This work was partially supported by the projects GRACeFUL (grant #640954) and CoeGSS (grant #676547), which have received funding from the European Union’s Horizon 2020 research and innovation programme. It was also partially supported by the Wallenberg Artificial Intelligence, Autonomous Systems and Software Program (WASP) funded by Knut and Alice Wallenberg Foundation.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2019 Springer Nature Switzerland AG
About this paper
Cite this paper
Algehed, M., Jansson, P., Einarsdóttir, S.H., Gerdes, A. (2019). Saint: An API-Generic Type-Safe Interpreter. In: Pałka, M., Myreen, M. (eds) Trends in Functional Programming. TFP 2018. Lecture Notes in Computer Science(), vol 11457. Springer, Cham. https://doi.org/10.1007/978-3-030-18506-0_5
Download citation
DOI: https://doi.org/10.1007/978-3-030-18506-0_5
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-18505-3
Online ISBN: 978-3-030-18506-0
eBook Packages: Computer ScienceComputer Science (R0)