Most implementations of functional and functional logic languages treat numbers and the basic numeric operations as external entities. The main reason for this is efficiency. However, this basic design decision has many unfortunate consequences for all programs using numbers. We present an approach to model numbers in a declarative way and argue that the loss in efficiency is compensated by the newly gained possibilities. Functional logic languages benefit the most from this proposal because all the numeric operations become fully narrowable. This enables the solving of simple equations on numbers in an efficient way without having to resort to external constraint solvers. The presented approach can either be used as a library for purely declarative numbers or it can be employed as a basic data type of functional (logic) languages. Indeed, we have integrated the presented data structures as the only numbers available in our compiler for the functional logic language Curry.
[1]
Michael Hanus,et al.
Functional Logic Design Patterns
,
2002,
FLOPS.
[2]
Michael Hanus,et al.
Declarative Programming with Function Patterns
,
2005,
LOPSTR.
[3]
Michael Hanus,et al.
On the Completeness of Residuation
,
1992,
JICSLP.
[4]
Michael Hanus,et al.
The Integration of Functions into Logic Programming: From Theory to Practice
,
1994,
J. Log. Program..
[5]
Bernd Brassel,et al.
Translating curry to haskell system demo
,
2005,
WCFLP '05.
[6]
Ramin Sadre,et al.
Pakcs: The portland aachen kiel curry system
,
2000
.
[7]
Michael Hanus,et al.
Curry: an integrated functional logic language (version 0
,
2003
.
[8]
M. Hanus,et al.
Curry: An Integrated Functional Logic Language
,
2003
.