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
        [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:  Wrapping random (Andrew Sackville-West)
   2.  Installing Gtk2hs (Colin Paul Adams)
   3. Re:  Re: Homework help (was Re: Help in   Haskell) ([EMAIL PROTECTED])
   4.  In-place lazy I/O (Alexander Dunlap)
   5.  Re: Installing Gtk2hs (Andy Stewart)
   6. Re:  Re: Installing Gtk2hs (Colin Paul Adams)
   7. Re:  In-place lazy I/O (Magnus Therning)
   8. Re:  Re: Installing Gtk2hs (Colin Paul Adams)
   9. Re:  Re: Installing Gtk2hs (Colin Paul Adams)


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

Message: 1
Date: Sat, 29 Nov 2008 09:02:23 -0800
From: Andrew Sackville-West <[EMAIL PROTECTED]>
Subject: Re: [Haskell-beginners] Wrapping random
To: beginners@haskell.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"

On Fri, Nov 28, 2008 at 10:53:32PM +0100, Torsten Otto wrote:
> Hi all,
>
> I teach a high school class in Computer Science. The current programming 
> goal is to implement chat-bots, and we're using Haskell of course. Now 
> one of my students had the seemingly easy idea of having the bot answer 
> with a random sentence if it doesn't have "good" answer.

Perhaps instead of using a random number, you could simulate
randomness with some other technique. For example, if there is no good
response in a particular situation, you could hash the input and map
it to some predetermined responses. This would keep you in the IO
monad (I think. I'm a total rookie at this). You could then useit as a
vehicle to teach some other stuff such as the meaning of random in a
computer environment (vs true randomness) and concepts of hashing
(even looking into collisions in a simple way because the students
will see that different situations reliably give rise to the same
outout).

.02

A
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20081129/21f097d8/attachment-0001.bin

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

Message: 2
Date: Sat, 29 Nov 2008 21:39:46 +0000
From: Colin Paul Adams <[EMAIL PROTECTED]>
Subject: [Haskell-beginners] Installing Gtk2hs
To: beginners@haskell.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

The install instructions seem very straight-forward, but they are not
working for me.

I did:

./configure --enable-docs --disable-deprecated
make
su -c'make install'

but the demos won't compile (they can't find the libraries).

checking the stderr from make shows:

ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: mtl
make: *** Deleting file `package.conf.inplace'
package.conf.inplace: openBinaryFile: does not exist (No such file or directory)
package.conf.inplace: openBinaryFile: does not exist (No such file or directory)
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: base
ghc-pkg: Unversioned dependencies found: mtl
make[1]: *** Deleting file `package.conf.inplace'
package.conf.inplace: openBinaryFile: does not exist (No such file or directory)
package.conf.inplace: openBinaryFile: does not exist (No such file or directory)

on the commandline:
    Warning: -fffi is deprecated: use -XForeignFunctionInterface or pragma {-# 
LANGUAGE ForeignFunctionInterface#-} instead
package.conf.inplace: openBinaryFile: does not exist (No such file or directory)
make[1]: *** [glib/System/Glib.o] Error 1
make: *** [all] Error 2

My environment is Fedora 10 (64-bit). Ghc 6.10.1.

Any suggestions?
-- 
Colin Adams
Preston Lancashire


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

Message: 3
Date: Sat, 29 Nov 2008 18:25:59 -0500
From: [EMAIL PROTECTED]
Subject: Re: [Haskell-beginners] Re: Homework help (was Re: Help in
        Haskell)
To: beginners@haskell.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain;       charset=ISO-8859-1;     DelSp="Yes";
        format="flowed"

G'day all.

Quoting "Benjamin L.Russell" <[EMAIL PROTECTED]>:

> Actually, initially I had to fight the urge not to rewrite it in a
> less elitist manner, in order to avoid the possibility of offending
> the original author.

It was me, and I'm not offended.  By putting words on a Wiki, rather
than, say, a personal blog, I feel that I'm explicitly inviting others
to be bold and modify them.

> I could have risked going against the cultural attitude of the
> original author, who had deliberately used the pejorative term "stupid
> question."

Actually, the reason why I used that term is simpler than that: I'd
just read the "smart questions" FAQ, and my brain was pre-conditioned
in that direction.

Go ahead and change it.

Cheers,
Andrew Bromage


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

Message: 4
Date: Sat, 29 Nov 2008 16:43:22 -0800
From: "Alexander Dunlap" <[EMAIL PROTECTED]>
Subject: [Haskell-beginners] In-place lazy I/O
To: beginners@haskell.org
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1

Hi all,

Suppose my program has one or more persistent files that it reads at
or near the beginning of its execution and writes at or near the end.
Thus, an extremely simplified model of my program could be

> main = do
>   h <- openFile "some-file" ReadMode
>   c <- hGetContents h
>   w <- openFile "some-file" WriteMode
>   hPutStr w (f c)

where f is some arbitrary function.

My question is how to do this. It seems like the data from h won't
necessarily be forced until f is called when it is written, and there
is no guarantee that all of the data will even be used by f until it
is written. Thus, I will get a file-locking error when trying to write
the file. Do I have to rig things so that I know f will consume all of
its input? Is it better to use strict I/O? Is there a better idiom for
this entirely?

Thanks for all of your help.
Alex


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

Message: 5
Date: Sun, 30 Nov 2008 09:17:50 +0800
From: Andy Stewart <[EMAIL PROTECTED]>
Subject: [Haskell-beginners] Re: Installing Gtk2hs
To: beginners@haskell.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

Hi, Colin,

I found same problem with me.
I think gtk2hs can't compile success with GHC 6.10.1
So i back to 6.8

Regards,

  -- Andy.

Colin Paul Adams <[EMAIL PROTECTED]> writes:

> The install instructions seem very straight-forward, but they are not
> working for me.
>
> I did:
>
> ./configure --enable-docs --disable-deprecated
> make
> su -c'make install'
>
> but the demos won't compile (they can't find the libraries).
>
> checking the stderr from make shows:
>
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: mtl
> make: *** Deleting file `package.conf.inplace'
> package.conf.inplace: openBinaryFile: does not exist (No such file or 
> directory)
> package.conf.inplace: openBinaryFile: does not exist (No such file or 
> directory)
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: base
> ghc-pkg: Unversioned dependencies found: mtl
> make[1]: *** Deleting file `package.conf.inplace'
> package.conf.inplace: openBinaryFile: does not exist (No such file or 
> directory)
> package.conf.inplace: openBinaryFile: does not exist (No such file or 
> directory)
>
> on the commandline:
>     Warning: -fffi is deprecated: use -XForeignFunctionInterface or pragma 
> {-# LANGUAGE ForeignFunctionInterface#-} instead
> package.conf.inplace: openBinaryFile: does not exist (No such file or 
> directory)
> make[1]: *** [glib/System/Glib.o] Error 1
> make: *** [all] Error 2
>
> My environment is Fedora 10 (64-bit). Ghc 6.10.1.
>
> Any suggestions?



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

Message: 6
Date: Sun, 30 Nov 2008 05:47:58 +0000
From: Colin Paul Adams <[EMAIL PROTECTED]>
Subject: Re: [Haskell-beginners] Re: Installing Gtk2hs
To: beginners@haskell.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

>>>>> "Andy" == Andy Stewart <[EMAIL PROTECTED]> writes:

    Andy> Hi, Colin, I found same problem with me.  I think gtk2hs
    Andy> can't compile success with GHC 6.10.1 So i back to 6.8

Thanks Andy.

I removed ghc 6.10.1 then did a yum groupinstall haskell.

I then tried again. This time the configure failed because it couldn't
find haddock. I had to manually add a link from haddock to haddock-0.9
in /usr/bin. Clearly a problem with the rpm packaging for Fedora.

Now make fails with:

svgcairo/Graphics/Rendering/Cairo/SVG.chs:201:2:
    Couldn't match expected type `()' against inferred type `CInt'
      Expected type: Render ()
      Inferred type: Render CInt
    In the expression:
          liftIO
        $ (\ (SVG arg1) (Cairo arg2)
               -> withForeignPtr arg1
                $ \ argPtr1 -> rsvg_handle_render_cairo argPtr1 arg2)
            svg cr
    In the expression:
        do cr <- ask
             liftIO
           $ (\ (SVG arg1) (Cairo arg2)
                  -> withForeignPtr arg1
                   $ \ argPtr1 -> rsvg_handle_render_cairo argPtr1 arg2)
               svg cr
make[1]: *** [svgcairo/Graphics/Rendering/Cairo/SVG.o] Error 1
make: *** [all] Error 2

-- 
Colin Adams
Preston Lancashire


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

Message: 7
Date: Sun, 30 Nov 2008 07:04:12 +0000
From: Magnus Therning <[EMAIL PROTECTED]>
Subject: Re: [Haskell-beginners] In-place lazy I/O
To: Alexander Dunlap <[EMAIL PROTECTED]>
Cc: beginners@haskell.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="utf-8"

Alexander Dunlap wrote:
> Hi all,
> 
> Suppose my program has one or more persistent files that it reads at
> or near the beginning of its execution and writes at or near the end.
> Thus, an extremely simplified model of my program could be
> 
>> main = do
>>   h <- openFile "some-file" ReadMode
>>   c <- hGetContents h
>>   w <- openFile "some-file" WriteMode
>>   hPutStr w (f c)
> 
> where f is some arbitrary function.
> 
> My question is how to do this. It seems like the data from h won't
> necessarily be forced until f is called when it is written, and there
> is no guarantee that all of the data will even be used by f until it
> is written. Thus, I will get a file-locking error when trying to write
> the file. Do I have to rig things so that I know f will consume all of
> its input? Is it better to use strict I/O? Is there a better idiom for
> this entirely?

I think a fairly common way to solve this is to change your program to
basically do

  main = do
    h <- openFile "some-file" ReadMode
    c <- hGetContents h
    w <- openFile "temp-file"
    hPutStr w (f c)
    hClose w
    renameFile "temp-file" "some-file"

Of course there may still be some laziness issues to keep in mind.  But
I believe that should take care of any locking issues your OS might
throw at you.

/M

-- 
Magnus Therning                             (OpenPGP: 0xAB4DFBA4)
magnus@therning.org             Jabber: magnus@therning.org
http://therning.org/magnus

Haskell is an even 'redder' pill than Lisp or Scheme.
     -- PaulPotts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
Url : 
http://www.haskell.org/pipermail/beginners/attachments/20081130/d61131fa/signature-0001.bin

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

Message: 8
Date: Sun, 30 Nov 2008 09:08:57 +0000
From: Colin Paul Adams <[EMAIL PROTECTED]>
Subject: Re: [Haskell-beginners] Re: Installing Gtk2hs
To: beginners@haskell.org
Cc: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

>>>>> "Colin" == Colin Paul Adams <[EMAIL PROTECTED]> writes:

>>>>> "Andy" == Andy Stewart <[EMAIL PROTECTED]> writes:
    Andy> Hi, Colin, I found same problem with me.  I think gtk2hs
    Andy> can't compile success with GHC 6.10.1 So i back to 6.8

    Colin> Thanks Andy.

    Colin> I removed ghc 6.10.1 then did a yum groupinstall haskell.

    Colin> I then tried again. This time the configure failed because
    Colin> it couldn't find haddock. I had to manually add a link from
    Colin> haddock to haddock-0.9 in /usr/bin. Clearly a problem with
    Colin> the rpm packaging for Fedora.

    Colin> Now make fails with:

    Colin> svgcairo/Graphics/Rendering/Cairo/SVG.chs:201:2: Couldn't
    Colin> match expected type `()' against inferred type `CInt'
    Colin> Expected type: Render () Inferred type: Render CInt In the
    Colin> expression: liftIO $ (\ (SVG arg1) (Cairo arg2)
    -> withForeignPtr arg1
    Colin>                 $ \ argPtr1 -> rsvg_handle_render_cairo
    Colin> argPtr1 arg2) svg cr In the expression: do cr <- ask liftIO
    Colin> $ (\ (SVG arg1) (Cairo arg2)
    -> withForeignPtr arg1
    Colin>                    $ \ argPtr1 -> rsvg_handle_render_cairo
    Colin> argPtr1 arg2) svg cr make[1]: ***
    Colin> [svgcairo/Graphics/Rendering/Cairo/SVG.o] Error 1 make: ***
    Colin> [all] Error 2

So I tried changing Render () to Render CInt in four places in
SVG.chs.

Now it installs OK with 6.8.3, and all the demos run.

I'd have a go at getting it to work with 6.10.1 if I knew what to do.
It appears the library structure has changed incompatibly (and ghc
didn't even change its version number - that's pretty bad). Is there a
document anywhere that details the structure changes?
-- 
Colin Adams
Preston Lancashire


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

Message: 9
Date: Sun, 30 Nov 2008 09:24:31 +0000
From: Colin Paul Adams <[EMAIL PROTECTED]>
Subject: Re: [Haskell-beginners] Re: Installing Gtk2hs
To: beginners@haskell.org
Cc: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

>>>>> "Colin" == Colin Paul Adams <[EMAIL PROTECTED]> writes:

    Colin> Now it installs OK with 6.8.3, and all the demos run.

Well, not quite all:

mozembed fails to compile with:

TestEmbedMoz.hs:5:7:
    Could not find module `Graphics.UI.Gtk.MozEmbed':
      Use -v to see a list of the files searched for.
make: *** [testembedmoz] Error 1

And the svgviewer programs fail at runtime with:

svgviewer: user error (Pattern match failure in do expression at 
SvgViewer.hs:11:2-9)

and:

svg2png: user error (Pattern match failure in do expression at 
Svg2Png.hs:9:2-18)

and for treelist:

make: *** No rule to make target `TreeSort.hs', needed by `treesort'.  Stop.

and for opengl:

ghc --make RotatingCube.hs -o cube 

RotatingCube.hs:7:17:
    Could not find module `Graphics.UI.Gtk.OpenGL':
      Use -v to see a list of the files searched for.
make: *** [cube] Error 1

and for sourceview:

ghc --make SourceViewTest.hs -o sourceview 

SourceViewTest.hs:5:7:
    Could not find module `Graphics.UI.Gtk.SourceView':
      Use -v to see a list of the files searched for.
make: *** [sourceview] Error 1

-- 
Colin Adams
Preston Lancashire


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

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


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

Reply via email to