Re: [Haskell-cafe] Function composition questions from a newbie

2009-12-01 Thread Daniel Fischer
Am Dienstag 01 Dezember 2009 10:32:24 schrieb newbie2009: > leledumbo wrote: > > None of them are legal, at least in my WinHugs they're not. What tools > > are you using? > > 1) I am using GHCi. I put the following into a file named composition.hs > and typed ":l composition.hs" in GHCi. I also did

Re: [Haskell-cafe] Function composition questions from a newbie

2009-12-01 Thread newbie2009
leledumbo wrote: > > None of them are legal, at least in my WinHugs they're not. What tools are > you using? > 1) I am using GHCi. I put the following into a file named composition.hs and typed ":l composition.hs" in GHCi. I also did a ":browse Main" 2) Next, I installed WinHugs, and loaded th

Re: [Haskell-cafe] Function composition questions from a newbie

2009-12-01 Thread leledumbo
> I dont understand why the above functions are legal, and what arguments they need. Could you please > give an example of how to invoke it? Huh? None of them are legal, at least in my WinHugs they're not. What tools are you using? Some good reading I found: http://learnyouahaskell.com/higher-or

Re: [Haskell-cafe] Function composition questions from a newbie

2009-12-01 Thread newbie2009
I am a newbie. Consider this code: square x = x * x add3 x y z = x + y + z leledumbo wrote: > > > what about (square . add3) 1 2? > > It doesn't work since add3, when curried (arguments of square "blended" > with add3's) with 1 argument becomes: > > add3 :: Num a => a -> a -> a > > whic

Re: [Haskell-cafe] Function composition questions from a newbie

2009-11-30 Thread leledumbo
> This doesnt. But why? Back to the definition of function composition: f . g is possible if g returns a value that's compatible with f's argument. Now, let's check the type of square and add3: square :: Num a => a -> a add3 :: Num a => a -> a -> a -> a (square . add3 1 2) is actually seen by t

Re: [Haskell-cafe] Function composition questions from a newbie

2009-11-30 Thread muad
newbie2009 wrote: > > I am a newbie. Consider this code: > > square x = x * x > add3 x y z = x + y + z > add x y = x + y > composition5 x = (square . add3) x > composition6 x y = (square . add3) x y > > 1) What arguments can i pass to composition5? Please give an example of > calling it. > 2