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: having trouble with helloworld style program
(Ertugrul Soeylemez)
2. Re: Parse string with optional entries [Parsec]
([email protected])
3. Re: having trouble with helloworld style program (Hartmut)
4. Re: having trouble with helloworld style program
(Sunil S Nandihalli)
5. Re: having trouble with helloworld style program (Sukumaran A)
6. Re: having trouble with helloworld style program (Sukumaran A)
7. Re: Parse string with optional entries [Parsec] (David McBride)
----------------------------------------------------------------------
Message: 1
Date: Mon, 8 Aug 2011 13:45:42 +0200
From: Ertugrul Soeylemez <[email protected]>
Subject: Re: [Haskell-beginners] having trouble with helloworld style
program
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Sunil S Nandihalli <[email protected]> wrote:
> module Main where
> import Prelude
>
> stringToInt::String->Int
> stringToInt str = read str
>
> main =
> do x<-getLine
> y<-stringToInt x
> print y
It is a type problem. Using the '<-' syntax for 'stringToInt' requires
that it is a monadic function (like: String -> IO Int), but it is not.
Since it is not monadic, you can simply let-bind the result to a name:
do xStr <- getLine
let x = stringToInt xStr
print x
Or more simply:
do xStr <- getLine
print (stringToInt xStr)
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
------------------------------
Message: 2
Date: Mon, 8 Aug 2011 11:53:32 +0000
From: <[email protected]>
Subject: Re: [Haskell-beginners] Parse string with optional entries
[Parsec]
To: <[email protected]>
Cc: [email protected]
Message-ID:
<d51f81ac58698f4c9f3819136bfada3f03748...@mucse504.eu.infineon.com>
Content-Type: text/plain; charset="utf-8"
Hi,
I have something similar to the CSV-Parser in RWH, chapter 16.
The problem are the possible empty cells, i.e. consecutive '\t'-Characters.
-----Original Message-----
From: Antoine Latter [mailto:[email protected]]
Sent: Monday, August 08, 2011 1:44 PM
To: Lukasser Stefan (IFAT IMM PSD D TEC / EE)
Cc: [email protected]
Subject: Re: [Haskell-beginners] Parse string with optional entries [Parsec]
On Mon, Aug 8, 2011 at 6:39 AM, <[email protected]> wrote:
> Hi all,
>
> I'm trying to parse a string in one of the following forms using Parsec:
>
> "1\t1\t123\t456" -> desired output: [Just 1, Just 1, Just 123, Just 456]
>
> or
>
> "1\t\1\t\t456" ?-> desired output: [Just 1, Just 1, Nothing, Just 456]
>
> i.e., the input is a list of numbers, separated by '\t' characters, with the
> possibility of missing entries.
> I'm having troubles with the backtracking in case of missing numbers. Can
> anybody give me a hint?
>
What do you have so far?
> Thanks in advance,
> Stefan
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 3
Date: Mon, 8 Aug 2011 13:54:55 +0200
From: Hartmut <[email protected]>
Subject: Re: [Haskell-beginners] having trouble with helloworld style
program
To: Ertugrul Soeylemez <[email protected]>
Cc: [email protected]
Message-ID:
<CAFz=thhqjml53qgdxxp4gam_mp1r+xx_31bfttjrqrvt7kk...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
here...
<- is good for "pulling out" a result/value out of an IO Action (after
running it)
let is good for the assignment of a pure functional evaluation/result
Hope this is roughly correct :-)
Hartmut
On Mon, Aug 8, 2011 at 1:45 PM, Ertugrul Soeylemez <[email protected]> wrote:
> Sunil S Nandihalli <[email protected]> wrote:
>
> > module Main where
> > import Prelude
> >
> > stringToInt::String->Int
> > stringToInt str = read str
> >
> > main =
> > do x<-getLine
> > y<-stringToInt x
> > print y
>
> It is a type problem. Using the '<-' syntax for 'stringToInt' requires
> that it is a monadic function (like: String -> IO Int), but it is not.
> Since it is not monadic, you can simply let-bind the result to a name:
>
> do xStr <- getLine
> let x = stringToInt xStr
> print x
>
> Or more simply:
>
> do xStr <- getLine
> print (stringToInt xStr)
>
>
> Greets,
> Ertugrul
>
>
> --
> nightmare = unsafePerformIO (getWrongWife >>= sex)
> http://ertes.de/
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110808/3074a6b8/attachment-0001.htm>
------------------------------
Message: 4
Date: Mon, 8 Aug 2011 17:25:07 +0530
From: Sunil S Nandihalli <[email protected]>
Subject: Re: [Haskell-beginners] having trouble with helloworld style
program
To: Ertugrul Soeylemez <[email protected]>
Cc: [email protected]
Message-ID:
<cap0fd73abz7rnwdffvqup7dgn64u4c0drcuzxlr96d+jp54...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
thanks Micheal and Ertugrul!
Sunil
On Mon, Aug 8, 2011 at 5:15 PM, Ertugrul Soeylemez <[email protected]> wrote:
> Sunil S Nandihalli <[email protected]> wrote:
>
> > module Main where
> > import Prelude
> >
> > stringToInt::String->Int
> > stringToInt str = read str
> >
> > main =
> > do x<-getLine
> > y<-stringToInt x
> > print y
>
> It is a type problem. Using the '<-' syntax for 'stringToInt' requires
> that it is a monadic function (like: String -> IO Int), but it is not.
> Since it is not monadic, you can simply let-bind the result to a name:
>
> do xStr <- getLine
> let x = stringToInt xStr
> print x
>
> Or more simply:
>
> do xStr <- getLine
> print (stringToInt xStr)
>
>
> Greets,
> Ertugrul
>
>
> --
> nightmare = unsafePerformIO (getWrongWife >>= sex)
> http://ertes.de/
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110808/98f9adbc/attachment-0001.htm>
------------------------------
Message: 5
Date: Mon, 8 Aug 2011 17:33:29 +0530
From: Sukumaran A <[email protected]>
Subject: Re: [Haskell-beginners] having trouble with helloworld style
program
To: Sunil S Nandihalli <[email protected]>
Cc: [email protected]
Message-ID:
<caad3xjwt1na4ywvh4kbvdz3tkxzh5cxk43w_dotnmgd3kxu...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Dear Sunil
I am very new to haskell, started reading http://learnyouahaskell.com and
completed upto functionally-solving-problems. In your example, it is very
clear where the issue is
Please check below code and try to infer what is wrong with you. Please let
me know if you want explanation from my side.
module Main where
import Prelude
stringToInt::String->Int
stringToInt str = read str
main =do
x<-getLine
let y=stringToInt x
print y
On Mon, Aug 8, 2011 at 5:09 PM, Sunil S Nandihalli <
[email protected]> wrote:
> Hello everybody,
> All I want to do in the following code is to read an integer from stdin
> and print it back to stdout. Can somebody help me fix my code snippet
> below..
>
> Thanks,
> Sunil
>
>
> module Main where
> import Prelude
>
> stringToInt::String->Int
> stringToInt str = read str
>
> main =
> do x<-getLine
> y<-stringToInt x
> print y
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110808/471f27ad/attachment-0001.htm>
------------------------------
Message: 6
Date: Mon, 8 Aug 2011 17:42:45 +0530
From: Sukumaran A <[email protected]>
Subject: Re: [Haskell-beginners] having trouble with helloworld style
program
To: Sunil S Nandihalli <[email protected]>
Cc: [email protected]
Message-ID:
<caad3xjz7dmt99n4bo31bamw9azxbrpihqzswmrmavnj6tgb...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Ohh, I missed to see reply from others. Anyway I am putting one more method
just from my side
module Main where
import Prelude
stringToInt::String->Int
stringToInt str = read str
main =do
x<-getLine
y<-return x
print $ stringToInt y
Regards
Sukumaran
On Mon, Aug 8, 2011 at 5:33 PM, Sukumaran A <[email protected]> wrote:
> Dear Sunil
> I am very new to haskell, started reading http://learnyouahaskell.com and
> completed upto functionally-solving-problems. In your example, it is very
> clear where the issue is
>
> Please check below code and try to infer what is wrong with you. Please let
> me know if you want explanation from my side.
>
>
> module Main where
> import Prelude
>
> stringToInt::String->Int
> stringToInt str = read str
>
> main =do
> x<-getLine
> let y=stringToInt x
> print y
>
> On Mon, Aug 8, 2011 at 5:09 PM, Sunil S Nandihalli <
> [email protected]> wrote:
>
>> Hello everybody,
>> All I want to do in the following code is to read an integer from stdin
>> and print it back to stdout. Can somebody help me fix my code snippet
>> below..
>>
>> Thanks,
>> Sunil
>>
>>
>> module Main where
>> import Prelude
>>
>> stringToInt::String->Int
>> stringToInt str = read str
>>
>> main =
>> do x<-getLine
>> y<-stringToInt x
>> print y
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110808/b89cfccd/attachment-0001.htm>
------------------------------
Message: 7
Date: Mon, 8 Aug 2011 09:53:22 -0400
From: David McBride <[email protected]>
Subject: Re: [Haskell-beginners] Parse string with optional entries
[Parsec]
To: [email protected]
Cc: [email protected]
Message-ID:
<can+tr42bexsx72cuzp+rnczlynpt9d+xkbr7ib1ac2ccwa1...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Read up on the sepBy combinator.
parse (sepBy (many digit) (char ',')) "" "123,321,,2321"
Right ["123","321","","2321"]
On Mon, Aug 8, 2011 at 7:53 AM, <[email protected]> wrote:
> Hi,
>
> I have something similar to the CSV-Parser in RWH, chapter 16.
> The problem are the possible empty cells, i.e. consecutive '\t'-Characters.
>
>
> -----Original Message-----
> From: Antoine Latter [mailto:[email protected]]
> Sent: Monday, August 08, 2011 1:44 PM
> To: Lukasser Stefan (IFAT IMM PSD D TEC / EE)
> Cc: [email protected]
> Subject: Re: [Haskell-beginners] Parse string with optional entries [Parsec]
>
> On Mon, Aug 8, 2011 at 6:39 AM, ?<[email protected]> wrote:
>> Hi all,
>>
>> I'm trying to parse a string in one of the following forms using Parsec:
>>
>> "1\t1\t123\t456" -> desired output: [Just 1, Just 1, Just 123, Just 456]
>>
>> or
>>
>> "1\t\1\t\t456" ?-> desired output: [Just 1, Just 1, Nothing, Just 456]
>>
>> i.e., the input is a list of numbers, separated by '\t' characters, with the
>> possibility of missing entries.
>> I'm having troubles with the backtracking in case of missing numbers. Can
>> anybody give me a hint?
>>
>
> What do you have so far?
>
>> Thanks in advance,
>> Stefan
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 38, Issue 17
*****************************************