[Haskell-beginners] Conciseness question

Ertugrul Soeylemez es at ertes.de
Sun Aug 7 15:21:13 CEST 2011


Manfred Lotz <manfred.lotz at arcor.de> wrote:

> In Lua I could do something like this:
>
> -- initialize empty table
> P = {}
>
> P.a = "bla1"
> P.b = "bla2"
>
> and so on.
>
> Now I can refer to each value by name, and I also can easily iterate
> over the table P.
>
> How can I do something similar in Haskell. Note: I do want only write
> each variable one time (or two times if I count the type definition).

I think you're not actually asking for record types at all, because that
doesn't really fit into Haskell's type system.  Rather you may want to
have a look at maps.  See the Data.Map module.  Those are dictionaries
with fast update and lookup as well as traversal operations.


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/





More information about the Beginners mailing list