Hostname: page-component-7bb8b95d7b-lvwk9 Total loading time: 0 Render date: 2024-09-10T12:24:00.042Z Has data issue: false hasContentIssue false

A liberal type system for functional logic programs

Published online by Cambridge University Press:  10 November 2014

FRANCISCO JAVIER LÓPEZ-FRAGUAS
Affiliation:
Dpto. de Sistemas Informáticos y Computación, Facultad de Informática, Universidad Complutense de Madrid, Madrid, Spain Email: fraguas@sip.ucm.es
ENRIQUE MARTIN-MARTIN
Affiliation:
Dpto. de Sistemas Informáticos y Computación, Facultad de Informática, Universidad Complutense de Madrid, Madrid, Spain Email: fraguas@sip.ucm.es
JUAN RODRÍGUEZ-HORTALÁ
Affiliation:
Dpto. de Sistemas Informáticos y Computación, Facultad de Informática, Universidad Complutense de Madrid, Madrid, Spain Email: fraguas@sip.ucm.es

Abstract

We propose a new type system for functional logic programming which is more liberal than the classical Damas–Milner usually adopted, but it is also restrictive enough to ensure type soundness. Starting from Damas–Milner typing of expressions, we propose a new notion of well-typed program that adds support for type-indexed functions, a particular form of existential types, opaque higher-order patterns and generic functions – as shown by an extensive collection of examples that illustrate the possibilities of our proposal. In the negative side, the types of functions must be declared, and therefore types are checked but not inferred. Another consequence is that parametricity is lost, although the impact of this flaw is limited as ‘free theorems’ were already compromised in functional logic programming because of non-determinism.

Type
Paper
Copyright
Copyright © Cambridge University Press 2014 

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Footnotes

This work has been partially supported by the Spanish projects STAMP (TIN2008-06622-C03-01), Prometidos-CM (S2009TIC-1465) and GPD (UCM-BSCH-GR35/10-A-910502).

References

