[Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1

Henning Thielemann lemming at henning-thielemann.de
Thu Jun 12 05:09:03 EDT 2008


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.



More information about the Haskell-Cafe mailing list