Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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. Re: Why this order of parameters (Martin Vlk)
2. Re: My First Haskell Project--Please give feedback!
(emacstheviking)
3. Re: Why this order of parameters (Alex Belanger)
4. Re: Why this order of parameters (David McBride)
5. Re: Why this order of parameters (Martin Vlk)
6. Re: Why this order of parameters (Harald Hanche-Olsen)
----------------------------------------------------------------------
Message: 1
Date: Thu, 12 Nov 2015 17:00:24 +0000
From: Martin Vlk <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Why this order of parameters
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252
Hi, my first intuition about this is that in data constructor it
technically doesn't matter, but you could argue that "a" represents the
actual result of the function so it comes first.
Second comes the state, which is the side thing, hence the
secondary/less important position.
As for the order of type constructor parameters you are right - state is
part of the structure that Monoid, Functor, Applicative, Monad and the
like use.
Martin
martin:
> runState :: State s a -> s -> (a, s)
>
> I understand that in the constructor s has to be first, so we can turn (State
> s) into a monad. But why doesn't s come
> first in the result too, as in
>
> runState :: State s a -> s -> (s, a)
------------------------------
Message: 2
Date: Thu, 12 Nov 2015 17:32:25 +0000
From: emacstheviking <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] My First Haskell Project--Please give
feedback!
Message-ID:
<CAEiEuU+GpiFdW-N=_fojjvsnpvdhkxhxwnkchnwahyj1stn...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
"The error messages are worse than gcc barfing on C++ templates"
that had me laughing all the way to the kettle! I know what you mean!
I will have a look myself sometime...
On 12 November 2015 at 16:34, Thomas Jakway <[email protected]> wrote:
> Hi everyone! I'm trying to write a blackjack simulator and would really
> appreciate advice on the code.
>
> I wrote about lots of specific things in an /r/haskell post:
>
>
> https://www.reddit.com/r/haskell/comments/3sjs0y/my_first_haskell_projectplease_give_feedback/
>
> And the code is here:
> https://github.com/tjakway/blackjack-simulator/blob/master/src/Cards.hs
>
> (sorry if it's annoying to have to follow a link, thought it'd be better
> than just copy + pasting a huge blob here)
>
> Thanks in advance!
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151112/c23f0cca/attachment-0001.html>
------------------------------
Message: 3
Date: Thu, 12 Nov 2015 12:34:43 -0500
From: Alex Belanger <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Why this order of parameters
Message-ID:
<cadsky2xp7lfz8vd1vhzm1devdvdyqhe4d4qenrfntbgioyw...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
foldr :: (a -> b -> b) -> b -> [a] -> b
foldr :: (b -> a -> a) -> a -> [b] -> a
are exactly the same types; simply inverted names for the type variables.
I don't clearly see any benefit.
Alex.
On Nov 12, 2015 12:00 PM, "Martin Vlk" <[email protected]> wrote:
> Hi, my first intuition about this is that in data constructor it
> technically doesn't matter, but you could argue that "a" represents the
> actual result of the function so it comes first.
> Second comes the state, which is the side thing, hence the
> secondary/less important position.
>
> As for the order of type constructor parameters you are right - state is
> part of the structure that Monoid, Functor, Applicative, Monad and the
> like use.
>
> Martin
>
> martin:
> > runState :: State s a -> s -> (a, s)
> >
> > I understand that in the constructor s has to be first, so we can turn
> (State s) into a monad. But why doesn't s come
> > first in the result too, as in
> >
> > runState :: State s a -> s -> (s, a)
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151112/d560c9a2/attachment-0001.html>
------------------------------
Message: 4
Date: Thu, 12 Nov 2015 12:49:11 -0500
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Why this order of parameters
Message-ID:
<CAN+Tr42WDjE4nEao8HtG1yJNc1cYdcUDQNjfW+=w9ytwkct...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
He means why is the first argument a -> b -> b in one function but b -> a
-> b in the other. And I have no answer for that. I admit to having been
caught by that in the past. You can't just replace one with the other in
code, you have to do a flip on the operator.
On Thu, Nov 12, 2015 at 12:34 PM, Alex Belanger <[email protected]>
wrote:
> foldr :: (a -> b -> b) -> b -> [a] -> b
> foldr :: (b -> a -> a) -> a -> [b] -> a
>
> are exactly the same types; simply inverted names for the type variables.
>
> I don't clearly see any benefit.
>
> Alex.
> On Nov 12, 2015 12:00 PM, "Martin Vlk" <[email protected]> wrote:
>
>> Hi, my first intuition about this is that in data constructor it
>> technically doesn't matter, but you could argue that "a" represents the
>> actual result of the function so it comes first.
>> Second comes the state, which is the side thing, hence the
>> secondary/less important position.
>>
>> As for the order of type constructor parameters you are right - state is
>> part of the structure that Monoid, Functor, Applicative, Monad and the
>> like use.
>>
>> Martin
>>
>> martin:
>> > runState :: State s a -> s -> (a, s)
>> >
>> > I understand that in the constructor s has to be first, so we can turn
>> (State s) into a monad. But why doesn't s come
>> > first in the result too, as in
>> >
>> > runState :: State s a -> s -> (s, a)
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151112/ca303b83/attachment-0001.html>
------------------------------
Message: 5
Date: Thu, 12 Nov 2015 17:49:20 +0000
From: Martin Vlk <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Why this order of parameters
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252
I think again this technically doesn't matter...
I'm curious if this could be for the sake of making the types of the two
functions (foldr/foldl) different? E.g. so that you can tell from the
type what function it is.
(I'm a Haskell beginner myself so would be curious to hear an expert's
voice on this!)
Martin
martin:
> foldl :: (a -> b -> a) -> a -> [b] -> a
> foldr :: (a -> b -> b) -> b -> [a] -> b
>
> For once the list is a list of as in foldl, but a list of as in foldr. Now
> that can be fixed with renaming the type
> parameters
>
> foldr :: (b -> a -> a) -> a -> [b] -> a
>
> this is the exact same thing and resembles more the type of foldl. But still
> the function argument has its parameters
> flipped. foldl's function takes the list element as second parameter and
> foldr's takes it as first parameter.
>
> Why is that so?
------------------------------
Message: 6
Date: Thu, 12 Nov 2015 20:45:37 +0000
From: Harald Hanche-Olsen <[email protected]>
To: "The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell" <[email protected]>
Subject: Re: [Haskell-beginners] Why this order of parameters
Message-ID: <etPan.5644fa70.5a4d5b58.3cc@frigg>
Content-Type: text/plain; charset="utf-8"
Hmmm, I seem to have missed part of this conversation, but I?ll toss in my two
cents anyhow:
Consider the identities
foldl (?) s [x,y,z] == ((s?x)?y)?z
foldr (?) s [x,y,z] == x?(y?(z?s))
and I think it should be clear that the type of (?) must be a?b?a in the former
and b?a?a in the latter.
Either of these identities would look rather odd when written in operator
notation if (?) were flipped!
? Harald
-----Original Message-----
From:?Martin Vlk <[email protected]>
Date:?12 November 2015 at 18:49:35
> I think again this technically doesn't matter...
>
> I'm curious if this could be for the sake of making the types of the two
> functions (foldr/foldl) different? E.g. so that you can tell from the
> type what function it is.
>
> (I'm a Haskell beginner myself so would be curious to hear an expert's
> voice on this!)
>
> Martin
>
> martin:
> > foldl :: (a -> b -> a) -> a -> [b] -> a
> > foldr :: (a -> b -> b) -> b -> [a] -> b
> >
> > For once the list is a list of as in foldl, but a list of as in foldr. Now
> > that can be fixed
> with renaming the type
> > parameters
> >
> > foldr :: (b -> a -> a) -> a -> [b] -> a
> >
> > this is the exact same thing and resembles more the type of foldl. But
> > still the function
> argument has its parameters
> > flipped. foldl's function takes the list element as second parameter and
> > foldr's takes
> it as first parameter.
> >
> > Why is that so?
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
--
Harald Hanche-Olsen
F?rsteamanuensis
Institutt for matematiske fag
Norges teknisk-naturvitenskapelige universitet
7491 Trondheim
http://www.math.ntnu.no/~hanche/
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 89, Issue 21
*****************************************