[Haskell-cafe] Increasing number of parameters

Jacek Generowicz jacek.generowicz at cern.ch
Fri Oct 15 05:38:43 EDT 2010

Thanks Brandon!

I really like the addParam utility,

> value val prompt = Question prompt (show val) (readCheck val)
> addParam :: (Show a) => (funTy -> String -> qty) -> (a -> funTy) ->  
> String -> (a
> -> qty)
> addParam qmakr fun string v = qmakr (fun v) (string++" "++show v)
> prefix1 = addParam value
> prefix2 = addParam prefix1
> prefix3 = addParam prefix2

but my crusty and sleep-deprived brain is not really grokking the  
internal plumbing.

So I'm trying to get to grips with a simpler variation on the same  
theme, and I'm still failing. I'm trying to write something along the  
lines of

addArg :: nArgFn -> a -> nPlus1ArgFn
addArg fn a = (a+) <---- fn where
     <---- = something which applies its right parameter to however  
many arguments it needs and feeds the result to the left parameter

in order to allow me to say

sum2 = (+)
sum3 = addArg sum2
sum4 = addArg sum3


More information about the Haskell-Cafe mailing list