
Brian Hulley wrote:
Krzysztof Kościuszkiewicz wrote:
So the type of mapM_ used in the code is (Foldable t, Monad m) => (a -> m b) -> t a -> m ()
I'd like to keep the generic Foldable t there when "m" is specialized to IO. I thought this would allow type of "reversor" to be specialized to (Foldable f) => [String] -> f String ... I'd like to avoid [a] -> something -> [a]
Yes this type should be fine.
I should have said though that in your code, because one arm of the case construct returns Data.List.reverse, the type of reversor is fixed to [a] -> [a]. The other arm of the case construct could make use of a more general function eg reverseFoldable :: (Foldable f, Foldable g) => f a -> g a but it would only be used at f == [], g == []. So in terms of the command line test harness, I think the only way is to explicitly choose the foldable you want to try out eg by using (Foldable.toList . Seq.reverse . Seq.fromList) etc. An alternative might be to just write some different implementations of reverse functions in a module then load the module into ghci to test them out interactively so their types don't get unified with each other. Brian.