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]

[hidden email]
system administrator [openafs,heimdal,too many hats]

[hidden email]
electrical and computer engineering, carnegie mellon university KF8NH

-------------- next part --------------

A non-text attachment was scrubbed...

Name: PGP.sig

Type: application/pgp-signature

Size: 195 bytes

Desc: This is a digitally signed message part

Url :

http://www.haskell.org/pipermail/beginners/attachments/20090328/9849f6ad/PGP.bin