Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Conciseness question (Manfred Lotz)
2. Re: Conciseness question (Thiago Negri)
3. Re: Conciseness question (Michael Snoyman)
4. Re: Conciseness question (Michael Snoyman)
5. Re: Conciseness question (Ertugrul Soeylemez)
6. Re: Conciseness question (Daniel Fischer)
7. Re: Conciseness question (Michael Snoyman)
8. Re: Conciseness question (Manfred Lotz)
9. Re: Conciseness question (Manfred Lotz)
----------------------------------------------------------------------
Message: 1
Date: Sun, 7 Aug 2011 13:25:48 +0200
From: Manfred Lotz <[email protected]>
Subject: [Haskell-beginners] Conciseness question
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
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
------------------------------
Message: 2
Date: Sun, 7 Aug 2011 10:10:04 -0300
From: Thiago Negri <[email protected]>
Subject: Re: [Haskell-beginners] Conciseness question
To: Manfred Lotz <[email protected]>
Cc: [email protected]
Message-ID:
<cablnezvz2ovian6mmlrjbjfdxg6k_32jnnxr5ubxerf9xyd...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
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 <[email protected]>:
> 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
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 3
Date: Sun, 7 Aug 2011 16:17:29 +0300
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] Conciseness question
To: Thiago Negri <[email protected]>
Cc: [email protected], Manfred Lotz <[email protected]>
Message-ID:
<CAKA2Jg+f2zAL3ZBjkGv+VLb+wY=9ROYum6JC-C=7r6sjcri...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
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 <[email protected]> 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 <[email protected]>:
>> 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
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 4
Date: Sun, 7 Aug 2011 16:19:41 +0300
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] Conciseness question
To: Thiago Negri <[email protected]>
Cc: [email protected], Manfred Lotz <[email protected]>
Message-ID:
<CAKA2JgKCQKS6FR6NT7imML+NEx6EFF7mYdJc3Lc=pnxrrm3...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Sorry, forgot to explain the phrase. In Hebrew, the ending "ayim" is
the dual form, used often for limbs (yadayim = hands, raglayim = feet,
etc). "Paam" means "time", and "paamayim" means "two times". "Nekuda"
means dot/period, and "nekudotayim" means two dots (== colon).
Paamayim Nekudotayim therefore is double-double dots, or two colons.
On Sun, Aug 7, 2011 at 4:17 PM, Michael Snoyman <[email protected]> wrote:
> 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 <[email protected]> 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 <[email protected]>:
>>> 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
>>> [email protected]
>>> http://www.haskell.org/mailman/listinfo/beginners
>>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
------------------------------
Message: 5
Date: Sun, 7 Aug 2011 15:21:13 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: Re: [Haskell-beginners] Conciseness question
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Manfred Lotz <[email protected]> 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/
------------------------------
Message: 6
Date: Sun, 7 Aug 2011 15:37:41 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Conciseness question
To: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain; charset="iso-8859-1"
On Sunday 07 August 2011, 15:19:41, Michael Snoyman wrote:
> Sorry, forgot to explain the phrase. In Hebrew, the ending "ayim" is
> the dual form, used often for limbs (yadayim = hands, raglayim = feet,
> etc). "Paam" means "time", and "paamayim" means "two times". "Nekuda"
> means dot/period, and "nekudotayim" means two dots (== colon).
> Paamayim Nekudotayim therefore is double-double dots, or two colons.
>
> On Sun, Aug 7, 2011 at 4:17 PM, Michael Snoyman <[email protected]>
wrote:
> > 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?
My guess: it's a reference to PHP, which, as far as I know, calls its scope
resolution operator thus (and confused the heck out of many people with
"Syntax error, unexpected T PAAMAYIM NEKUDOTAYIM") and thus made this
phrase known in wider circles of goyim too.
------------------------------
Message: 7
Date: Sun, 7 Aug 2011 17:38:40 +0300
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] Conciseness question
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID:
<CAKA2JgLkqCWtwv1NLD_2W2GD1kJ+cEGGV=trqqohvo6zult...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
On Sun, Aug 7, 2011 at 4:37 PM, Daniel Fischer
<[email protected]> wrote:
> On Sunday 07 August 2011, 15:19:41, Michael Snoyman wrote:
>> Sorry, forgot to explain the phrase. In Hebrew, the ending "ayim" is
>> the dual form, used often for limbs (yadayim = hands, raglayim = feet,
>> etc). "Paam" means "time", and "paamayim" means "two times". "Nekuda"
>> means dot/period, and "nekudotayim" means two dots (== colon).
>> Paamayim Nekudotayim therefore is double-double dots, or two colons.
>>
>> On Sun, Aug 7, 2011 at 4:17 PM, Michael Snoyman <[email protected]>
> wrote:
>> > 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?
>
> My guess: it's a reference to PHP, which, as far as I know, calls its scope
> resolution operator thus (and confused the heck out of many people with
> "Syntax error, unexpected T PAAMAYIM NEKUDOTAYIM") and thus made this
> phrase known in wider circles of goyim too.
>
Ahhh.... thanks for the explanation.
------------------------------
Message: 8
Date: Sun, 7 Aug 2011 16:45:01 +0200
From: Manfred Lotz <[email protected]>
Subject: Re: [Haskell-beginners] Conciseness question
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
On Sun, 7 Aug 2011 10:10:04 -0300
Thiago Negri <[email protected]> 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
>
Thanks for pointing me to this. At least it shows a nice way do define
records without the need to name the members.
> >
> > pval = P {
> > ? a = "bla1",
> > ? b = "bla2"
> > }
> >
This could be then pval = P "bla1" "bla2", however it doesn't give me
map over the member of the record which I want because I have some 15
members of such a record.
--
Manfred
------------------------------
Message: 9
Date: Sun, 7 Aug 2011 17:07:40 +0200
From: Manfred Lotz <[email protected]>
Subject: Re: [Haskell-beginners] Conciseness question
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
On Sun, 7 Aug 2011 15:21:13 +0200
Ertugrul Soeylemez <[email protected]> wrote:
> Manfred Lotz <[email protected]> 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.
>
Hmm, not quite sure I'm understanding why Data.Map would help.
What I want to have is something like the following without the
verboseness of it:
-- this is a minimal example.
-- Assume I would have some 15 such values.
a = "bla"
b = "bla2"
valList = [ a, b ]
Now in my program on the one hand I want to do something with all
values, thus: map doSomething valList
On the other hand I frequently want use single values in my program,
like e.g.:
let x = "suffix " ++ a
What I don't want to do is to write a definition like valList
because if I add a new value I have to remind myself not to forget to
add it to valList too.
--
Manfred
--
Manfred
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 38, Issue 12
*****************************************