Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Creating arrays in Haskell (Karol Samborski)
2. Re: Creating arrays in Haskell (Michal Kawalec)
3. Re: Creating arrays in Haskell (Karol Samborski)
4. Re: Creating arrays in Haskell (Michal Kawalec)
----------------------------------------------------------------------
Message: 1
Date: Wed, 2 Oct 2013 12:11:15 +0200
From: Karol Samborski <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Creating arrays in Haskell
Message-ID:
<cace2dtsg2us7fjrhgzvbmiju8_ybu8hrgc1gorgq4jgdhyf...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
2013/10/2 Michal Kawalec <[email protected]>
> Hello,
>
> I want to use the FFT library in Haskell and for that I need to create
> an array. However, when I input
>
> array (1,100) [(i, i*i) | i <- [1..100]]
>
>
Hi Michal,
I think you should just add type signature to the [1..100], like this:
array (1,100) [(i, i*i) | i <- ([1..100]::[Int])]
Best,
Karol
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131002/1e90a5d3/attachment-0001.html>
------------------------------
Message: 2
Date: Wed, 02 Oct 2013 11:26:36 +0100
From: Michal Kawalec <[email protected]>
To: beginners <[email protected]>
Subject: Re: [Haskell-beginners] Creating arrays in Haskell
Message-ID: <1380709513-sup-5707@carrot>
Content-Type: text/plain; charset="utf-8"
Excerpts from Karol Samborski's message of 2013-10-02 11:11:15 +0100:
> I think you should just add type signature to the [1..100], like this:
> array (1,100) [(i, i*i) | i <- ([1..100]::[Int])]
Thank you, it seems that it worked, but with my limited knowledge of
Haskell I stumbled onto another problem:
Prelude Data.List Math.FFT Data.Array.CArray Data.Array.Base> array (1,100)
[(i, i*i) | i <- [1..100]::[Int]]
<interactive>:74:1:
No instance for (IArray a0 Int) arising from a use of `array'
The type variable `a0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there are several potential instances:
instance Foreign.Storable.Storable e => IArray CArray e
-- Defined in `Data.Array.CArray.Base'
instance IArray Array e -- Defined in `Data.Array.Base'
instance IArray UArray Int -- Defined in `Data.Array.Base'
Possible fix: add an instance declaration for (IArray a0 Int)
In the expression:
array (1, 100) [(i, i * i) | i <- [1 .. 100] :: [Int]]
In an equation for `it':
it = array (1, 100) [(i, i * i) | i <- [1 .. 100] :: [Int]]
--
Michal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131002/cd251b5c/attachment-0001.sig>
------------------------------
Message: 3
Date: Wed, 2 Oct 2013 12:43:14 +0200
From: Karol Samborski <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Creating arrays in Haskell
Message-ID:
<CACe2dTtAbH9N5+LJXVV3514N0hRpaga2qx8X=g6zzjkvbgc...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
2013/10/2 Michal Kawalec <[email protected]>
> Excerpts from Karol Samborski's message of 2013-10-02 11:11:15 +0100:
> > I think you should just add type signature to the [1..100], like this:
> > array (1,100) [(i, i*i) | i <- ([1..100]::[Int])]
>
> Thank you, it seems that it worked, but with my limited knowledge of
> Haskell I stumbled onto another problem:
>
> Prelude Data.List Math.FFT Data.Array.CArray Data.Array.Base> array
> (1,100) [(i, i*i) | i <- [1..100]::[Int]]
>
> <interactive>:74:1:
> No instance for (IArray a0 Int) arising from a use of `array'
> The type variable `a0' is ambiguous
> Possible fix: add a type signature that fixes these type variable(s)
> Note: there are several potential instances:
> instance Foreign.Storable.Storable e => IArray CArray e
> -- Defined in `Data.Array.CArray.Base'
> instance IArray Array e -- Defined in `Data.Array.Base'
> instance IArray UArray Int -- Defined in `Data.Array.Base'
> Possible fix: add an instance declaration for (IArray a0 Int)
> In the expression:
> array (1, 100) [(i, i * i) | i <- [1 .. 100] :: [Int]]
> In an equation for `it':
> it = array (1, 100) [(i, i * i) | i <- [1 .. 100] :: [Int]]
>
>
> --
> Michal
>
>
This is because ghci doesn't know which instance of IArray to use. If you
look at type signature of function 'array' you'll see that it returns some
type 'a i e' where 'a e' is an instance of IArray class. So what you must
do is simply tell it what 'a i e' you want. Try this:
array (1,100) [(i, i*i) | i <- [1..100]] :: CArray Int Int
Best,
Karol
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131002/757f51f8/attachment-0001.html>
------------------------------
Message: 4
Date: Wed, 02 Oct 2013 11:45:58 +0100
From: Michal Kawalec <[email protected]>
To: beginners <[email protected]>
Subject: Re: [Haskell-beginners] Creating arrays in Haskell
Message-ID: <1380710720-sup-1210@carrot>
Content-Type: text/plain; charset="utf-8"
Excerpts from Karol Samborski's message of 2013-10-02 11:43:14 +0100:
> This is because ghci doesn't know which instance of IArray to use. If you
> look at type signature of function 'array' you'll see that it returns some
> type 'a i e' where 'a e' is an instance of IArray class. So what you must
> do is simply tell it what 'a i e' you want. Try this:
>
> array (1,100) [(i, i*i) | i <- [1..100]] :: CArray Int Int
Thank you for that explanation, it worked.
--
Michal
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20131002/04782507/attachment-0001.sig>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 64, Issue 5
****************************************