[Haskell-cafe] Please help from a newby

Luke Palmer lrpalmer at gmail.com
Fri Nov 2 16:34:13 EDT 2007

On 11/2/07, karle <ph_kittichai at yahoo.com> wrote:
> 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 :-)


More information about the Haskell-Cafe mailing list