>> fac n = let { f = foldr (*) 1 [1..n] } in f
>
> Why do you bother with the interior definition of f in there?
>
> fac = product . enumFromTo 1
let fac = do is_zero <- (==0); if is_zero then return 1 else liftM2
(*) id (fac . pred)
-nwn
On Sat, Mar 27, 2010 at 9:59 AM, Ivan Lazar Miljenovic
<[email protected]> wrote:
> zaxis <[email protected]> writes:
>> In 6.10.4_1 under freebsd
>>> let f x y z = x + y + z
>> *Money> :t f
>> f :: (Num a) => a -> a -> a -> a
>>
>>> :t (>>=) . f
>> (>>=) . f :: (Monad ((->) a), Num a) => a -> ((a -> a) -> a -> b) -> a -> b
>>> ((>>=) . f) 1 (\f x -> f x) 2
>>
>> <interactive>:1:1:
>> No instance for (Monad ((->) a))
>> arising from a use of `>>=' at <interactive>:1:1-5
>> Possible fix: add an instance declaration for (Monad ((->) a))
>> In the first argument of `(.)', namely `(>>=)'
>> In the expression: ((>>=) . f) 1 (\ f x -> f x) 2
>> In the definition of `it': it = ((>>=) . f) 1 (\ f x -> f x) 2
>>
>
> Some definitions and exports got changed, so in 6.12 the (-> a) Monad
> instance is exported whereas in 6.10 it isn't.
>
>> fac n = let { f = foldr (*) 1 [1..n] } in f
>
> Why do you bother with the interior definition of f in there?
>
> fac = product . enumFromTo 1
>
> --
> Ivan Lazar Miljenovic
> [email protected]
> IvanMiljenovic.wordpress.com
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe