
The same declaration.- 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 = [(Address,Port)] update_table1::Table -> Pkg -> Table update_table1 [] (t,d,y) = [(t,d,y)] Error is Type error in explicitly typed binding *** Term : update_table1 *** Type : Table -> Pkg -> [(Pkgtype,Int,Payload)] *** Does not match : Table -> Pkg -> Table Please kindly suggest, thanks in advance. -- View this message in context: http://www.nabble.com/Please-help-from-a-newby-tf4740192.html#a13555338 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

type Pkg = (Pkgtype,Address,Payload) type Table = [(Address,Port)]
update_table1::Table -> Pkg -> Table update_table1 [] (t,d,y) = [(t,d,y)]
The problem is that your function's type signature says it's returning a Table, which is a [(Address,Port)], but it's actually returning a [(Pkgtype,Address,Payload)]

On 11/2/07, karle
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 = [(Address,Port)] ^^^^^^^^^^^^^^ Two elements
update_table1::Table -> Pkg -> Table update_table1 [] (t,d,y) = [(t,d,y)] ^^^^^^^ Three elements
So there's the error. You probably want to return something like [(a,p)] where a is an address and p is a port. I'm trying to figure out where you would get that information though. If your payload (the "y" parameter in your implementation) is RTDP then you have _two_ addresses (the "d" parameter and the one in the payload), so I wouldn't know which one to use, and if your payload is a UP then I don't know where you would get a port. On the other hand, I haven't the slightest clue what you're trying to implement, I was just trying to figure it out based on the types :-) Luke

Karle,
The expression (t,d,y) must have type Pkg, by your type annotation for
update_table1, so [ (t,d,y) ] has type [Pkg]. Also by your type
annotation, the result of update_table1 should by of type Table. Is
the type [Pkg] compatible with type Table? In other words, is the type
[ (Pkgtype,Address,Payload) ] the same as the type [ (Address,Port) ]?
Judging from your questions yesterday and today, I suspect that you
have not worked carefully through a Haskell language tutorial. I would
not discourage you from asking questions on the mailing list, but I
would strongly encourage you to consider referring to some of the
resources at http://haskell.org/haskellwiki/Books_and_tutorials before
trying to proceed with whatever programming project you are working
on.
Regards,
Chris
On 11/2/07, karle
The same declaration.-
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 = [(Address,Port)]
update_table1::Table -> Pkg -> Table update_table1 [] (t,d,y) = [(t,d,y)]
Error is
Type error in explicitly typed binding *** Term : update_table1 *** Type : Table -> Pkg -> [(Pkgtype,Int,Payload)] *** Does not match : Table -> Pkg -> Table
Please kindly suggest, thanks in advance.
-- View this message in context: http://www.nabble.com/Please-help-from-a-newby-tf4740192.html#a13555338 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (4)
-
Andrew Wagner
-
Christopher L Conway
-
karle
-
Luke Palmer