
24 Sep
2015
24 Sep
'15
3:41 p.m.
David Moberg
This mail got stuck in my spam filter because of auth reason. Bumping in case someone else who missed it wants to answer.
2015-08-28 19:12 GMT+02:00 Williams, Wes(AWF)
: Hi haskellers,
I am trying to understand why I get the following error in learning applicative style.
Prelude> let estimates = [5,5,8,8,2,1,5,2]
Prelude> (/) <$> Just $ foldl (+) 0 estimates <*> Just . fromIntegral $ length estimates
I think $ is the culprit. You can not combine $ and <*> and get what you expect, because $ works on *the whole* expression: Prelude> (/) <$> Just (foldl (+) 0 estimates) <*> Just (fromIntegral (length estimates)) Just 4.5 Another problem was (.), you actually don't need any function composition here. -- CYa, ⡍⠁⠗⠊⠕