Is there a simple way to emulate the burning bridges proposal (also called foldable/traversable proposal, part of GHC 7.10) on GHC 7.8 or possibly older?
Some aspects are genuinely hard to emulate. This includes the changing in class hierarchies. Most likely, that part cannot be emulated.
New functions and function replacements can simply be imported from Data.Foldable
and friends. Yet, functions such as length
or null
are not available with the new type signatures. The following snippet achieves some aspects of pretending burning bridges:
import Prelude hiding (elem, foldr, length, maximum, null)
import Data.Foldable (Foldable, elem, foldMap, foldr, maximum, toList)
import Data.Traversable (Traversable, traverse)
length :: Foldable t => t a -> Int -- will become a method of Foldable
length = Data.Foldable.foldl' (\c _ -> c + 1) 0
null :: Foldable t => t a -> Bool -- will become a method of Foldable
null = foldr (\_ _ -> False) True
Is there some package that does this in a more complete way?