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

zaxis z_axis at 163.com
Sat Mar 27 02:33:48 EDT 2010


>>Why do you bother with the interior definition of f in there? 
Because i want to try a C code style not layout style without `do` syntax
sugar .


Yusaku Hashimoto wrote:
> 
>>> 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
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 


-----
fac n = let {  f = foldr (*) 1 [1..n] } in f 
-- 
View this message in context: http://old.nabble.com/Why-is-it-so-different-between-6.12.1-and-6.10.4_1---tp28049329p28050543.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list