Implicit Function Arguments

Tyson Whitehead twhitehead at
Sat Jun 28 12:32:30 EDT 2008

What do people think about implicit function argument?

That is, named function arguments, possibly tagged with something special like 
a tilde, whereby scoped variables of the same name are automatically passed.

The idea is to avoid the pain of a lots of pass through parameters while make 
it easy to modify one or two of them.  For example, in

f1 :: ~state::State -> Input -> Output
f1 input = f2 input

f2 :: ~state::State -> Input -> Output
f2 input = <whatever>

we don't have to specify ~state for f2 because it picks it up automatically 
from ~state being in scope from f1.  To change it, however, we just do

f1 :: ~state::State -> Input -> Output
f1 input = f2 input
  where ~state = <whatever>

The advantage over wrapping it in a monad being:

1) it is evident what is being passed around behind the scenes from the type 
signatures, and

2) we avoiding the lifting issue (to compose multiple implicit arguments we 
just specifying them -- assuming their are no name clashes).

Cheers!  -Tyson

More information about the Glasgow-haskell-users mailing list