[Haskell-cafe] Problem using ap -- No instance for (Monad ((->) [[a]]))

Jim Burton jim at sdf-eu.org
Fri Jul 6 11:12:27 EDT 2007


If I try  a function to make a point-free version of the function in this
fold --

foldr (\x ys -> ys ++ map (x:) ys) [[]]

:pl gives me

GOA Control.Monad> :pl (\x ys -> ys ++ map (x:) ys)
 ap (++) . map . (:)
GOA Control.Monad> :t  ap (++) . map . (:)
ap (++) . map . (:) :: (Monad ((->) [[a]])) => a -> [[a]] -> [[a]]

but this is what happens if I try to use it:

GOA Control.Monad> let ps = foldr (ap (++) . map . (:)) [[]]

<interactive>:1:16:
    No instance for (Monad ((->) [[a]]))
      arising from use of `ap' at <interactive>:1:16-22
    Possible fix: add an instance declaration for (Monad ((->) [[a]]))
    In the first argument of `(.)', namely `ap (++)'
    In the first argument of `foldr', namely
        `((ap (++)) . (map . (:)))'
    In the expression: foldr ((ap (++)) . (map . (:))) [[]]
(0.00 secs, 0 bytes)

What gives?



-- 
View this message in context: http://www.nabble.com/Problem-using-ap----No-instance-for-%28Monad-%28%28-%3E%29---a--%29%29-tf4036243.html#a11466625
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list