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:  where do i get wrong (Emanuel Koczwara)
   2. Re:  where do i get wrong (Roelof Wobben)
   3. Re:  where do i get wrong (Nadir Sampaoli)
   4.  foldr problem (Roelof Wobben)
   5. Re:  foldr problem (Emanuel Koczwara)


----------------------------------------------------------------------

Message: 1
Date: Sun, 02 Mar 2014 21:12:03 +0100
From: Emanuel Koczwara <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] where do i get wrong
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"

Hi,

W dniu 02.03.2014 21:06, Roelof Wobben pisze:
> Thanks.
>
> This does the job :
>
> import Data.Char
>
> x = map isLower "ABCde":[]
> -- Note that comments are preceded by two hyphens
> {- or enclosed
>    in curly brace/hypens pairs. -}
> main = print x
>

   You have a list of lists of booleans: [[Bool]]. You should get a list 
of booleans: [Bool] instead.

Regards,
Emanuel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140302/51a4e658/attachment-0001.html>

------------------------------

Message: 2
Date: Sun, 02 Mar 2014 21:32:16 +0100
From: Roelof Wobben <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] where do i get wrong
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140302/42435fb0/attachment-0001.html>

------------------------------

Message: 3
Date: Sun, 2 Mar 2014 21:36:33 +0100
From: Nadir Sampaoli <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] where do i get wrong
Message-ID:
        <cafywtds-aeug4m52cqxxmr6kjb58z7gzbcxo9jgr7qc5ibl...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hello,

2014-03-02 20:50 GMT+01:00 Roelof Wobben <[email protected]>:

>  Correect, I forget to use map
> But also x = map "aBCde".islower does not work.
>
> Your use of the dot (.) function makes me think you might mix Haskell
syntax with OO languages like Python or Java where dot notation is used to
call methods on objects.

Also, as Emanuel and Vlatko pointed out one very important thing in Haskell
is reading type signatures. So, let's check `map` signature:

    map :: (a -> b) -> [a] -> [b]

What does this mean?
Although all Haskell functions take one and only one argument we probably
might find it simpler to reason in terms of first argument, second argument
and return value (`map` should probably be better described as a function
that takes a function from `a` to `b` and returns a function from [a] to
[b]).

Anyway.

The first argument is (a -> b), a function from `a` to `b`.
The second argument is [a], i.e. a list of `a` (`a` can potentially
represent any type).
The last type in the signature is [b] which we might call the return type.
Again, haskellers, don't stab me please :)

Now check the type signature for `isLower`:

    isLower :: Char -> Bool

`isLower` will be `map`'s first argument, so, replacing the original (a ->
b) with isLower type signature, you'll get:

    map :: (Char -> Bool) -> [Char] -> [Bool]

A step further, the signature then becomes:

    map isLower :: [Char] -> [Bool]

As you can see here, understanding that all functions in Haskell takes just
one argument helps because `map isLower` is in turn a function. The result
of calling `map` with `isLower` as its (first and only) argument, is a
function from [a], or, better, from [Char], since Char is the (first and
only) argument of `isLower`, to [b], or, better, to [Bool] since Bool is
the return type of `isLower`.

Now we have map isLower which takes a [Char]. [Char] and String are
synonyms, by the way, so you could also write `map isLower` signature as
follows:

    map isLower :: String -> [Bool]

This seems exactly what we need: a function from String to a list of
booleans.

 I think I have to find out how I can ghci in fpcomplete or use another IDE
> which supports it.
>
> Roelof
>

Have you read/are you reading "Learn you a Haskell" (
http://learnyouahaskell.com/chapters)? I'd advise you to read it, as it
helps you, in the beginning, being more confortable with Haskell's syntax
and library.

--
Nadir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140302/7e5fbe98/attachment-0001.html>

------------------------------

Message: 4
Date: Sun, 02 Mar 2014 22:44:14 +0100
From: Roelof Wobben <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] foldr problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140302/34eb36b8/attachment-0001.html>

------------------------------

Message: 5
Date: Sun, 02 Mar 2014 22:51:51 +0100
From: Emanuel Koczwara <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] foldr problem
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"

Hi,

W dniu 02.03.2014 22:44, Roelof Wobben pisze:
> Hello,
>
> I now have to use foldr to find the max value in a list.
>
> So I do this:
>
> import Data.Char
>
> x = foldr max [5,10,2,8.1]
> -- Note that comments are preceded by two hyphens
> {- or enclosed
>    in curly brace/hypens pairs. -}
> main = print x
>
> But now I see this error message:
> Active code from: 1: Haskell Basics
> main.hs@7:8-7:13
>     No instance for (Show ([[t0]] -> [t0])) arising from a use of 
> `print' Possible fix: add an instance declaration for (Show ([[t0]] -> 
> [t0])) In the expression: print x In an equation for `main': main = 
> print x
>
> Active code from: 1: Haskell Basics Active code from: 1: Haskell Basics

   Please look at foldr type and documentation. There is one argument 
missing in your code.

Regards,
Emanuel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140302/0c181039/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 69, Issue 5
****************************************

Reply via email to