A number of people have discussed the use of implicit parameters to mimic global variables in Haskell. I am wondering if any have done the same for a first-class module system such as that proposed by Shields and Jones. It seems to make a tremendous amount of sense to do it that way: 1. semi-constant values: Things that are calculated or input at the beginning of the program could be handled by Main.main, which would pass the results to the Second module, whose main function it could then call. This seems much more natural than the implicit parameter approach for this purpose. 2. others: whenever a group of functions are likely to share a particular argument, they can be grouped in a module for greater convenience. For example, a library of mathematical functions that should all share a certain precision indicator could be grouped in a module: the user of the module could instantiate it once with the right precision and then use all the functions at that precision. David Feuer (please reply to dfeuer@cs.brown.edu)
David Feuer wrote:
A number of people have discussed the use of implicit parameters to mimic global variables in Haskell. I am wondering if any have done the same for a first-class module system such as that proposed by Shields and Jones. It seems to make a tremendous amount of sense to do it that way:
1. semi-constant values: Things that are calculated
aren't a problem unless they depend on something that's input at run-time.
or input at the beginning of the program could be handled by Main.main, which would pass the results to the Second module, whose main function it could then call. This seems much more natural than the implicit parameter approach for this purpose.
This approach could also solve the "here document" question. If we allow modules that define a value rather than names and are in a range of different syntaxes, we can import the value at the point of use. Having foreign values in files would allow things such as the import of a font metric file as a constant, which would be much nicer than reading it from a file and having to pass it around. Jón
On Tuesday 26 March 2002 17:31, you wrote: A number of people have discussed the use of implicit parameters to mimic global variables in Haskell. I am wondering if any have done the same for a first-class module system such as that proposed by Shields and Jones. It seems to make a tremendous amount of sense to do it that way:
1. semi-constant values: Things that are calculated or input at the beginning of the program could be handled by Main.main, which would pass the results to the Second module, whose main function it could then call. This seems much more natural than the implicit parameter approach for this purpose.
It seems nice for that *specific* purpose. What I like about implicit parameters is the fact that they are a more general approach, and that is IMO very important. You, might for instance, decide that maybe it would be a good idea to, under certain specific conditions, change one of those "semi-constant" values. Imagine some AI algortithm, you iterate some learning function 'learnF' over and over again. Now you realize that under certain conditions maybe the learning rate (used in learnF) should be changed. Chaging your implementation would be easy with implicit parameters. J.A.
participants (3)
-
Feuer -
Jon Fairbairn -
Jorge Adriano