Skip to main content
×
Home
    • Aa
    • Aa

Interactive programming in Agda – Objects and graphical user interfaces

  • ANDREAS ABEL (a1), STEPHAN ADELSBERGER (a2) and ANTON SETZER (a3)
Abstract
Abstract

We develop a methodology for writing interactive and object-based programs (in the sense of Wegner) in dependently typed functional programming languages. The methodology is implemented in the ooAgda library. ooAgda provides a syntax similar to the one used in object-oriented programming languages, thanks to Agda's copattern matching facility. The library allows for the development of graphical user interfaces (GUIs), including the use of action listeners.

Our notion of interactive programs is based on the IO monad defined by Hancock and Setzer, which is a coinductive data type. We use a sized coinductive type which allows us to write corecursive programs in a modular way. Objects are server-side interactive programs that respond to method calls by giving answers and changing their state. We introduce two kinds of objects: simple objects and IO objects. Methods in simple objects are pure, while method calls in IO objects allow for interactions before returning their result. Our approach also allows us to extend interfaces and objects by additional methods.

We refine our approach to state-dependent interactive programs and objects through which we can avoid exceptions. For example, with a state-dependent stack object, we can statically disable the pop method for empty stacks. As an example, we develop the implementation of recursive functions using a safe stack. Using a coinductive notion of object bisimilarity, we verify basic correctness properties of stack objects and show the equivalence of different stack implementations. Finally, we give a proof of concept that our interaction model allows to write GUI programs in a natural way: we present a simple drawing program, and a program which allows the users to move a small spaceship using a button.

Copyright
Linked references
Hide All

This list contains references from the content that can be linked to their source. For a full set of references and notes please see the PDF or HTML where available.

M. Abadi & L. Cardelli (eds). (1996) A Theory of Objects, Monographs in Computer Science. Springer.

A. Abel (2008) Semi-continuous sized types and termination. Log. Meth. Comput. Sci. 4 (2:3), 133 (CSL'06 special issue).

A. Abel & B. Pientka (2013) Wellfounded recursion with copatterns: A unified approach to termination and productivity. In G. Morrisett & T. Uustalu (eds) Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming, ICFP 2013. ACM, pp. 185196.

T. Altenkirch & P. Morris (2009) Indexed containers. In Proceedings of the 24nd IEEE Symposium on Logic in Computer Science, LICS 2009. IEEE Computer Society, pp. 277285.

G. Barthe , M. J. Frade , E. Giménez , L. Pinto & T. Uustalu (2004) Type-based termination of recursive definitions. Math. Struct. Comput. Sci. 14 (1), 97141.

A. Bauer & M. Pretnar (2015) Programming with algebraic effects and handlers. J. Log. Algebr. Methods Program. 84 (1), 108123.

J. C. Blanchette , A. Popescu & D. Traytel (2015) Foundational extensible corecursion: a proof assistant perspective. In K. Fisher & J. H. Reppy (eds), Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming, ICFP 2015. ACM, pp. 192204.

T. Coquand (1994) Infinite objects in type theory. In H. Barendregt & T. Nipkow (eds), Proceedings of the International Workshop on Types for Proofs and Programs, TYPES '93, Lecture Notes in Computer Sciience, vol. 806. Springer, pp. 6278.

P. Dybjer (1994) Inductive families. Formal Asp. Comput. 6 (4), 440465.

P. Dybjer & A. Setzer (2003) Induction-recursion and initial algebras. Ann. Pure Appl. Logic 124, 147.

R. Garcia , É. Tanter , R. Wolff & J. Aldrich (2014) Foundations of typestate-oriented programming. ACM Trans. Program. Lang. Syst. 36 (4), 12:112:44.

J. G. Granström (2012) A new paradigm for component-based development. J. Softw. 7 (5), 11361148.

P. Hancock & P. Hyvernat (2006) Programming interfaces and basic topology. Ann. Pure Appl. Log. 137, 189239.

P. Hancock , C. McBride , N. Ghani , L. Malatesta & T. Altenkirch (2013) Small induction recursion. In M. Hasegawa (ed), Typed Lambda Calculi and Applications, Lecture Notes in Computer Science, vol. 7941. Berlin, Heidelberg: Springer, pp. 156172.

P. Hancock & A. Setzer (2005) Interactive programs and weakly final coalgebras in dependent type theory. In L. Crosilla & P. Schuster (eds), From Sets and Types to Topology and Analysis. Towards Practicable Foundations for Constructive Mathematics, Oxford Logic Guides. Oxford: Oxford Univ. Press.

T. Harris , S. Marlow , S. L. Peyton Jones & M. Herlihy (2008) Composable memory transactions. Commun. ACM 51 (8), 91100.

R. Hirschfeld , P. Costanza & O. Nierstrasz (2008) Context-oriented programming. J. Obj. Tech. 7 (3), 125151.

A. J. C. Hurkens (1995) A simplification of Girard's paradox. In M. Dezani-Ciancaglini & G. D. Plotkin (eds), Proceedings of the 2nd International Conference on Typed Lambda Calculi and Applications, TLCA '95, Lecture Notes in Computer Science, vol. 902. Springer, pp. 266278.

B. Igried & A. Setzer (2016) Programming with monadic CSP-style processes in dependent type theory. In Proceedings of the 1st International Workshop on Type-Driven Development, TyDe 2016, New York: ACM, pp. 2838.

R. Matthes (2002) Tarski's fixed-point theorem and lambda calculi with monotone inductive types. Synthese 133 (1–2), 107129.

C. McBride & J. McKinna (2004) The view from the left. J. Funct. Program. 14 (1), 69111.

E. Moggi (1991) Notions of computation and monads. Inf. Comput. 93 (1), 5592.

K. Petersson & D. Synek (1989) A set constructor for inductive sets in Martin-Löf's Type Theory. In D. H. Pitt , D. E. Rydeheard , P. Dybjer , A. M. Pitts & A. Poigné (eds), Category Theory and Computer Science, Lecture Notes in Computer Science, vol. 389. London: Springer-Verlag, pp. 128140.

A. Setzer (2012) Coalgebras as types determined by their elimination rules. In P. Dybjer , S. Lindström , E. Palmgren & G. Sundholm (eds), Epistemology versus Ontology Logic, Epistemology, and the Unity of Science, vol. 27. Springer Netherlands, pp. 351369. doi: 10.1007/978-94-007-4435-6_16.

A. Setzer (2016) How to reason coinductively informally. In R. Kahle , T. Strahm & T. Studer (eds), Advances in Proof Theory. Springer, pp. 377408.

A. Stump (2016) Verified Functional Programming in Agda. Morgan & Claypool.

Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 49 *
Loading metrics...

Abstract views

Total abstract views: 366 *
Loading metrics...

* Views captured on Cambridge Core between 6th February 2017 - 20th September 2017. This data will be updated every 24 hours.