[Haskell-cafe] I am having trouble with the type declaration for creating an identity matrix.

Kevin Charter kcharter at gmail.com
Wed Apr 25 00:21:48 CEST 2012


On Tue, Apr 24, 2012 at 3:20 PM, KC <kc1956 at gmail.com> wrote:

> initIdentityMat :: Int -> ST s (STUArray s (Int,Int) ((Int, Int), Double))
> initIdentityMat m = newListArray ((1,m),(1,m)) ([((i,j), if i == j then
> 1.0 else 0.0) | i <- [1..m], j <- [1..m]] :: [((Int,Int), Double)])
>
> Doesn't seem to compile, nor do minor variations of the type declaration.
>

If you use Hoogle to find the type and API docs for 'newListArray', I
believe you'll be able to figure out what's wrong, but I'll give you a
hint. The list you're giving to 'newListArray' contains too much; and the
pair you give it is only half correct.

Kevin

-- 
Kevin Charter
kevin.charter at acm.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120424/b0337ac8/attachment.htm>


More information about the Haskell-Cafe mailing list