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:  Is this scope range problem? (Sok H. Chang)
   2. Re:  Is this scope range problem? (Luca Toscano)
   3. Re:  Is this scope range problem? (Bastian Erdn??)
   4. Re:  GUI library for beginners? (Brent Yorgey)
   5. Re:  Is this scope range problem? (Sok H. Chang)
   6. Re:  GUI library for beginners? (Tom Hobbs)


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

Message: 1
Date: Tue, 14 Dec 2010 20:32:43 +0900
From: "Sok H. Chang" <[email protected]>
Subject: Re: [Haskell-beginners] Is this scope range problem?
To: Luca Toscano <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="utf-8"

Thank you so much, Luca.
Mmm... I want to make a "List of Sentence" from some text file.

inputFile.txt is like this.
--------------------------------
This is a pen.
Is this a pen?
etc...many sentence. Each line, only one sentence.

How can I make a list of sentence?
How can I declared inpStr?

Thank you.

Sincerely, Sok Chang


2010/12/14 Luca Toscano <[email protected]>

> On 12/14/2010 07:24 AM, Sok H. Chang wrote:
>
>> Hello, everyone.
>>
> Hello,
> I don't understand very well what you're trying to do in your code, but if
> it is simply reading from a file and put the output into another file there
> is a better way:
>
>
> import System.IO
> import System.Random
>
> sentenceAry = []
>
> main :: IO ()
> main = do
>    inh <- openFile "c:\\Documents and Settings\\shaegis\\inputFile.txt"
> ReadMode
>    outh <- openFile "c:\\Documents and Settings\\shaegis\\outputFile.txt"
> WriteMode
>    mainloop inh outh
>    hClose inh
>    hClose outh
>
> mainloop :: Handle -> Handle -> IO ()
> mainloop inh outh = do
>    ineof <- hIsEOF inh
>    if ineof
>        then
>            return ()
>        else do
>            inpStr <- hGetLine inh
>            hPutStrLn outh inpStr
>            mainloop inh outh
>
>
> I hope I've understood the problem.. In your code 'inpStr' wasn't in scope,
> because you've declared it  only into else block..
>
> Luca
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>



-- 
Sok Ha, CHANG
Open Mind Clinic/Academy, 1551-1, Sa-Dong, SangRok-Gu, AnSan-City,
KyongGi-Do
Tel: 031-407-6114
HP: openmind.ac / www.openmind.ac
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20101214/a33176ea/attachment-0001.htm>

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

Message: 2
Date: Tue, 14 Dec 2010 14:36:24 +0100
From: Luca Toscano <[email protected]>
Subject: Re: [Haskell-beginners] Is this scope range problem?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed

On 12/14/2010 12:32 PM, Sok H. Chang wrote:
> Thank you so much, Luca.
> Mmm... I want to make a "List of Sentence" from some text file.
>
> inputFile.txt is like this.
> --------------------------------
> This is a pen.
> Is this a pen?
> etc...many sentence. Each line, only one sentence.
>
> How can I make a list of sentence?
> How can I declared inpStr?
>
> Thank you.
>
> Sincerely, Sok Chang
>
You're welcome! I am a beginner in haskell programming, it's interesting 
to work with others! By the way, this is the code:

import System.IO
import System.Random
import Data.List

main :: IO ()
main = do
     inh <- openFile "path_to_file" ReadMode
     prova <- (mainloop inh [])
     print prova
     hClose inh

mainloop :: Handle -> [String] -> IO [String]
mainloop inh list = do
     ineof <- hIsEOF inh
     if ineof
         then
             return list
         else do
             inpStr <- hGetLine inh
             mainloop inh (list ++ [inpStr])

This is my version, it works I think.. I hope this helps you!!

Luca






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

Message: 3
Date: Tue, 14 Dec 2010 15:13:33 +0100
From: Bastian Erdn?? <[email protected]>
Subject: Re: [Haskell-beginners] Is this scope range problem?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii


On Dec 14, 2010, at 14:36, Luca Toscano wrote:

