Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Re: [Haskell-cafe] Unable to install packages (Tim Baumgartner)
   2.  hGetContents, unicode and linux (Erik de Castro Lopo)
   3. Re:  hGetContents, unicode and linux (Michael Snoyman)
   4. Re:  hGetContents, unicode and linux (Yitzchak Gale)
   5. Re:  hGetContents, unicode and linux (Yitzchak Gale)
   6. Re:  hGetContents, unicode and linux (Erik de Castro Lopo)
   7. Re:  hGetContents, unicode and linux (Michael Snoyman)
   8. Re:  hGetContents, unicode and linux (Michael Snoyman)


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

Message: 1
Date: Sat, 27 Nov 2010 20:14:37 +0100
From: Tim Baumgartner <baumgartner....@googlemail.com>
Subject: [Haskell-beginners] Re: [Haskell-cafe] Unable to install
        packages
To: beginners@haskell.org
Message-ID:
        <aanlktinhj2c2bogk=p8--lp_yhv3zu5jptbs37nl2...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi Roland,

I installed Leksah on Ubuntu 10.10 recently using the instructions
found on 
http://rizwanbulbul.blogspot.com/2010/06/installing-leksah-gtk-gtk2hs-and-glade.html
It was quite straight forward for me.

Regards
Tim


2010/11/27 Roland Senn <r...@bluewin.ch>:
>  I learned a little bit Haskell with Hugs on Windows and now I want to
> develop on Linux.
>
> I installed the Haskell Platform on Unbunto 10.10. There were no problems.
> Then I tried to install Leksah with
> sudo cabal install leksah --global
> It failed with:
> Resolving dependencies...
> /tmp/gtksourceview2-0.11.12661/gtksourceview2-0.11.1/Gtk2HsSetup.hs:25:0:
>     warning: #warning Setup.hs is guessing the version of Cabal. If
> compilation of Setup.hs fails use -DCABAL_VERSION_MINOR=x for Cabal version
> 1.x.0 when building (prefixed by --ghc-option= when using the 'cabal'
> command)
> [1 of 2] Compiling Gtk2HsSetup      (
> /tmp/gtksourceview2-0.11.12661/gtksourceview2-0.11.1/Gtk2HsSetup.hs,
> /tmp/gtksourceview2-0.11.12661/gtksourceview2-0.11.1/dist/setup/Gtk2HsSetup.o
> )
> [2 of 2] Compiling Main             (
> /tmp/gtksourceview2-0.11.12661/gtksourceview2-0.11.1/Setup.hs,
> /tmp/gtksourceview2-0.11.12661/gtksourceview2-0.11.1/dist/setup/Main.o )
> Linking
> /tmp/gtksourceview2-0.11.12661/gtksourceview2-0.11.1/dist/setup/setup ...
> Configuring gtksourceview2-0.11.1...
> Preprocessing library gtksourceview2-0.11.1...
> Building gtksourceview2-0.11.1...
> [ 1 of 13] Compiling Graphics.UI.Gtk.SourceView.Signals (
> dist/build/Graphics/UI/Gtk/SourceView/Signals.hs,
> dist/build/Graphics/UI/Gtk/SourceView/Signals.o )
> Graphics/UI/Gtk/SourceView/Signals.chs:51:46:
>    Module `System.Glib.UTFString' does not export `maybePeekUTFString'
> cabal: Error: some packages failed to install:
> gtksourceview2-0.11.1 failed during the building phase. The exception was:
> ExitFailure 1
> leksah-0.8.0.8 depends on gtksourceview2-0.11.1 which failed to install.
>
> I searched the Internet on "gtksourceview2 maybePeekUTFString" and found a
> patch:
> http://www.mail-archive.com/gtk2hs-de...@lists.sourceforge.net/msg00971/gtk_0_11_2-needs-glib--__-0_11_2-for-maybepeekutfstring.dpatch
>
> As a newby with the Haskell tools, I searched the Internet on how to install
> a patch.
> I found dpm and I tried to install it with:
>
> sudo cabal install dpm --global
>
> It failed with:
> configure: error: in `/tmp/terminfo-0.3.1.31936/terminfo-0.3.1.3':
> configure: error: curses headers could not be found, so this package cannot
> be built
> See `config.log' for more details.
> cabal: Error: some packages failed to install:
> DPM-0.2.1 depends on terminfo-0.3.1.3 which failed to install.
> darcs-2.5 depends on terminfo-0.3.1.3 which failed to install.
> haskeline-0.6.3.2 depends on terminfo-0.3.1.3 which failed to install.
> terminfo-0.3.1.3 failed during the configure step. The exception was:
> ExitFailure 1
>
> So after installing Haskell Platform, I only found broken packages!
>
> What can I do to install Leksah?
> _______________________________________________
> Haskell-Cafe mailing list
> haskell-c...@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


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

