| The library report defines
| 
|   -- Diagonal of a square matrix
|   diag :: (Ix a) => Array (a,a) b -> Array a b
|   diag x = ixmap (l,u) (\i->(i,i)) x
|    where ((l,l'),(u,u')) | l == l' && u == u'  = bounds x

And that is indeed a stupid definition.  It's like saying

        x = if x>2 then 1 else 10

(the guard is really just an 'if'.)  So of course l, u etc are all
bottom.  

The guard needs to be on diag itself
   diag x | l==l' && u==u' = ixmap ...as before
                            where
                               ((l,l'),(u,u')) = bounds x

thanks for pointing this out

| 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

S

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to