
On Tue, May 13, 2008 at 12:48 PM, Paul Johnson
$ pointfree "\xs -> foldl' (+) 0 xs / fromIntegral (length xs)" ap ((/) . foldl' (+) 0) (fromIntegral . length)
But when I try this in GHCi 6.8.2 I get:
Prelude Data.List Control.Monad> let mean2 = ap ((/) . foldl' (+) 0) (fromIntegral . length)
<interactive>:1:12: No instance for (Monad ((->) [b])) arising from a use of `ap' at <interactive>:1:12-58 Possible fix: add an instance declaration for (Monad ((->) [b])) In the expression: ap ((/) . foldl' (+) 0) (fromIntegral . length) In the definition of `mean2': mean2 = ap ((/) . foldl' (+) 0) (fromIntegral . length)
It's using the Monad ((->) r) instance, which doesn't exist by default. import Control.Monad.Instances to get it. Luke