[Haskell-cafe] Implicit parameters and Arrows/Yampa?

Derek Elkins derek.a.elkins at gmail.com
Sun Jan 6 17:35:31 EST 2008

On Sun, 2008-01-06 at 23:44 +0100, Peter Verswyvelen wrote:
> If I understand it correctly, implicit parameters in Haskell allow you
> to pass values to functions with explicitly adding a parameter to each
> of the functions being “called” (I appologize for my imperative
> terminology here. How would I say this correctly? Being “evaluated”?)

No one is going to get upset if you use "call", but if you'd like, the
more technical term in this context is "applied", instead of "call f
passing x", we would say "apply f to x".

> The arrows always use tuples to group the input and output parameters,
> like:
> foo :: SF (Int,Int,Int) (Int,Int)
> foo = proc (x,y,z) -> do
>    p <- cat -< (x,y)
>    q <- dog -< z
>    returnA -< (p,q)
>      where
>        cat = proc (x,y) -> returnA -< (x+y)
>        dog = proc z -> returnA -< 10*z
> Suppose I don’t want to explicitly pass the x and y parameters to the
> cat (and deeper) arrows, but make them implicit. I guess that would be
> impossible? I mean, I can’t use implicit parameters language extension
> to make the arrow input parameters implicit?

Implicit parameters add an extra argument to a function conceptually.
What you need is to "add an argument" to "SF" which implicit parameters
don't know how to do since SF is just some data structure.  One way to
deal with this is the way you deal with the same problem in Haskell
without implicit parameters. (I never use implicit parameters).  In that
case you would use the Reader monad (transformer).  Similarly, you can
use an equivalent Reader/Environment arrow transformer.

More information about the Haskell-Cafe mailing list