Quantcast

Beginners Question: Problem with Data Type Declaration

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Beginners Question: Problem with Data Type Declaration

kaffeepause73
I try to create an own data type containing "Vector Double" from the H-Matrix package. The code:

##

data PowerSig = PowerSig Int Double Vector Double

main = do
let p5 = PowerSig 1 0.1 (fromList [1,2,3])

##

When compiling with ghci, I get however the following message:

    `Vector' is not applied to enough type arguments
    Expected kind `?', but `Vector' has kind `* -> *'
    In the type `Vector'
    In the definition of data constructor `PowerSig'
    In the data type declaration for `PowerSig'

I don't understand the compilers message and couldn't find any wiki-page/other material to help me.
The Data Declaration somehow seems not to understand that "Vector Double" belongs together, but brackets don't help either.

Cheers Phil

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Beginners Question: Problem with Data Type Declaration

Johan Tibell-2
Hi,

On Thu, Jun 16, 2011 at 9:53 AM, kaffeepause73 <[hidden email]> wrote:
> I try to create an own data type containing "Vector Double" from the H-Matrix
> package. The code:
>
> ##
>
> data PowerSig = PowerSig Int Double Vector Double

You need to put parenthesis around (Vector Double). Otherwise this is
interpreted as a constructor with 4 fields (instead of 3).

Johan

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Beginners Question: Problem with Data Type Declaration

kaffeepause73
Hi Johan,

actually quite obvious. Code works now, many thanks. :-)


import Data.Packed.Vector

data PowerSig = PowerSig Int Double (Vector Double) -- signal Index timeStep data

instance Show PowerSig where  
  show (PowerSig idx dt vector) = "PowerSignal Nr: " ++ show idx ++ "  dt: " ++ show dt ++ " val:" ++ show vector    
 
main = do

        let p = PowerSig 5 0.1 (fromList [0..10::Double])
        putStrLn (show p)
Loading...