Message: 2
Date: Sun, 28 Nov 2010 17:26:44 +1100
From: Erik de Castro Lopo <mle...@mega-nerd.com>
Subject: [Haskell-beginners] hGetContents, unicode and linux
To: beginners@haskell.org
Message-ID: <20101128172644.066cb32c.mle...@mega-nerd.com>
Content-Type: text/plain; charset=US-ASCII

Hi all,

I've got a trivial test program:

    main :: IO ()
    main
     = do   text <- readFile "unicode.txt"
            putStr text

which I compile with ghc-6.12.1 (from Debian) and when it runs I get:

    hGetContents: invalid argument (Invalid or incomplete multibyte or wide 
character)

I've done some googling which seems to suggest that I need to set
the LANG environment variable, but I already have that set to
en_AU.UTF-8.

Clues?

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


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

Message: 3
Date: Sun, 28 Nov 2010 08:35:58 +0200
From: Michael Snoyman <mich...@snoyman.com>
Subject: Re: [Haskell-beginners] hGetContents, unicode and linux
To: beginners@haskell.org
Message-ID:
        <aanlktimv3woolprajoscnesgnr5rbmhnyjumar_-n...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Nov 28, 2010 at 8:26 AM, Erik de Castro Lopo
<mle...@mega-nerd.com> wrote:
> Hi all,
>
> I've got a trivial test program:
>
>    main :: IO ()
>    main
>     = do   text <- readFile "unicode.txt"
>            putStr text
>
> which I compile with ghc-6.12.1 (from Debian) and when it runs I get:
>
>    hGetContents: invalid argument (Invalid or incomplete multibyte or wide 
> character)
>
> I've done some googling which seems to suggest that I need to set
> the LANG environment variable, but I already have that set to
> en_AU.UTF-8.
>
> Clues?
>
> Cheers,
> Erik

Perhaps a silly question, but are you certain that the input file is
valid UTF-8? You could also try using the readFile from
utf8-string[1], which I believe ignores improper UTF8 sequences. A
theoretically better approach is to read the contents as a lazy
bytestring and then use the decode functions from the text package,
but that's a little bit more work.

[1] 
http://hackage.haskell.org/packages/archive/utf8-string/0.3.6/doc/html/System-IO-UTF8.html#v:readFile


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

Message: 4
Date: Sun, 28 Nov 2010 08:40:32 +0200
From: Yitzchak Gale <g...@sefer.org>
Subject: Re: [Haskell-beginners] hGetContents, unicode and linux
To: beginners@haskell.org
Message-ID:
        <aanlktim0=k_n0ah7u=98vvxiy96ou9klz8geuszmy...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Erik de Castro Lopo wrote:
>    hGetContents: invalid argument (Invalid or incomplete multibyte or wide 
> character)
> I've done some googling which seems to suggest that I need to set
> the LANG environment variable, but I already have that set to
> en_AU.UTF-8.

You can check to see what encoding GHC has picked up from your
environment by examining localeEncoding.

You can force the encoding to UTF-8 by

hSetEncoding stdin utf8
hSetEncoding stdout utf8

All of the above in the context of import System.IO, of course.

Regards,
Yitz


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

Message: 5
Date: Sun, 28 Nov 2010 08:53:56 +0200
From: Yitzchak Gale <g...@sefer.org>
Subject: Re: [Haskell-beginners] hGetContents, unicode and linux
To: Michael Snoyman <mich...@snoyman.com>
Cc: beginners@haskell.org
Message-ID:
        <aanlktimhhcud2mgred8x5pplhsynpkcob_y+ooxqz...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Michael Snoyman wrote:
> Perhaps a silly question, but are you certain that the input file is
> valid UTF-8?

That is a very good point.

> You could also try using the readFile from utf8-string...
> [or] read the contents as a lazy
> bytestring and then use the decode functions...

Those approaches are now both deprecated. Either do
what you are doing, which gives you conceptually simple
strings as lists of Char. Or, for better efficiency, use
the text package:

>    import qualified Data.Text.Lazy as T
>    main :: IO ()
>    main
>     = do   text <- T.readFile "unicode.txt"
>            T.putStr text

