Could someone explain winhugs does not accept this argument?

type Address = Int data Port = C | D deriving(Eq,Show) data Payload = UP[Char] | RTDP(Address,Port) deriving(Eq,Show) data Pkgtype = RTD | U deriving(Eq,Show) type Pkg = (Pkgtype,Address,Payload) type Table = Signal (Address,Port) system inA inB = (outC,outD) where route = update_pr inA inB s1 = lookup_pr route inA s2 = lookup_pr route inB (s3,s4) = unzipSY s1 (s5,s6) = unzipSY s2 s7 = add_list_pr s3 s5 s8 = add_list_pr s4 s6 outC = fifoSY s7 outD = fifoSY s8 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)) the error message is Type error in application *** Expression : delive_adr_A t *** Term : t *** Type : Signal Table *** Does not match : Signal (Int,Port) -- View this message in context: http://www.nabble.com/Could-someone-explain-winhugs-does-not-accept-this-arg... Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

...
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) or newtype Table = Table AddressPort deriving(Eq,Show) - marc
participants (2)
-
karle
-
Marc A. Ziegert