ABSTRACT
This paper introduces a language feature, called implicit parameters, that provides dynamically scoped variables within a statically-typed Hindley-Milner framework. Implicit parameters are lexically distinct from regular identifiers, and are bound by a special with construct whose scope is dynamic, rather than static as with let. Implicit parameters are treated by the type system as parameters that are not explicitly declared, but are inferred from their use.
We present implicit parameters within a small call-by-name λ-calculus. We give a type system, a type inference algorithm, and several semantics. We also explore implicit parameters in the wider settings of call-by-need languages with overloading, and call-by-value languages with effects. As a witness to the former, we have implemented implicit parameters as an extension of Haskell within the Hugs interpreter, which we use to present several motivating examples.
- 1.BENTON, N. A mixed linear and non-linear logic: Proofs, terms and models. Tech. Rep. 352, University of Cambridge Computer Laboratory, Oct. 1994.Google Scholar
- 2.GARRIGUE, J. Dynamic binding and lexical binding in a transformation calculus. In Proc. of the Fuji International Workshop on Functional and Logic Programming. (1995). Google ScholarDigital Library
- 3.GARRIGUE, J., AND KACI, H. The Typed Polymorphic Label-Selective Lambda-Calculus. In Conference Record of POPL '94: 21st A GM SIGPLAN-SIGA GT Symposium on Principles of Programming Languages (Portland, Oregon, 1994). Google ScholarDigital Library
- 4.HANSON, C. MIT Scheme Reference. Cambridge, MA: MIT Press, Apr. 96.Google Scholar
- 5.JONES, M. P. Qualified Types: Theory and Practice. Cambridge University Press, Cambridge, England, 1994. Google ScholarDigital Library
- 6.JONES, M. P. Exploring the design space for typebased implicit parameterization. Tech. rep., Oregon Graduate Institute, July 1999.Google Scholar
- 7.JONES, M. P. Type classes with functional dependencies, Oct. 1999. (Submitted for publication).Google Scholar
- 8.JONES, M. P., AND PETERSON, J. C. Hugs 98 user manual, http://~--~.haskell, org/hugs/, May 1999.Google Scholar
- 9.KING, D. J., AND LAUNCHBUI~~, J. Structuring depthfirst search algorithms in Haskell. In A CM Symposium on Principles of Programming Languages (San Francisco, California, Jan. 1995), pp. 344-354. Google ScholarDigital Library
- 10.LIANG, S. The Java Native Interface (Programmer's guide and Specification). The Java Series. Addison Wesley, 1999. Google ScholarDigital Library
- 11.MEIJER, E., AND CLAESSEN, K. The design and implementation of Mondrian. In Proceedings o/the HaskeU Workshop (1997).Google Scholar
- 12.MILNER, R., TOFTE, M:, HARPER, R., AND MAC- QUEEN, I). The Definition of Standard ML- Revised. The MIT Press, 1997. Google ScholarDigital Library
- 13.ODERSKY, M., WADLER, P., AND WEHR, M. A second look at overloading. In Proceedings of the 1995 Conference on Functional Programming Languages and Computer Architecture (San Diego, CMifornia, June 1995), ACM Press. Google ScholarDigital Library
- 14.PEYTON JONES, S., AND HUGHES, J. Haskell 98: A non-strict, purely functional language. http ://haskell. cs. yale. edu/onlinereport/, Jan. 1999.Google Scholar
- 15.REMY, D. Typechecking records and variants in a natural extension of ML. In Conference Record of fhe Sixteenth Annual A CM Symposium on Principles of Programming Languages (Austin, Texas, Jan. 1989). Google ScholarDigital Library
- 16.WADLER, P., AND BLOTT, S. How to make ad-hoc polymorphism less ad hoc. In Conference Record of the Sixteenth Annual A CM Symposium on Principles of Programming Languages (1989). Google ScholarDigital Library
Index Terms
- Implicit parameters: dynamic scoping with static types
Recommendations
Simplicitly: foundations and applications of implicit function types
Understanding a program entails understanding its context; dependencies, configurations and even implementations are all forms of contexts. Modern programming languages and theorem provers offer an array of constructs to define contexts, implicitly. ...
Implicit Parameters for Logic Programming
PPDP '18: Proceedings of the 20th International Symposium on Principles and Practice of Declarative ProgrammingImplicit parameters allow programmers to omit certain arguments from function calls and have them automatically inferred by the compiler based on their types. At every call site, the compiler determines the values of the implicit parameters based on ...
Comments