On Thu, 12 Jun 2008, Isaac Dupree wrote:

Henning Thielemann wrote:

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

I think you got L and R backwards?

Why do you think so?

http://cvs.haskell.org/Hugs/pages/libraries/base/Data-Sequence.html#v%3Aviewl

it's a little confusing to me, but following Data.Sequence I think they're meant to match whether repeated L or R makes a foldl or a foldr.

viewl is like a 'case' for distinction of [] and (:) and thus can be used to implement both foldl and foldr.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to