[Haskell-cafe] Wheres this going wrong

Udo Stenzel u.stenzel at web.de
Wed Mar 22 13:38:06 EST 2006

Neil Rutland wrote:
> ttyyppee LLiinnee == [[((((SSttrriinngg,,SSttrriinngg)),,((SSttrriinngg,,IInntt)),,((SSttrriinngg,,IInntt)),,((SSttrriinngg,,BBooooll)),,
> ((SSttrriinngg,,BBooooll)),,((SSttrriinngg,,BBooooll)),,((SSttrriinngg,,BBooooll)),,((SSttrriinngg,,BBooooll)),,((SSttrriinngg,,BBooooll)),,
> ((SSttrriinngg,,BBooooll)),,((SSttrriinngg,,BBooooll)),,((SSttrriinngg,,BBooooll))))]]

What's wrong with a record?

*> data Line = Line { a1 :: String, a2 :: Int, ... }

While you're at it, you might want to give the fields sensible names.

> Anyway when i enter something such as lookup "a1" i get back a load of stuff
> about Eq.....

lookup expects a list of pairs, but you're passing it a tuple.  A list
would have to be homogenous, your tuple isn't, therefore lookup cannot
do what you want.  Just use a record.

Languages shape the way we think, or don't. -- Erik Naggum
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060322/830ca536/attachment.bin

More information about the Haskell-Cafe mailing list