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. Re: What is operator :| ? (Brandon Allbery)
2. Re: What is operator :| ? (John M. Dlugosz)
3. Help on first program (John M. Dlugosz)
4. Re: Help on first program (John M. Dlugosz)
5. Re: Help on first program (John M. Dlugosz)
6. Re: Help on first program (Brandon Allbery)
7. Re: Help on first program (John M. Dlugosz)
8. Re: Help on first program (Brandon Allbery)
----------------------------------------------------------------------
Message: 1
Date: Fri, 28 Mar 2014 09:56:05 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] What is operator :| ?
Message-ID:
<cakfcl4w7wbgyizoz3ctumpy9winq0svcd2wbbtzr73+jae8...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Fri, Mar 28, 2014 at 2:48 AM, Francesco Ariis <[email protected]> wrote:
> On Fri, Mar 28, 2014 at 12:54:03AM -0500, John M. Dlugosz wrote:
> > More generally, is there some effective way to search for
> > non-alphabetical Haskell things? Google just ignores the
> > "punctuation".
>
> You can find :| on Hayoo [1], the other handy place where to
> look for APIs stuff being Hoogle [2] (Hoogle is more focused on
> 'standard' Haskell libraries, Hayoo searches in all Hackage,
> both have their usefulness).
> From there, if I need to search, say, a blog post, I will refer
> to the name of the typeclass/module/data and feed it to a search
> engine (so in this case "data NonEmpty etc. etc.").
> Apparently Google ignores punctuation in most cases [3].
>
http://symbolhound.com is useful.
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140328/404be5c9/attachment-0001.html>
------------------------------
Message: 2
Date: Fri, 28 Mar 2014 17:05:50 -0500
From: "John M. Dlugosz" <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] What is operator :| ?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 3/28/2014 1:48 AM, Karl Voelker wrote:
> On Thu, Mar 27, 2014, at 10:54 PM, John M. Dlugosz wrote:
>> More generally, is there some effective way to search for
>> non-alphabetical Haskell things?
>> Google just ignores the "punctuation".
>
> For that, you can use Hayoo.
>
> http://holumbus.fh-wedel.de/hayoo/hayoo.html
>
> -Karl
>
Awesome! Thanks for pointing that out.
------------------------------
Message: 3
Date: Fri, 28 Mar 2014 18:00:27 -0500
From: "John M. Dlugosz" <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Help on first program
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
Can someone explain what's wrong here? What is the code below _really_ saying,
vs what I
meant? I don't understand the error messages yet.
== input ==
module Main (
main
) where
solve n src dest tmp =
do solve (n-1) src tmp -- line 6
solve 1 src dest tmp
solve (n-1) tmp dest -- line 8
solve 1 src dest _ =
putStrLn "move a disk from " ++ src ++ " to " ++ dest -- line 11
main = do
putStrLn "Towers of Hanoi problem"
solve 5 "A" "B" "C"
== output ==
Prelude> :reload
[1 of 1] Compiling Main ( towers1.hs, interpreted )
Failed, modules loaded: none.
Prelude>
towers1.hs:6:8:
Couldn't match expected type `[a0]'
with actual type `[Char] -> [Char]'
In the return type of a call of `solve'
Probable cause: `solve' is applied to too few arguments
In a stmt of a 'do' block: solve (n - 1) src tmp
In the expression:
do { solve (n - 1) src tmp;
solve 1 src dest tmp;
solve (n - 1) tmp dest }
towers1.hs:8:8:
Couldn't match expected type `[Char]'
with actual type `[Char] -> [Char]'
In the return type of a call of `solve'
Probable cause: `solve' is applied to too few arguments
In a stmt of a 'do' block: solve (n - 1) tmp dest
In the expression:
do { solve (n - 1) src tmp;
solve 1 src dest tmp;
solve (n - 1) tmp dest }
towers1.hs:11:5:
Couldn't match expected type `[Char]' with actual type `IO ()'
In the return type of a call of `putStrLn'
In the first argument of `(++)', namely
`putStrLn "move a disk from "'
In the expression:
putStrLn "move a disk from " ++ src ++ " to " ++ dest
------------------------------
Message: 4
Date: Fri, 28 Mar 2014 18:02:26 -0500
From: "John M. Dlugosz" <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Help on first program
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Nevermind... it really is too few arguments.
On 3/28/2014 6:00 PM, John M. Dlugosz wrote:
> Can someone explain what's wrong here? What is the code below _really_
> saying, vs what I
> meant? I don't understand the error messages yet.
>
> == input ==
> module Main (
> main
> ) where
>
> solve n src dest tmp =
> do solve (n-1) src tmp -- line 6
> solve 1 src dest tmp
> solve (n-1) tmp dest -- line 8
>
> solve 1 src dest _ =
> putStrLn "move a disk from " ++ src ++ " to " ++ dest -- line 11
>
>
> main = do
> putStrLn "Towers of Hanoi problem"
> solve 5 "A" "B" "C"
>
>
> == output ==
> Prelude> :reload
> [1 of 1] Compiling Main ( towers1.hs, interpreted )
> Failed, modules loaded: none.
> Prelude>
> towers1.hs:6:8:
> Couldn't match expected type `[a0]'
> with actual type `[Char] -> [Char]'
> In the return type of a call of `solve'
> Probable cause: `solve' is applied to too few arguments
> In a stmt of a 'do' block: solve (n - 1) src tmp
> In the expression:
> do { solve (n - 1) src tmp;
> solve 1 src dest tmp;
> solve (n - 1) tmp dest }
>
> towers1.hs:8:8:
> Couldn't match expected type `[Char]'
> with actual type `[Char] -> [Char]'
> In the return type of a call of `solve'
> Probable cause: `solve' is applied to too few arguments
> In a stmt of a 'do' block: solve (n - 1) tmp dest
> In the expression:
> do { solve (n - 1) src tmp;
> solve 1 src dest tmp;
> solve (n - 1) tmp dest }
>
> towers1.hs:11:5:
> Couldn't match expected type `[Char]' with actual type `IO ()'
> In the return type of a call of `putStrLn'
> In the first argument of `(++)', namely
> `putStrLn "move a disk from "'
> In the expression:
> putStrLn "move a disk from " ++ src ++ " to " ++ dest
>
------------------------------
Message: 5
Date: Fri, 28 Mar 2014 18:10:20 -0500
From: "John M. Dlugosz" <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Help on first program
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
OK, I'm really stuck now. This gives "out of memory" and doesn't print
anything other
than the first line of output.
== source code ==
module Main (
main
) where
solve n src dest tmp =
do solve (n-1) src tmp dest
solve 1 src dest tmp
solve (n-1) tmp dest src
solve 1 src dest _ =
putStrLn ("move a disk from " ++ src ++ " to " ++ dest)
main = do
putStrLn "Towers of Hanoi problem"
solve 5 "A" "B" "C"
== end ==
Each recursive call is either 1 or (n-1) so it should count down 5,4,3,2,1 and
stop the
recursion.
What am I missing?
------------------------------
Message: 6
Date: Fri, 28 Mar 2014 19:14:50 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Help on first program
Message-ID:
<cakfcl4wv7rampu5suehhf8gkcjktfzwmygjbp5jupu3kyqf...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Fri, Mar 28, 2014 at 7:10 PM, John M. Dlugosz
<[email protected]>wrote:
> Each recursive call is either 1 or (n-1) so it should count down 5,4,3,2,1
> and stop the recursion.
>
What am I missing?
It doesn't magically stop at 0; Integer (inferred type) is signed.
Moreover, even if it were not signed, it would wrap around (or possibly
throw an exception on some CPUs, but not on Intel). You need to include a
check for 0 to stop the recursion.
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140328/cab4f12c/attachment-0001.html>
------------------------------
Message: 7
Date: Fri, 28 Mar 2014 18:49:07 -0500
From: "John M. Dlugosz" <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Help on first program
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On 3/28/2014 6:14 PM, Brandon Allbery wrote:
> On Fri, Mar 28, 2014 at 7:10 PM, John M. Dlugosz <[email protected]
> <mailto:[email protected]>> wrote:
>
> Each recursive call is either 1 or (n-1) so it should count down
> 5,4,3,2,1 and stop
> the recursion.
>
> What am I missing?
>
>
> It doesn't magically stop at 0; Integer (inferred type) is signed. Moreover,
> even if it
> were not signed, it would wrap around (or possibly throw an exception on some
> CPUs, but
> not on Intel). You need to include a check for 0 to stop the recursion.
>
I don't get it. When n == 1 it should match the second form, and that is not
recursive.
Ah, they are matched in order!
(Yes, it works if I reverse the clauses)
Hmm, so it figures out the type from all of them? I worried about putting
specialized
ones first because there is far less information.
------------------------------
Message: 8
Date: Fri, 28 Mar 2014 19:56:44 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Help on first program
Message-ID:
<cakfcl4u_zxnrrgem9gfx0jq6ebyhrzzpiqq7ung+j1kbhx7...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Fri, Mar 28, 2014 at 7:49 PM, John M. Dlugosz
<[email protected]>wrote:
> On 3/28/2014 6:14 PM, Brandon Allbery wrote:
>
>> On Fri, Mar 28, 2014 at 7:10 PM, John M. Dlugosz <
>> [email protected]
>> <mailto:[email protected]>> wrote:
>>
>> Each recursive call is either 1 or (n-1) so it should count down
>> 5,4,3,2,1 and stop
>> the recursion.
>>
>> What am I missing?
>>
>> It doesn't magically stop at 0; Integer (inferred type) is signed.
>> Moreover, even if it
>> were not signed, it would wrap around (or possibly throw an exception on
>> some CPUs, but
>> not on Intel). You need to include a check for 0 to stop the recursion.
>>
>> I don't get it. When n == 1 it should match the second form, and that
> is not recursive.
>
> Ah, they are matched in order!
> (Yes, it works if I reverse the clauses)
Hmm, so it figures out the type from all of them? I worried about putting
> specialized ones first because there is far less information.
It uses all of them to get the type, yes. And the more specific pattern
must come first; the first one always matches in this case because `n`
doesn't give it any way not to match. If you had warnings enabled, the
compiler should have warned you that the second form wouldn't be matched
(although you may also need optimization turned on).
The compiler doesn't see the different implementations as independent, and
in fact doesn't see multiple implementations of the function at all at type
resolution time; it's translated to a single function applying `case` to
the parameters to determine which clause of the body to evaluate.
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140328/b0945b62/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 69, Issue 45
*****************************************