> On 12/14/2010 12:32 PM, Sok H. Chang wrote:
>> Thank you so much, Luca.
>> Mmm... I want to make a "List of Sentence" from some text file.
>> 
>> inputFile.txt is like this.
>> --------------------------------
>> This is a pen.
>> Is this a pen?
>> etc...many sentence. Each line, only one sentence.
>> 
>> How can I make a list of sentence?
>> How can I declared inpStr?
>> 
>> Thank you.
>> 
>> Sincerely, Sok Chang
>> 
> You're welcome! I am a beginner in haskell programming, it's interesting to 
> work with others! By the way, this is the code:
> 
> import System.IO
> import System.Random
> import Data.List
> 
> main :: IO ()
> main = do
>    inh <- openFile "path_to_file" ReadMode
>    prova <- (mainloop inh [])
>    print prova
>    hClose inh
> 
> mainloop :: Handle -> [String] -> IO [String]
> mainloop inh list = do
>    ineof <- hIsEOF inh
>    if ineof
>        then
>            return list
>        else do
>            inpStr <- hGetLine inh
>            mainloop inh (list ++ [inpStr])

the "list ++ [inpStr]" is not very efficient for files with lot's of sentences. 
 (++) is implemented in a way that it goes through the whole "list" every time 
a new field is appended.  So, it does a lot of work a multiple times.  Instead 
you should consider to e.g. use "inpStr : list" and reverse the list in the end.

> This is my version, it works I think.. I hope this helps you!!

Another solution would be

  main = do
    input <- readFile "path_to_file"
    let prova = lines input
    print prova

Cheers,
Bastian




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

Message: 4
Date: Tue, 14 Dec 2010 09:38:18 -0500
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] GUI library for beginners?
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1

But OpenGL is not really a GUI library, is it?  I think gtk2hs is
usually recommended. I've never used it personally but have heard good
things from those who have.  Hopefully the web page will be back up
soon.

-Brent

