Library report examples

Ian Lynagh igloo@earth.li
Tue, 27 Nov 2001 20:04:24 +0000


Simon,

On Tue, Nov 27, 2001 at 02:28:45AM -0800, Simon Peyton-Jones wrote:
> 
> | I am also curious why, for example,
> | 
> |   row :: (Ix a, Ix b) => a -> Array (a,b) c -> Array b c
> |   row i x = ixmap (l',u') (\j->(i,j)) x where ((l,l'),(u,u')) 
> | = bounds x
> | 
> | isn't written as
> | 
> |   row :: (Ix a, Ix b) => a -> Array (a,b) c -> Array b c
> |   row i x = ixmap (l,u) (\j->(i,j)) x where ((_,l),(_,u)) = bounds x
> |                    ~~~                        ~~~   ~~~
> 
> you can write it either way

I agree that the two are equivalent definitions, I just find the latter
style easier to follow. Similarly I would write
"new_is = map fst new_ivs" rather than
"new_is = [i | (i,_) <- new_ivs]" - maybe this is just a personal taste
thing. Certainly not worth quibbling over at any rate  :-)


Another one for you: In 10.3 (Monad, Functions) the listFile example
uses openFile where it means readFile.

Another minor quibble: the use of brackets around contexts isn't
consistent within the Monad section (haven't looked at the others).


Thanks
Ian