Skip to main content Accessibility help
×
Home
Hostname: page-component-846f6c7c4f-fw8f9 Total loading time: 0.347 Render date: 2022-07-07T10:42:31.211Z Has data issue: true Feature Flags: { "shouldUseShareProductTool": true, "shouldUseHypothesis": true, "isUnsiloEnabled": true, "useRatesEcommerce": false, "useNewApi": true } hasContentIssue true

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.CrossRefGoogle 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.CrossRefGoogle 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.CrossRefGoogle 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.CrossRefGoogle Scholar
Hanus, M. (2007) Multi-paradigm declarative languages. In: 23rd International Conference on Logic Programming, Springer Lecture Notes in Computer Science 4670 4575.CrossRefGoogle 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.CrossRefGoogle 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.CrossRefGoogle Scholar
Läufer, K. and Odersky, M. (1994) Polymorphic type inference and abstract data types. ACM Transactions on Programming Languages and Systems 16 14111430.CrossRefGoogle 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.CrossRefGoogle 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.CrossRefGoogle 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.CrossRefGoogle 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.CrossRefGoogle 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.CrossRefGoogle Scholar
Milner, R. (1978) A theory of type polymorphism in programming. Journal of Computer and System Sciences 17 348375.CrossRefGoogle Scholar
Mitchell, J. C. and Plotkin, G. D. (1988) Abstract types have existential type. ACM Transactions on Programming Languages and Systems 10 (3)470502.CrossRefGoogle 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.CrossRefGoogle 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.CrossRefGoogle 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.CrossRefGoogle 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.CrossRefGoogle Scholar

Save article to Kindle

To save this article to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

A liberal type system for functional logic programs
Available formats
×

Save article to Dropbox

To save this article to your Dropbox account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you used this feature, you will be asked to authorise Cambridge Core to connect with your Dropbox account. Find out more about saving content to Dropbox.

A liberal type system for functional logic programs
Available formats
×

Save article to Google Drive

To save this article to your Google Drive account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you used this feature, you will be asked to authorise Cambridge Core to connect with your Google Drive account. Find out more about saving content to Google Drive.

A liberal type system for functional logic programs
Available formats
×
×

Reply to: Submit a response

Please enter your response.

Your details

Please enter a valid email address.

Conflicting interests

Do you have any conflicting interests? *