[Haskell-cafe] Could someone explain winhugs does not accept this argument?

Marc A. Ziegert coeus at gmx.de
Sun Nov 4 00:08:21 EDT 2007

> type Table = Signal (Address,Port) 
> lookup_pr::Signal Table->AbstExt Pkg->AbstExt Pkg 
> lookup_pr t (Prst(x,y,z)) 
>     |(delive_adr_A t == y && x == U) = (Prst(x,y,z)) 
>     |otherwise = look_if_RTD_pkG_A t (Prst(x,y,z)) 
> Type error in application
> *** Expression     : delive_adr_A t
> *** Term           : t
> *** Type           : Signal Table
> *** Does not match : Signal (Int,Port)

when a "Table" is a "Signal (Address,Port)" then
what is a "Signal Table" ?

btw is this some sort of homework?
writing your mail should not have been easier than just reading the error message:

in the expression "delive_adr_A t" (look it up in your source)
there is that term "t" (which is a part of the expression);
"t" has the type "Signal Table" (why? look at its type definition in "lookup_pr::Signal Table->..."),
but in the expression it should have the type "Signal (Int,Port)".

so, now compare these two types. do "Signal Table" and "Signal (Int,Port)" equal? replace "Table" with its type alias from your sourcecode, and think about which type looks strange.

i don't want to be mean... but did you already attend a tutorial on haskell? to know the type of everything you write, is the key to eradicate bugs.

with the type system, you will write less runtime-bugs: just make them compile-time-bugs.
like this:

newtype Address = Address Int deriving(Eq,Show,Ord) -- or deriving(Eq,Show,Ord,Num)
data Port = C | D deriving(Eq,Show)
newtype AddressPort = AddressPort (Address,Port) deriving(Eq,Show)
data Payload = UP String | RTDP AddressPort deriving(Eq,Show)
data Pkgtype = RTD | U deriving(Eq,Show)
data Pkg = Pkg Pkgtype Address Payload
newtype Table = Table (Signal AddressPort)
newtype Table = Table AddressPort deriving(Eq,Show)

- marc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20071104/b0bf2cd5/attachment.bin

More information about the Haskell-Cafe mailing list