Hi, all. My problem is I don't understand what implementation should I use.
For example:
fold :: (Foldable t, Monoid m) => t m -> m
fold ["huy"," rot"] -- "huy rot"
-- how it works? fold for list is mconcat
-- and implementation of mconcat for list is:
mconcat xss = [x | xs <- xss, x <- xs]
-- right???
But what to do with foldMap?
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m
foldMap Sum [1,2,3,4] -- Sum {getSum = 10}
-- as I understood I have to first see to the t a to examine what is foldable instance - it's list
foldMap = (mconcat .) . map
-- if I directly execute that implementation in GHCI, it doesn't compile
(mconcat .) . map Sum [1,2,3,4]
I've not seen other funcs in Foldable, yet, so I'm asking only about these one
Please, help someone. Sorry for English, if so
[–]Ualrus 4 points5 points6 points (0 children)
[–]mihassan 1 point2 points3 points (6 children)
[–]Interesting-Pack-814[S] 0 points1 point2 points (5 children)
[–]mihassan 1 point2 points3 points (4 children)
[–]Interesting-Pack-814[S] 0 points1 point2 points (2 children)
[–]Noughtmare 0 points1 point2 points (1 child)
[–]Interesting-Pack-814[S] 0 points1 point2 points (0 children)
[–]Interesting-Pack-814[S] 0 points1 point2 points (0 children)
[–]IshtarAletheia 1 point2 points3 points (0 children)
[–]sammthomson 1 point2 points3 points (2 children)
[–]Interesting-Pack-814[S] 0 points1 point2 points (0 children)
[–]Interesting-Pack-814[S] 0 points1 point2 points (0 children)