Antoy, S. and Tolmach, A. P. (1999) Typed higher-order narrowing without higher-order strategies. In: 4th International Symposium on Functional and Logic Programming (FLOPS '09). Springer Lecture Notes in Computer Science 1722 335353.Google Scholar
Cheney, J. and Hinze, R. (2003) First-class phantom types. Technical Report TR2003-1901, Cornell University.Google Scholar
Christiansen, J., Seidel, D. and Voigtländer, J. (2010) Free theorems for functional logic programs. In: 4th ACM SIGPLAN Workshop on Programming Languages Meets Program Verification, ACM 3948.Google Scholar
Damas, L. and Milner, R. (1982) Principal type-schemes for functional programs. In: 9th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM 207212.Google Scholar
GHC-Team (2011) The glorious glasgow haskell compilation system user's guide. Available at http://www.haskell.org/ghc/docs/latest/html/users_guide.Google Scholar
González-Moreno, J., Hortalá-González, T., López-Fraguas, F. and Rodríguez-Artalejo, M. (1999) An approach to declarative programming based on a rewriting logic. Journal of Logic Programming 40 (1)4787.Google Scholar
González-Moreno, J., Hortalá-González, T. and Rodríguez-Artalejo, M. (1997) A higher order rewriting logic for functional logic programming. In: 14th International Conference on Logic Programming, MIT Press 153167.Google Scholar
González-Moreno, J., Hortalá-González, T. and Rodríguez-Artalejo, M. (2001) Polymorphic types in functional logic programming. Journal of Functional and Logic Programming 2001 (1)197.Google Scholar
Hall, C. V., Hammond, K., Peyton Jones, S. and Wadler, P. (1996) Type classes in Haskell. ACM Transactions on Programming Languages and Systems 18 (2)109138.Google Scholar
Hanus, M. (2007) Multi-paradigm declarative languages. In: 23rd International Conference on Logic Programming, Springer Lecture Notes in Computer Science 4670 4575.Google Scholar
Hanus, M. (ed.) (2006) Curry: An integrated functional logic language. Available at http://www.informatik.uni-kiel.de/~curry/report.html.Google Scholar
Hinze, R. (2006) Generics for the masses. Journal of Functional Programming 16 (4–5)451483.CrossRefGoogle Scholar
Hinze, R. and Löh, A. (2007) Generic programming, now! In: Datatype-Generic Programming 2006. Springer Lecture Notes in Computer Science 4719 150208.Google Scholar
Hudak, P., Hughes, J., Peyton Jones, S. and Wadler, P. (2007) A history of Haskell: Being lazy with class. In: 3rd ACM SIGPLAN Conference on History of Programming Languages, ACM 155.Google Scholar
Johann, P. and Voigtländer, J. (2004) Free theorems in the presence of seq. In: 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM 99110.Google Scholar
Läufer, K. and Odersky, M. (1994) Polymorphic type inference and abstract data types. ACM Transactions on Programming Languages and Systems 16 14111430.Google Scholar
Löh, A. and Hinze, R. (2006) Open data types and open functions. In: 8th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming, ACM 133144.Google Scholar
López-Fraguas, F., Martin-Martin, E. and Rodríguez-Hortalá, J. (2010) Liberal typing for functional logic programs. In: 8th Asian Symposium on Programming Languages and Systems (APLAS '10). Springer Lecture Notes in Computer Science 6461 8096.Google Scholar
López-Fraguas, F., Martin-Martin, E. and Rodríguez-Hortalá, J. (2010) New results on type systems for functional logic programming. In: 18th International Workshop on Functional and Constraint Logic Programming (WFLP '09). Springer Lecture Notes in Computer Science 5979 128144.Google Scholar
López-Fraguas, F., Rodríguez-Hortalá, J. and Sánchez-Hernández, J. (2008) Rewriting and call-time choice: The HO case. In: 9th International Symposium on Functional and Logic Programming. Springer Lecture Notes in Computer Science 4989 147162.Google Scholar
López-Fraguas, F. and Sánchez-Hernández, J. (1999) $\mathcal{TOY}$: A multiparadigm declarative system. In: 10th Rewriting Techniques and Applications (RTA'99). Springer Lecture Notes in Computer Science 1631 244247.Google Scholar
Lux, W. (2008) Adding Haskell-style overloading to Curry. In: Workshop of Working Group 2.1.4 of the German Computing Science Association GI 67–76.Google Scholar
Lux, W. (2009) Type-classes and call-time choice vs. run-time choice - post to the curry mailing list. Available at http://www.informatik.uni-kiel.de/~curry/listarchive/0790.html.Google Scholar
Martin-Martin, E. (2009) Advances in type systems for functional logic programming, Master's thesis, Universidad Complutense de Madrid. Available at http://gpd.sip.ucm.es/enrique/publications/master/masterThesis.pdf.Google Scholar
Martin-Martin, E. (2011) Type classes in functional logic programming. In: 20th ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, ACM 121130.Google Scholar
Milner, R. (1978) A theory of type polymorphism in programming. Journal of Computer and System Sciences 17 348375.Google Scholar
Mitchell, J. C. and Plotkin, G. D. (1988) Abstract types have existential type. ACM Transactions on Programming Languages and Systems 10 (3)470502.Google Scholar
Moreno-Navarro, J., Mariño, J., del Pozo-Pietro, A., Herranz-Nieva, A. and García-Martín, J. (1996) Adding type classes to functional-logic languages. In: Joint Conference on Declarative Programming, APPIA-GULP-PRODE'96 427–438.Google Scholar
Perry, N. (1991) The Implementation of Practical Functional Programming Languages, Ph.D. thesis, Imperial College, London.Google Scholar
Peyton Jones, S., Vytiniotis, D. and Weirich, S. (2006) Simple unification-based type inference for GADTs (Technical Appendix). Technical Report MS-CIS-05-22, University of Pennsylvania.Google Scholar
Sánchez-Hernández, J. (2006) Constructive failure in functional-logic programming: From theory to implementation. Journal of Universal Computer Science 12 (11)15741593.Google Scholar
Schrijvers, T., Peyton Jones, S., Sulzmann, M. and Vytiniotis, D. (2009) Complete and decidable type inference for GADTs. In: 14th ACM SIGPLAN International Conference on Functional Programming, ACM 341352.Google Scholar
Seidel, D. and Voigtländer, J. (2010) Automatically generating counterexamples to naive free theorems. In: 10th International Symposium on Functional and Logic Programming. Springer Lecture Notes in Computer Science 6009 175190.Google Scholar
Thatté, S. R. (1994) Semantics of type classes revisited. In: 8th ACM Conference on LISP and Functional Programming, ACM 208219.Google Scholar
van Bakel, S. and Fernández, M. (1997) Normalization results for typeable rewrite systems. Information and Computation 133 (2)73116.Google Scholar
Wadler, P. (1989) Theorems for free! In: 4th International Conference on Functional Programming Languages and Computer Architecture, ACM 347359.Google Scholar
Wadler, P. and Blott, S. (1989) How to make ad-hoc polymorphism less ad hoc. In: 16th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM 6076.Google Scholar
Warren, D. H. (1982) Higher-order extensions to prolog: Are they needed? In: Machine Intelligence 10, Ellis Horwood Ltd. 441454.Google Scholar
Wright, A. K. and Felleisen, M. (1992) A syntactic approach to type soundness. Information and Computation 115 3894.Google Scholar