On Wed, 11 Jun 2008, Isaac Dupree wrote:

"extractHead" is an ugly name for a nevertheless standardish-meaning function... what is it usually called? uncons? headTail? (Data.Sequence, which is meant to be left-right symmetric, calls it "viewr"... except your version doesn't have the Maybe, it's partial instead, fails on empty lists)

I like the 'viewL' and 'viewR' kind of functions, they are safer than 'head' and 'tail', 'init' and 'last'. But since in most cases I used 'viewL' in connection with 'maybe', the continuation style functions

switchL :: b -> (a -> Seq a -> b) -> Seq a -> b
switchR :: b -> (Seq a -> a -> b) -> Seq a -> b

are even more convenient. They replace 'case' on those structures where you do not have access to the constructors.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to