
On 2009 Mar 28, at 0:59, Jeff Lasslett wrote:
myGroupBy :: (a -> a -> Bool) -> [a] -> [[a]] myGroupBy p xs = foldr step [[]] xs where -- step :: a -> [ [ a ] ] -> [ [ a ] ] step x acc@( ys : yss ) | null ys = [ x ] : [] | p x ( head ys ) = ( x : ys ) : yss | ( p x ( head ys ) ) == False = [ x ] : acc
In Haskell98, the type "a" in step is not the same as the one in myGroupBy. If you use the ScopedTypeVariables extension (see the ghc manual; just adding the option won't work) you can write the type. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH