[Haskell-beginners] Conciseness question

Michael Snoyman michael at snoyman.com
Sun Aug 7 15:17:29 CEST 2011


I was just glancing through that chapter when I saw the phrase
"Paamayim Nekudotayim." I was most certainly not expecting Hebrew
phrases to pop up here. Has this phrase somehow made it into a larger
circle without my knowing, or is there some explanation out there as
to why it's used in LYAH?

On Sun, Aug 7, 2011 at 4:10 PM, Thiago Negri <evohunz at gmail.com> wrote:
> Hey Manfred.
>
> Take a look at "Record Syntax" topic of the book "Learn you a Haskell
> for great good". It looks like what you want.
>
> http://learnyouahaskell.com/making-our-own-types-and-typeclasses#record-syntax
>
> Thiago.
>
> 2011/8/7 Manfred Lotz <manfred.lotz at arcor.de>:
>> Hi all,
>> 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 thought about:
>>
>> data P = P {
>>     a :: String,
>>     b :: String
>> }
>>
>> Then I have one definition
>>
>> pval = P {
>>   a = "bla1",
>>   b = "bla2"
>> }
>>
>> Now I could refer to each val easily, e.g. a pval. However, I don't see
>> that I could iterate over the members of pval.
>>
>>
>> It there a way to do what I want without defining a list like this?
>> pls p = [ (a p), (b p)]
>>
>> Perhaps a comletely different way?
>>
>>
>>
>> --
>> Manfred
>>
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>



More information about the Beginners mailing list