# [Haskell-cafe] Why is it so different between 6.12.1 and 6.10.4_1 ?

Yusaku Hashimoto nonowarn at gmail.com
Fri Mar 26 21:22:10 EDT 2010

```>> 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
<ivan.miljenovic at gmail.com> wrote:
> zaxis <z_axis at 163.com> 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
> Ivan.Miljenovic at gmail.com
> IvanMiljenovic.wordpress.com
> _______________________________________________
> Haskell-Cafe mailing list