2

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?

Helmut Grohne
  • 6,578
  • 2
  • 31
  • 67
  • 4
    [base-compat](https://hackage.haskell.org/package/base-compat) – cchalmers Jul 03 '15 at 17:15
  • 1
    Note that since `toList` becomes a method of `Foldable`, `base-compat` chooses to not define it and thus `toList` is missing in `Prelude.Compat` but available in a recent `Prelude`. – Helmut Grohne Jul 03 '15 at 17:33

0 Answers0