[Haskell-cafe] Please help from a newby

Christopher L Conway cconway at cs.nyu.edu
Fri Nov 2 16:38:16 EDT 2007


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 <ph_kittichai at yahoo.com> wrote:
>
> 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


More information about the Haskell-Cafe mailing list