On Tue, Dec 14, 2010 at 09:55:45AM +0000, Tom Hobbs wrote:
> Hi Venanzio,
> 
> I found the following sites very helpful when trying to understand
> OpenGL + Haskell.
> 
> - 
> http://blog.mikael.johanssons.org/archive/2006/09/opengl-programming-in-haskell-a-tutorial-part-1/
> - http://myawesomeblag.blogspot.com/2007/03/opengl-tetris-in-haskell.html
> 
> My site contains the commands I used to get everything install on
> Ubuntu, it also has a link to my code on it, but you'll find that the
> code is very similar to Mikael's above.
> 
> http://whatimean.wordpress.com/2010/10/19/simple-cell-automata-in-haskell/
> 
> Good luck.
> 
> Tom
> 
> On Tue, Dec 14, 2010 at 9:16 AM, Venanzio Capretta <[email protected]> wrote:
> > Hi,
> > ?I've been trying to find out what is the best GUI library to use for a
> > Haskell beginner.
> > At first I adopted gtk2hs and it was going well. But the web page for it has
> > disappeared during the Haskell site migration. So now I don't have access to
> > the documentation and the examples any more.
> > Next I tried with wxHaskell, but unfortunately it doesn't install on Ubuntu
> > (I checked on the mailing list: other people had the same problem and I
> > don't understand the solution).
> > Is there a library for GUI in Haskell that is simple to use and well
> > supported, something that is user friendly for a beginner Haskell
> > programmer?
> > Best wishes,
> > ?Venanzio
> >
> > _______________________________________________
> > 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: Tue, 14 Dec 2010 23:42:22 +0900
From: "Sok H. Chang" <[email protected]>
Subject: Re: [Haskell-beginners] Is this scope range problem?
To: Luca Toscano <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="utf-8"

Thank you so much ! Luca and Bastian !
Now, I can handle whole text file as one list.
I want to do this... extract one text, or eliminate one text(like "tail
LIST") etc...
Thank you.

Also very Thankful to Bastian.
I'll try readFile function.

Thank you again, and Have a nice day.

Sincerely, Sok Chang

2010/12/14 Luca Toscano <[email protected]>

> On 12/14/2010 12:32 PM, Sok H. Chang wrote:
>
>> Thank you so much, Luca.
>> Mmm... I want to make a "List of Sentence" from some text file.
>>
>> inputFile.txt is like this.
>> --------------------------------
>> This is a pen.
>> Is this a pen?
>> etc...many sentence. Each line, only one sentence.
>>
>> How can I make a list of sentence?
>> How can I declared inpStr?
>>
>> Thank you.
>>
>> Sincerely, Sok Chang
>>
>>  You're welcome! I am a beginner in haskell programming, it's interesting
> to work with others! By the way, this is the code:
>
>
> import System.IO
> import System.Random
> import Data.List
>
> main :: IO ()
> main = do
>    inh <- openFile "path_to_file" ReadMode
>    prova <- (mainloop inh [])
>    print prova
>    hClose inh
>
> mainloop :: Handle -> [String] -> IO [String]
> mainloop inh list = do
>
>    ineof <- hIsEOF inh
>    if ineof
>        then
>            return list
>
>        else do
>            inpStr <- hGetLine inh
>            mainloop inh (list ++ [inpStr])
>
> This is my version, it works I think.. I hope this helps you!!
>
>
> Luca
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>



-- 
Sok Ha, CHANG
Open Mind Clinic/Academy, 1551-1, Sa-Dong, SangRok-Gu, AnSan-City,
KyongGi-Do
Tel: 031-407-6114
HP: openmind.ac / www.openmind.ac
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20101214/33d055df/attachment-0001.htm>

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

Message: 6
Date: Tue, 14 Dec 2010 14:49:45 +0000
From: Tom Hobbs <[email protected]>
Subject: Re: [Haskell-beginners] GUI library for beginners?
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

The articles are actually using HOpenGL and HGlut.

Whether they satisfy the definition of "GUI library" or not, I don't
know.  I assumed they did.  Sorry.

On Tue, Dec 14, 2010 at 2:38 PM, Brent Yorgey <[email protected]> wrote:
> But OpenGL is not really a GUI library, is it? ?I think gtk2hs is
> usually recommended. I've never used it personally but have heard good
> things from those who have. ?Hopefully the web page will be back up
> soon.
>
> -Brent
>
> On Tue, Dec 14, 2010 at 09:55:45AM +0000, Tom Hobbs wrote:
>> Hi Venanzio,
>>
>> I found the following sites very helpful when trying to understand
>> OpenGL + Haskell.
>>
>> - 
>> http://blog.mikael.johanssons.org/archive/2006/09/opengl-programming-in-haskell-a-tutorial-part-1/
>> - http://myawesomeblag.blogspot.com/2007/03/opengl-tetris-in-haskell.html
>>
>> My site contains the commands I used to get everything install on
>> Ubuntu, it also has a link to my code on it, but you'll find that the
>> code is very similar to Mikael's above.
>>
>> http://whatimean.wordpress.com/2010/10/19/simple-cell-automata-in-haskell/
>>
>> Good luck.
>>
>> Tom
>>
>> On Tue, Dec 14, 2010 at 9:16 AM, Venanzio Capretta <[email protected]> 
>> wrote:
>> > Hi,
>> > ?I've been trying to find out what is the best GUI library to use for a
>> > Haskell beginner.
>> > At first I adopted gtk2hs and it was going well. But the web page for it 
>> > has
>> > disappeared during the Haskell site migration. So now I don't have access 
>> > to
>> > the documentation and the examples any more.
>> > Next I tried with wxHaskell, but unfortunately it doesn't install on Ubuntu
>> > (I checked on the mailing list: other people had the same problem and I
>> > don't understand the solution).
>> > Is there a library for GUI in Haskell that is simple to use and well
>> > supported, something that is user friendly for a beginner Haskell
>> > programmer?
>> > Best wishes,
>> > ?Venanzio
>> >
>> > _______________________________________________
>> > 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
>



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

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


End of Beginners Digest, Vol 30, Issue 22
*****************************************

Reply via email to