In any case, you still need to have the correct encoding
set on the handles as before. (And the input needs to
be valid for your selected encoding.)

Regards,
Yitz


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

Message: 6
Date: Sun, 28 Nov 2010 18:18:55 +1100
From: Erik de Castro Lopo <mle...@mega-nerd.com>
Subject: Re: [Haskell-beginners] hGetContents, unicode and linux
To: beginners@haskell.org
Message-ID: <20101128181855.cab0f234.mle...@mega-nerd.com>
Content-Type: text/plain; charset=US-ASCII

Yitzchak Gale wrote:

> You can check to see what encoding GHC has picked up from your
> environment by examining localeEncoding.

How do I do that? TextEncoding doesn't seem to be Showable.

> You can force the encoding to UTF-8 by
> 
> hSetEncoding stdin utf8
> hSetEncoding stdout utf8
> 
> All of the above in the context of import System.IO, of course.

Thank you. My program:

    main :: IO ()
    main
     = do   h <- openFile "unicode.txt" ReadMode
            hSetEncoding h utf8
            hSetEncoding stdout utf8
            text <- hGetContents h
            putStr text

now works as it should.

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


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

Message: 7
Date: Sun, 28 Nov 2010 09:19:58 +0200
From: Michael Snoyman <mich...@snoyman.com>
Subject: Re: [Haskell-beginners] hGetContents, unicode and linux
To: g...@sefer.org
Cc: beginners@haskell.org
Message-ID:
        <aanlktikucwgvsscxjrexpyqo=f9sn2ycqcgzuunon...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Nov 28, 2010 at 8:53 AM, Yitzchak Gale <g...@sefer.org> wrote:
> Michael Snoyman wrote:
>> Perhaps a silly question, but are you certain that the input file is
>> valid UTF-8?
>
> That is a very good point.
>
>> You could also try using the readFile from utf8-string...
>> [or] read the contents as a lazy
>> bytestring and then use the decode functions...
>
> Those approaches are now both deprecated. Either do
> what you are doing, which gives you conceptually simple
> strings as lists of Char. Or, for better efficiency, use
> the text package:
>
>>    import qualified Data.Text.Lazy as T
>>    main :: IO ()
>>    main
>>     = do   text <- T.readFile "unicode.txt"
>>            T.putStr text
>
> In any case, you still need to have the correct encoding
> set on the handles as before. (And the input needs to
> be valid for your selected encoding.)

Which is why I would actually recommend sticking with the
bytestring/text combination when you know what the file encoding will
be and it is not system-dependent. It's the approach that I use with
Hamlet et al for precisely that reason.

Michael


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

Message: 8
Date: Sun, 28 Nov 2010 09:27:19 +0200
From: Michael Snoyman <mich...@snoyman.com>
Subject: Re: [Haskell-beginners] hGetContents, unicode and linux
To: g...@sefer.org
Cc: beginners@haskell.org
Message-ID:
        <aanlktimcmb0blhe1ydgzpwrtxt_5ia1sgdeug4gjm...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Nov 28, 2010 at 9:19 AM, Michael Snoyman <mich...@snoyman.com> wrote:
> On Sun, Nov 28, 2010 at 8:53 AM, Yitzchak Gale <g...@sefer.org> wrote:
>> Michael Snoyman wrote:
>>> Perhaps a silly question, but are you certain that the input file is
>>> valid UTF-8?
>>
>> That is a very good point.
>>
>>> You could also try using the readFile from utf8-string...
>>> [or] read the contents as a lazy
>>> bytestring and then use the decode functions...
>>
>> Those approaches are now both deprecated. Either do
>> what you are doing, which gives you conceptually simple
>> strings as lists of Char. Or, for better efficiency, use
>> the text package:
>>
>>>    import qualified Data.Text.Lazy as T
>>>    main :: IO ()
>>>    main
>>>     = do   text <- T.readFile "unicode.txt"
>>>            T.putStr text
>>
>> In any case, you still need to have the correct encoding
>> set on the handles as before. (And the input needs to
>> be valid for your selected encoding.)
>
> Which is why I would actually recommend sticking with the
> bytestring/text combination when you know what the file encoding will
> be and it is not system-dependent. It's the approach that I use with
> Hamlet et al for precisely that reason.

Sorry for replying to myself, but I didn't clarify that very well.
You're right that setting encoding on the handle can work well enough
for this, but it does *not* address invalid byte sequences (AFAIK),
which can be dealt with using the bytestring/text decoding
combination.

Michael


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

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 29, Issue 44
*****************************************

Reply via email to