Talk:Haskell/Traversable

rejectWithNegatives actually needs just Foldable
"Using Foldable would replace the structure of the original list with that of whatever Monoid we pick for folding, and there is no way of twisting that into giving either the original list or Nothing."

This is incorrect; `rejectWithNegatives` is possible to implement using just Foldable:

rejectWithNegatives :: [Foldable t, Ord a, Num a] => t a -> Maybe (t a) rejectWithNegatives lst = foldr trampoline id lst (Just lst) where trampoline x bounce acc | x <= 0 = Nothing | otherwise = bounce acc

In order to properly motivate Traversable, we would need something where we require more general effect building. I can't think of one off the top of my head though. 209.133.79.5 (discuss) 00:26, 18 January 2020 (UTC) A concerned person at work


 * Well spotted, thank you. It is worth noting that the flaw in the example is specifically that, given the list is returned unchanged in case of success, we don't have to actually rebuild the structure, as we can cheat by slipping in the original list. This can be made explicit by refactoring your  as:




 * I will think about a better example (suggestions, as ever, are welcome). --Duplode (discuss • contribs) 01:44, 20 February 2020 (UTC)

Why Functor a constraint of Traverse?
Foldable I understand, but wouldn't it still work without the Functor constraint? &mdash;76.26.110.79 (discuss) 04:10, 27 April 2021 (UTC)

transpose exercise is too hard
Hi! I think the =transpose= exercise is too hard. There is a whole chapter about /understanding/ the solution in `Data.Traversable`. I do not think it is didactically useful to make readers solve this exercise when learning about `Traversable`.