[Haskell-cafe] map/reduce example

2007-11-26 Thread Bulat Ziganshin
Hello Haskell-Cafe,

i've written small program which demonstrates how map/reduce may be
implemented in Haskell. it counts amount of words in file, splitting
it into 64kb blocks processed by two threads. their results are
combined by another two threads. how it may be made better? in
particular, is it strict in values send over channels?

{-# LANGUAGE BangPatterns #-}

import Control.Concurrent
import Control.Concurrent.Chan
import Control.Monad
import Data.IORef
import Data.ByteString.Char8 as B hiding (length)
import System.Environment
import System.IO

main = do
  (file:_) - getArgs
  h - openBinaryFile file ReadMode

  map- newChan
  reduce - newChan
  result - newChan

  replicateM_ 2 (forkIO$ mapThread map reduce)  
  replicateM_ 2 (forkIO$ reduceThread reduce result)

  jobs - new 0
  untilM (hIsEOF h) $ do
str - B.hGet h 65536
writeChan map str
jobs += 1

  jobs' - val jobs
  writeChan reduce (0,-jobs')

  res - readChan result
  print res

  
mapThread map reduce =
  forever $ do
str - readChan map
let !sum = length (B.words str)
writeChan reduce (sum,1)

reduceThread reduce result =
  forever $ do
(sum1,n1) - readChan reduce
(sum2,n2) - readChan reduce
let (!sum,!n) = (sum1+sum2,n1+n2)
case n of
  0 - writeChan result sum
  _ - writeChan reduce (sum,n)


untilM cond action = do
  deny - cond
  unless deny $ do
action
untilM cond action

forever action  =  action  forever action

infixl 0 =:, +=
new = newIORef
val = readIORef
a=:b = writeIORef a b
a+=b = modifyIORef a (\a-a+b)


-- 
Best regards,
 Bulat  mailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: is there a more concise way to generate helper functions for a datatype built on records?

2007-11-26 Thread Benedikt Huber

Neil Mitchell wrote:
 Hi

 Some of these can be automatically derived by the Data.Derive tool...
 The derivations Set, Is, From, Has, LazySet all look useful.
 ...

 On Nov 24, 2007 4:01 PM, Thomas Hartman [EMAIL PROTECTED] wrote:
 I think I'm running into more or less the same issue discussed at

 http://bloggablea.wordpress.com/2007/04/24/haskell-records-considered-grungy/

 Just wondering if I missed anything, or if any of the ideas
 considering better records setter/getters have been implemented in  
the

 meantime.

Hi,
the Ref deriviation (included in Data.Derive) seems to be a good way  
to solve some aspects

of this problem; I have some questions on my own though.
Here is a working example of updating the two player's state in the  
pong game:


 {-# OPTIONS -cpp #-}
 {-# OPTIONS_DERIVE --output=file.h #-}
 module Main where
 import Control.Arrow
 #include file.h

Refs as in (http://www.haskell.org/pipermail/haskell-cafe/2007-June/026477.html 
):


 type Upd a = a - a
 data Ref cx t
 = Ref { select :: cx - t , update :: Upd t - Upd cx }
 (@.) :: Ref a b - Ref b c - Ref a c
 a @. b
 =  Ref { select = select b . select a,
  update = update a . update b }

The game model:

 data Object2D
  = Object2D { x :: Double, y :: Double } deriving (Show {-! Ref !-})
 data Player
 = Player { points :: Int, pos :: Object2D } deriving (Show {-!  
Ref !-})

 data Game
 = Game { p1 :: Player, p2 :: Player, ball :: Object2D } deriving  
(Show {-! Ref !-})

 sampleGame :: Game
 sampleGame = Game { p1 = Player 0 (Object2D 5 0), p2 = Player 0  
(Object2D 5 10), ball = Object2D 5 5 }


Game update proceeds in several steps, we now consider the first one:
Updating the 2 player's position - this happens, at least  
conceptually, *in paralell*
(for example: both players might be aloud to have a look at the other  
players position in the last turn, but

not at the updated position).

Here's the update for one player:

 updatePlayerPos :: Bool - Upd Player
 updatePlayerPos moveRight
  = update (refPos @. refX) $
case moveRight of
  True  - ((min 10) . (+1))
  False - ((max  0) . (+(-1)))

If sequential update is ok for us, the game state update is simply:

 updatePositions :: Bool - Bool - Upd Game
 updatePositions move1 move2 = update refP1 (updatePlayerPos  
move1) . update refP2 (updatePlayerPos move2)


To get it *actually* work in parallel we have to create a new  
reference for both players:


 refPlayers :: Ref Game (Player,Player)
 refPlayers = Ref { select = select refP1  select refP2,
update = \pu g - let (p1',p2') = pu (p1 g, p2  
g) in g { p1 = p1', p2 = p2' } }


While the select part of the Ref is expressed using , I don't know  
how the

paralell update can be expressed in terms of combinators. Any hints ?

Now, the game state update in the parallel version is easy. Note that  
it would also be possible now
to take one player's position into account when updating the other  
player's position:


 updatePositionsPar move1 move2 = (update refPlayers) $  
updatePlayerPos move1 *** updatePlayerPos move2


So, the Ref deriviation is really nice for sequential updates;
paralell updates on the other hand need some work.
Furthermore, I don't really know how well Refs work if updates
need information on other parts of the state without modifying it.
(e.g. the AI player needs to know where the ball is, but does not  
modify the ball).

I'd really appreciate if anyone has some additional clues.

thanks,
benedikt
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Old editions of The Monad.Reader lost

2007-11-26 Thread Wouter Swierstra


On 18 Aug 2007, at 20:10, Henk-Jan van Tuyl wrote:

Now that all hawiki pages have been removed, we have lost some  
valuable information. For example The Monad.Reader; on http:// 
www.haskell.org/haskellwiki/The_Monad.Reader


A few people have been asking what has happened to old editions of  
the Monad.Reader. I'm happy to announce that almost all authors have  
agreed to the new Haskellwiki license.


I have added the .pdf of the very first issue to the Monad.Reader  
homepage; Shae Erisson was kind enough to set up a wiki hosting the  
later issues.


http://www.haskell.org/sitewiki/images/9/9d/TMR-Issue1.pdf

http://www.haskell.org/tmrwiki/

Both are links can be found on the Monad.Reader homepage.

If anyone is inclined to port the MoinMoin content to the Haskellwiki  
format, I'd be happy to provide them with a list of all the authors  
that have agreed with the new license.


  Wouter



This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Pretty-printing peg solitaire boards

2007-11-26 Thread Maurí­cio

 (...)However, I'm doing that because there's a
 single position which my brother could not
 solve, and he believes it to be impossible(...)


 I guess you meant
   #0#
   #0#
 ###0###
 ###
 ###
   ###
   ###

 This indeed can not be solved. (...)

Actually, I did mean to start with:

  ###
  ###
###0###
###
###
  ###
  ###

and then go to:

  #0#
  #0#
###
###
###
  ###
  ###

My brother's idea is that he can solve any board
after you choose the initial peg to be removed and
the first move. He can do it for any combination,
except for this one.

But your argument is very interesting, indeed!
I'll try to find that book, we'll like to read it.

Best,
Maurício

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New slogan for haskell.org

2007-11-26 Thread Henning Thielemann

On Thu, 4 Oct 2007, Don Stewart wrote:

 The Haskell website has the rather strange motivational text:

 Haskell is a general purpose, purely functional programming language
 featuring static typing, higher order functions, polymorphism, type
 classes, and monadic effects. Haskell compilers are freely available
 for almost any computer.

To continue an old thread: What about turning the strange words like
'monadic effects' into links to glossary articles?

Btw. where is 'lazy' ?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New slogan for haskell.org

2007-11-26 Thread Henning Thielemann

On Mon, 26 Nov 2007, Thomas Davie wrote:

 On 26 Nov 2007, at 15:15, Henning Thielemann wrote:

 
  On Thu, 4 Oct 2007, Don Stewart wrote:
 
  The Haskell website has the rather strange motivational text:
 
 Haskell is a general purpose, purely functional programming
  language
 featuring static typing, higher order functions, polymorphism,
  type
 classes, and monadic effects. Haskell compilers are freely
  available
 for almost any computer.
 
  To continue an old thread: What about turning the strange words like
  'monadic effects' into links to glossary articles?
 
  Btw. where is 'lazy' ?

 I believe the point of this discussion was that anyone reading the
 Haskell webpage will currently get about as far as featuring static
 typing, and go this is all very nice, but what exactly does this
 language do for me?  Why should I use it?.  Take for example what the
 python website says:

I didn't want to repeat the discussion. I think the discussion ended with:
Anything more helpful would be too long for the title line at haskell.org,
and a more detailed explanation (but not a generic advertisement like that
from Python) should be reachable easily. Now my idea was, that making
links to glossary articles leaves the slogan as short as it is, and allows
people to find out quickly about the words they still don't know. An
explanation why Haskell's features are useful for programmers is still
required.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] The Monad.Reader - Call for Copy

2007-11-26 Thread Wouter Swierstra

Call for Copy
The Monad.Reader - Issue 10


I would like to welcome articles for the anniversary issue of The  
Monad.Reader.


* The Monad.Reader *

The Monad.Reader is an electronic magazine about all things Haskell.  
It is less-formal than journal, but somehow more enduring than a wiki- 
page. There have been a wide variety of articles, including: exciting  
code fragments, intriguing puzzles, book reviews, tutorials, and even  
half-baked research ideas.


* Submission Details *

Get in touch with me if you intend to submit something -- the sooner  
you let me know what you're up to, the better.


Please submit articles for the next issue by e-mail (wss at  
cs.nott.ac.uk) to me before


  ** January 25, 2008 **

Articles should be written according to the guidelines available from

http://www.haskell.org/haskellwiki/The_Monad.Reader

Please submit your article in PDF, together with any source files you  
used. The sources will be released together with the magazine under a  
BSD license.


If you would like to submit an article, but have trouble with LaTeX  
please let me know and we'll sort something out.


Looking forward to your submission,

  Wouter


This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New demo/test program for Yhc Javascript backend

2007-11-26 Thread Thomas Hartman
It would be really helpful if you could include this (and other)
examples in an /examples directory under

src/translator/js

in the yhc darcs distribution, with working makefiles that validate
against the buildbot.

Something seems a bit off for me, probably forgot a tilde somewheres.

t.

2007/11/17, Dimitry Golubovsky [EMAIL PROTECTED]:
 Hi,

 For those of you who are interested in using Haskell in client-side
 web application programming:

 I have added a new demo/test program to this Wiki page (Does it leak?):

 http://haskell.org/haskellwiki/Yhc/Javascript

 This demo program shows some progress made since the first
 announcement of Yhc Javascript backend (Core to Javascript converter)
 was made about a year ago. Please test the demo for functionality and
 memory leaks in various browsers. Your feedback is appreciated.

 The demo program is self-contained (does not require any Haskell
 libraries beyond those included with Yhc). There is a darcs repo:
 http://www.golubovsky.org/repos/wsptest/ from which this demo program
 along with Makefile can be obtained if anybody wants to play with the
 code.

 Thanks.

 --
 Dimitry Golubovsky

 Anywhere on the Web
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Pretty-printing peg solitaire boards

2007-11-26 Thread Bertram Felgenhauer
Maur??cio wrote:
 Actually, I did mean to start with:

   ###
   ###
 ###0###
 ###
 ###
   ###
   ###

 and then go to:

   #0#
   #0#
 ###
 ###
 ###
   ###
   ###

 My brother's idea is that he can solve any board
 after you choose the initial peg to be removed and
 the first move. He can do it for any combination,
 except for this one.

Heh. He's in for a surprise, there are actually solutions for this.
It was surprisingly hard to find one though. Thanks for the puzzle.
(I won't spoil it here. Ask me off list if you're interested.)

 But your argument is very interesting, indeed!
 I'll try to find that book, we'll like to read it.

It's a series of three books actually. Sadly it's been a long
time since I've read them so I forgot which volume covers which
topics.

Bertram
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] getDirectoryContents still causing problems Re: problems building ycr2js (hopefully fixed)

2007-11-26 Thread Thomas Hartman
still having problems darcs pulling your updates, related to System.FilePath.

did you make clean and then make again?

I darcs pulled everything.

(cd src/translator/js; make all install)

... ...
(cd 
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskell;
\
  for f in `find . -name '*.hs' | sort` ; do make -s -f
/home/thartman/haskell-installs/yhc-install/yhc/src/translat\
or/js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)

-s flag silences, we don't want that, with verbose output again we see
that make is failing for a huge number of packages

(cd /home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/h\
askell; \
  for f in `find . -name '*.hs' | sort` ; do make -f
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/\
js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
 yhc --core --no-bytecode CDOM/Level1/DomUtils.hs
yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)

make: *** [CDOM/Level1/DomUtils.ycr] Error 1
yhc --core --no-bytecode CDOM/Level1/Events.hs
yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)

...

[EMAIL 
PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskellyhc
--core --no-bytecode CDOM/Level1/DomUtils\
.hs
yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)

Unfamiliar with yhc, I couldn't figure out where getDirectory contents
is being called from.

Grepping at the root, I guess something here is causing problems

[EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhcgrep -irl
getDirectoryContents *
Make/Useful.hs
inst/bin/yhc
src/compiler98/Package.hs
src/packages/yhc-base-1.0/System/Directory.hs
src/packages/haskell98-1.0/Directory.hs
src/tester/Main.hs
tests/conformance98/Directory/getDirContents/Main.hs

best, thomas.

2007/11/25, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 On Nov 25, 2007 5:50 PM, Thomas Hartman [EMAIL PROTECTED] wrote:
  Thanks Dmitri, I also had to fix an issue with System.FilePath,
  there's a message about this on haskell cafe.

 In fact, takeDirectory is the right replacement for getDirectory in
 older FilePath. I have pushed this change too.

 Thanks.

 --
 Dimitry Golubovsky

 Anywhere on the Web

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: getDirectoryContents still causing problems Re: problems building ycr2js (hopefully fixed)

2007-11-26 Thread Thomas Hartman
False alarm.

I rm -rf ed yhhc, fresh darcs got the latest yhc, reinstalled yhc, and redid

(cd src/translator/js; make all install)

and it built.


2007/11/26, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 It looks like this comes from Yhc, not from the Javascript backend.

 Have you done the full sequence of (starting with clean repo)?

 darcs get darcs.haskell.org/yhc
 scons core=1 build
 scons prefix=... install # whatever your stuff goes, and yhc will be
 in bin/ from that, and this bin/ should be on your path
 (cd src/translator/js; make all install)

 Please let me know where it fails.

 Thank you.

 On 11/26/07, Thomas Hartman [EMAIL PROTECTED] wrote:
  still having problems darcs pulling your updates, related to 
  System.FilePath.
 
  did you make clean and then make again?
 
  I darcs pulled everything.
 
  (cd src/translator/js; make all install)
 
  ... ...
  (cd 
  /home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskell;
  \
   for f in `find . -name '*.hs' | sort` ; do make -s -f
  /home/thartman/haskell-installs/yhc-install/yhc/src/translat\
  or/js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
  yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
  getDirectoryContents: does not exist (No such fi\
  le or directory)
 
  -s flag silences, we don't want that, with verbose output again we see
  that make is failing for a huge number of packages
 
  (cd /home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/h\
  askell; \
   for f in `find . -name '*.hs' | sort` ; do make -f
  /home/thartman/haskell-installs/yhc-install/yhc/src/translator/\
  js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
   yhc --core --no-bytecode CDOM/Level1/DomUtils.hs
  yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
  getDirectoryContents: does not exist (No such fi\
  le or directory)
 
  make: *** [CDOM/Level1/DomUtils.ycr] Error 1
  yhc --core --no-bytecode CDOM/Level1/Events.hs
  yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
  getDirectoryContents: does not exist (No such fi\
  le or directory)
 
  ...
 
  [EMAIL 
  PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskellyhc
  --core --no-bytecode CDOM/Level1/DomUtils\
  .hs
  yhc: /home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
  getDirectoryContents: does not exist (No such fi\
  le or directory)
 
  Unfamiliar with yhc, I couldn't figure out where getDirectory contents
  is being called from.
 
  Grepping at the root, I guess something here is causing problems
 
  [EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhcgrep -irl
  getDirectoryContents *
  Make/Useful.hs
  inst/bin/yhc
  src/compiler98/Package.hs
  src/packages/yhc-base-1.0/System/Directory.hs
  src/packages/haskell98-1.0/Directory.hs
  src/tester/Main.hs
  tests/conformance98/Directory/getDirContents/Main.hs
 
  best, thomas.
 
  2007/11/25, Dimitry Golubovsky [EMAIL PROTECTED]:
   Thomas,
  
   On Nov 25, 2007 5:50 PM, Thomas Hartman [EMAIL PROTECTED] wrote:
Thanks Dmitri, I also had to fix an issue with System.FilePath,
there's a message about this on haskell cafe.
  
   In fact, takeDirectory is the right replacement for getDirectory in
   older FilePath. I have pushed this change too.
  
   Thanks.
  
   --
   Dimitry Golubovsky
  
   Anywhere on the Web
  
 


 --
 Dimitry Golubovsky

 Anywhere on the Web

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: getDirectoryContents still causing problems Re: problems building ycr2js (hopefully fixed)

2007-11-26 Thread Thomas Hartman
Based on my experience, I wouldn't recommend doing scons fullclean;
rather, I would darcs checkout and go from scratch. Annoying, but
seems to work better.

thomas.



2007/11/26, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 This happens sometimes as Yhc depends on many other packages not very
 well in sync (e. g. FilePath). Plus, internal dependencies are not
 always tracked very well. Or binary core format gets upgraded (that
 means, the core linker does not accept older versions of core files,
 and all of them have to be regenerated).

 You may see sometimes recommendations in the Yhc mailing list: pull
 patches, then do scons fullclean. Or re-check the whole repo out,
 which is basically the same.

 Thanks.

 On 11/26/07, Thomas Hartman [EMAIL PROTECTED] wrote:
  False alarm.
 
  I rm -rf ed yhhc, fresh darcs got the latest yhc, reinstalled yhc, and redid
 
  (cd src/translator/js; make all install)
 
  and it built.
 
  2007/11/26, Dimitry Golubovsky [EMAIL PROTECTED]:
   Thomas,
  
   It looks like this comes from Yhc, not from the Javascript backend.
  
   Have you done the full sequence of (starting with clean repo)?
  
   darcs get darcs.haskell.org/yhc
   scons core=1 build
   scons prefix=... install # whatever your stuff goes, and yhc will be
   in bin/ from that, and this bin/ should be on your path
   (cd src/translator/js; make all install)
  
   Please let me know where it fails.
  
   Thank you.
  
   On 11/26/07, Thomas Hartman [EMAIL PROTECTED] wrote:
still having problems darcs pulling your updates, related to 
System.FilePath.
   
did you make clean and then make again?
   
I darcs pulled everything.
   
(cd src/translator/js; make all install)
   
... ...
(cd 
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskell;
\
 for f in `find . -name '*.hs' | sort` ; do make -s -f
/home/thartman/haskell-installs/yhc-install/yhc/src/translat\
or/js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
yhc: 
/home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)
   
-s flag silences, we don't want that, with verbose output again we see
that make is failing for a huge number of packages
   
(cd 
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/js/lib/h\
askell; \
 for f in `find . -name '*.hs' | sort` ; do make -f
/home/thartman/haskell-installs/yhc-install/yhc/src/translator/\
js/Makefile `dirname $f`/`basename $f .hs`.ycr ; done)
 yhc --core --no-bytecode CDOM/Level1/DomUtils.hs
yhc: 
/home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)
   
make: *** [CDOM/Level1/DomUtils.ycr] Error 1
yhc --core --no-bytecode CDOM/Level1/Events.hs
yhc: 
/home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)
   
...
   
[EMAIL 
PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/js/lib/haskellyhc
--core --no-bytecode CDOM/Level1/DomUtils\
.hs
yhc: 
/home/thartman/haskell-installs/yhc-install/yhc/inst/lib/yhc/packages:
getDirectoryContents: does not exist (No such fi\
le or directory)
   
Unfamiliar with yhc, I couldn't figure out where getDirectory contents
is being called from.
   
Grepping at the root, I guess something here is causing problems
   
[EMAIL PROTECTED]:~/haskell-installs/yhc-install/yhcgrep -irl
getDirectoryContents *
Make/Useful.hs
inst/bin/yhc
src/compiler98/Package.hs
src/packages/yhc-base-1.0/System/Directory.hs
src/packages/haskell98-1.0/Directory.hs
src/tester/Main.hs
tests/conformance98/Directory/getDirContents/Main.hs
   
best, thomas.
   
2007/11/25, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 On Nov 25, 2007 5:50 PM, Thomas Hartman [EMAIL PROTECTED] wrote:
  Thanks Dmitri, I also had to fix an issue with System.FilePath,
  there's a message about this on haskell cafe.

 In fact, takeDirectory is the right replacement for getDirectory in
 older FilePath. I have pushed this change too.

 Thanks.

 --
 Dimitry Golubovsky

 Anywhere on the Web

   
  
  
   --
   Dimitry Golubovsky
  
   Anywhere on the Web
  
 


 --
 Dimitry Golubovsky

 Anywhere on the Web

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: New slogan for haskell.org

2007-11-26 Thread apfelmus

Henning Thielemann wrote:

Now my idea was, that making
links to glossary articles leaves the slogan as short as it is, and allows
people to find out quickly about the words they still don't know. An
explanation why Haskell's features are useful for programmers is still
required.


+1

But we'd probably need the glossary articles first before linking to them :)

Regards,
apfelmus

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New demo/test program for Yhc Javascript backend

2007-11-26 Thread Thomas Hartman
2007/11/26, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 All published examples (source, html) go into web/jsdemos subdirectory
 (from the root of the Yhc repo source tree).

right; it would be nice to have a makefile (or makefiles) there that
works out of the box, rather than relying on the wiki

http://haskell.org/haskellwiki/Yhc/Javascript/Users_guide#Building_and_installation_on_Unix

which, among other things, requires cleaning up tabs for the
formatting to work. Even if it can't be incorporated into the
buildbot, it would be nice to have some working make examples to
orient one's self.

Secondly, with regards to your cps changes, are you aware of *any*
demos that will compile from head?

I want to get going with this because I have a situation where ycr2js
would be really useful for an in-house project,  client side table
filtering on large tables.

Maybe I should say a bit about this as well so you can tell me if this
seems realistic, I'll write a separate email about that.

t.


 Not all of them may be compilable at the moment though (and some will
 never be compilable in the future, just kept there for historic
 reasons - that's why they are not being tested by the buildbot).

 I am currently going through transition from plain CPS to Cont monad,
 so regular monadic notation can be used instead of CPS. However I am
 experiencing memory leaks in MSIE (try the EchoM example) which I did
 not expect to happen (never had them in plain CPS). If I cannot fix
 that I'll roll back to plain CPS.

 On 11/26/07, Thomas Hartman [EMAIL PROTECTED] wrote:
  It would be really helpful if you could include this (and other)
  examples in an /examples directory under
 
  src/translator/js
 
 --
 Dimitry Golubovsky

 Anywhere on the Web

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: New slogan for haskell.org

2007-11-26 Thread Andrew Coppin

apfelmus wrote:
But we'd probably need the glossary articles first before linking to 
them :)


+12

I added added alpha, beta and eta conversion a while back. (And then 
some kind soul corrected it because half of what I wrote was actually 
*wrong*...) Anybody want to take a stab at all 15 kinds of morphisms? :-}


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: New slogan for haskell.org

2007-11-26 Thread Henning Thielemann

On Mon, 26 Nov 2007, Andrew Coppin wrote:

 apfelmus wrote:
  But we'd probably need the glossary articles first before linking to
  them :)

 +12

 I added added alpha, beta and eta conversion a while back. (And then
 some kind soul corrected it because half of what I wrote was actually
 *wrong*...) Anybody want to take a stab at all 15 kinds of morphisms? :-}

Let's start with polymorphism. :-)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New slogan for haskell.org

2007-11-26 Thread Thomas Davie


On 26 Nov 2007, at 15:50, Henning Thielemann wrote:



On Mon, 26 Nov 2007, Thomas Davie wrote:


On 26 Nov 2007, at 15:15, Henning Thielemann wrote:



On Thu, 4 Oct 2007, Don Stewart wrote:


The Haskell website has the rather strange motivational text:

  Haskell is a general purpose, purely functional programming
language
  featuring static typing, higher order functions, polymorphism,
type
  classes, and monadic effects. Haskell compilers are freely
available
  for almost any computer.


To continue an old thread: What about turning the strange words like
'monadic effects' into links to glossary articles?

Btw. where is 'lazy' ?


I believe the point of this discussion was that anyone reading the
Haskell webpage will currently get about as far as featuring static
typing, and go this is all very nice, but what exactly does this
language do for me?  Why should I use it?.  Take for example what  
the

python website says:


I didn't want to repeat the discussion. I think the discussion ended  
with:
Anything more helpful would be too long for the title line at  
haskell.org,
and a more detailed explanation (but not a generic advertisement  
like that

from Python) should be reachable easily. Now my idea was, that making
links to glossary articles leaves the slogan as short as it is, and  
allows

people to find out quickly about the words they still don't know. An
explanation why Haskell's features are useful for programmers is still
required.


But the point is that this section of the site is the bit that's meant  
to be an advertisement -- we're trying to encourage people to read  
more, and quite frankly, making it a fist full of links would make at  
least me think Well bugger this if I have to read 10 pages before I  
even have a clue what it is.


Bob
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] idea for ycr2js demo, actually meant for an in-house project. is this realistic?

2007-11-26 Thread Thomas Hartman
As I mentioned in a previous post, I've been spending quite some time
trying to get live with ycr2js because there's a project it would be
useful for for my day job, as well as making another nice demo to add
to the list.

Basically, I have some functionality that does client-side filtering
of large html tables. It's pretty smart -- it can filter on multiple
columns, and the filter can be any javascript expression from String
- Bool (to use haskell terminology in a javascript context). The
filter works by hiding rows that don't match the filter; it's built on
mochikit.

Unfortunately this is rather ugly from the user's perspective. You
have to type something like

x.match(my string)

into the search string or

(x  5  x  7)

where x is some variable buried in the javascript.

I would like for the user to be able to enter search criteria in a
more intuitive google style

=skittles or (=~mr. goodbar and =~15 grams)

so you need a parser that takes the search criteria and converts it
into a function from (String - Bool)

This parser is relatively easy to build in haskell; I built it. It's
surely also doable in javascript, but not as nicely, easily, and
cleanly, and being a better haskell than javascript programmer as
well, I would rather generate the javascript from haskell.

So at any rate what I have is

-- parser from String - (String - Bool) (haskell)
-- working html/javascript built on mochikit that filters a
multicolumn table with multiple filter expressions. There is a
function here that takes a string and returns a bool, but it's icky,
doesn't recognize quoted strings, doesn't recognize boolean and/or or
parentheses. I want to replace it with a function generated from
haskell that does all of these things.

What I need is to combine these two components.

I'll try and post some minimal source code for the parser and the
javascript/mochikit stuff soon, and if this problem is tractable it
can become another example for ycr2js.

A possible reason why this wouldn't work is that when you're using the
ycr2js stuff, *everything* has to be generated; it doesn't play well
plugging in an existing javascript function with a generated one. I'd
be surprised if that was the case, but since I haven't actually
successfully generated any code yet i guess anything possible. At any
rate, if this sort of thing could cause issues please someone in the
know give me fair warning.

thomas.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] return in Monad class necessary?

2007-11-26 Thread Henning Thielemann

I wonder whether it is a typical mistake of beginners
to write 'return' within a do-block (that is, not at the end)
and if it is possible to avoid this mistake by clever typing.
In a proper monad 'return' can be fused with subsequent actions,
and thus it is not necessary within a sequence of actions.
However, although sensible, 'return' is also not required at the end of a block.
Has someone already thought about a replacement for monads?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Libraries need a new owner

2007-11-26 Thread Adrian Hey

Hello Folks,

Adrian Hey wrote:

If anyone is interested in the job then I
suggest they contact myself or Jean-Philippe Bernardy.


Sigh..no sooner than I go and write something like that than the IEE (or
I should say IET) go and break my mail alias. So sorry if anyone did
actually try to contact me and got a their mail bounced. It should be
working again now.

Regards
--
Adrian Hey

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New demo/test program for Yhc Javascript backend

2007-11-26 Thread Thomas Hartman
Fair enough, I can wait for a couple of days.

You might want to fix

[EMAIL 
PROTECTED]:~/haskell-installs/yhc-install/yhc/src/translator/js/testdarcs
whatsnew
{
hunk ./src/translator/js/test/Makefile 12
-   $(YHC) -includes ../lib/haskell -linkcore $
+   $(YHC) --includes ../lib/haskell --linkcore $
}

immediately though.

This is the only makefile for the javascript stuff in the repo, and it
doesn't work because of - instead of --. Given your darcs log message
that the javascript compiler would be broken I initially assumed that
was the reason and not a flags change.

More questions. So okay, it builds, I have Test1.html. It's a blank
file with a bunch of javascript. I have firebug, so I can ask execute
stuff in the javascript console. But I can't figure out what to
execute. factorial isn't there, nor sumlst... none of the interesting
looking functions? So what is this supposed to do? And can I change
the makefile so that at least it generates javascript where I can
execute the interesting functions in the firebug console?

thomas.

2007/11/26, Dimitry Golubovsky [EMAIL PROTECTED]:
 Thomas,

 OK, let's try to get on the same page regarding where the project is.

 The Javascript generator is maybe not optimal, but it works.

 DOM bindings are generated from W3C's IDL files, so everything DOM
 provides may be used by Haskell programs, whether in CPS notation, or
 monadic, this will become clear, which form to use, in the near
 future.

 The recent HsWTKDemo works well in major browsers (FF, MSIE, Opera)
 except for Safari, but this is probably a hard case due to the lack of
 debugging information.

 If you look at its source 
 http://darcs.haskell.org/yhc/web/jsdemos/HsWTKDemo.hs

 (no, you cannot compile it at the moment because it is plain CPS) you
 may see some stuff related to static page layout definition in
 declarative way (look for upcntW, factW, etc.) This part is almost
 finalized wrt notation. What's left undecided is whether to use plain
 CPS notation, or monadic notation for parts of the code that involve
 imperative stuff (see e. g. updateD function where node's children are
 replaced in order to update what's displayed).

 This all works perfectly in plain CPS. Understanding that nowadays
 Monads are mainstream, I am trying to adopt monadic notation based on
 the Cont monad instead of plain CPS. I ran one example (EchoM) on MSIE
 and noticed memory leaks on each user's action. However when the page
 is unloaded, MSIE shrinks in size which is a good sign. I think I know
 where the cause is, tonight I'll try to fix it. If unsuccessful, I'll
 probably unroll all monadic changes.

 Next steps are:

 1. Finalize the code notation for static layout and imperative part
 and check the base library into the Yhc repo

 2. Generate haddock documentation

 3. Write a better documentation for developers

 4. Set up a web service that would allow everybody to submit their
 Haskell source and generate HTML page with Javascript in response;
 this I think can be done based on the hpaste program (backed by
 Happs).

 Just for now, you have to wait a couple days while I am straightening
 the monadic thing out. I'd appreciate if you look at the code of
 HsWTKDemo and give me your impressions about notation, etc.

 Thank you.

 --
 Dimitry Golubovsky

 Anywhere on the Web

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New slogan for haskell.org

2007-11-26 Thread Thomas Schilling
On Thu, 2007-10-04 at 10:36 -0700, Don Stewart wrote:
 It was raised at CUFP today that while Python has:
 
 Python is a dynamic object-oriented programming language that can be
 used for many kinds of software development. It offers strong
 support for integration with other languages and tools, comes with
 extensive standard libraries, and can be learned in a few days. Many
 Python programmers report substantial productivity gains and feel
 the language encourages the development of higher quality, more
 maintainable code.
 
 With the links from the start about using Python for various purposes,
 along with reassuring text about licenses and so on. 
 
 Note its all about how it can help you.
 
 The Haskell website has the rather strange motivational text:
 
 Haskell is a general purpose, purely functional programming language
 featuring static typing, higher order functions, polymorphism, type
 classes, and monadic effects. Haskell compilers are freely available
 for almost any computer.
 
 Which doesn't say why these help you.
 
 Any suggestions on a 2 or 3 sentence spiel about what's available?
 
 Here's some quick points:
 
 General purpose: applications from OS kernels to compilers to web dev to 
 ...
 Strong integration with other languages: FFI, and FFI binding tools
 Many developer tools: debugger, profiler, code coverage, QuickCheck
 Extensive libraries: central library repository, central repo hosting 
 Productivity, robustness, maintainability: purity, type system, etc
 Parallelism!
 


Haskell is a general-purpose, pure functional programming languages
that puts many interesting results from research into a practical
programming language.  It's features include:

 * Static typing with type inference: enables writing robust and fast
   programs quickly and makes large code bases maintainable.

 * Higher-order functions, polymorphism, and laziness: enables higher
   levels of abstraction, more composable, thus reusable code.

 * Purity: helps keeping your code maintainable and testable.

Haskell comes with many libraries, freely available compilers for
almost any computer, debuggers, profilers, code coverage and testing
tools.


That seems short enough to me.  Things that could find their way in are:

  monads: for the embedded DSL angle
  paralellism: mention STM and high-level combinators




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] return in Monad class necessary?

2007-11-26 Thread Bulat Ziganshin
Hello Henning,

Monday, November 26, 2007, 9:48:29 PM, you wrote:

 I wonder whether it is a typical mistake of beginners
 to write 'return' within a do-block (that is, not at the end)

don't forget that `return` is also used to force evaluation:

do let n = a+b
   return $! n
   writeChan c (n,1)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New slogan for haskell.org

2007-11-26 Thread Andrew Coppin

Thomas Davie wrote:
But the point is that this section of the site is the bit that's meant 
to be an advertisement -- we're trying to encourage people to read 
more, and quite frankly, making it a fist full of links would make at 
least me think Well bugger this if I have to read 10 pages before I 
even have a clue what it is.


Mmm, the man has a point...

I guess it's kinda hard to explain in just a few words why Haskell is 
actually so damn cool. I mean, you can write it enables you to write 
less code. (Ever heard that one before?) Or you could say it makes 
your programs more reliable (er, yes, I believe we've heard that all 
before too). Or even, it enables you to easily harness multicore 
computing (except that it isn't true - yet). Hmm... so we seem to have 
a choice between verbose statements that nobody is going to read, or 
hopeful promises of better which we can't substansiate. Oh dear...


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Pretty-printing peg solitaire boards

2007-11-26 Thread Maurí­cio

 Actually, I did mean to start with:
 (...)

   #0#
   #0#
 ###
 ###
 ###
   ###
   ###

 (...)

 Heh. He's in for a surprise, there are actually
 solutions for this. (...)

If you don't want to spoil it here, and it won't
take too much of your time to write it down, you
can send it to my e-mail: '[EMAIL PROTECTED]'

 (...) I'll try to find that book, we'll like to
 read it.

 It's a series of three books actually. Sadly
 it's been a long time since I've read them so I
 forgot which volume covers which topics.

Actually, it seems there's an old edition in two
volumes and a new one, in four volumes. I just
read the first chapter of volume I in Amazon, and
it's really a nice reading.

Maurício

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Building MissingH on Windows

2007-11-26 Thread nionita
Hi,

I'm trying to build MissingH (0.18.6) on Windows, but it looks like
(probably because of changes in Cabal) the Setup.hs is broken. Im using GHC
6.8.1. Following message:

$ runhaskell Setup.hs configure

Setup.hs:19:35:
Couldn't match expected type `(Either
 GenericPackageDescription
PackageDescription,
   HookedBuildInfo)'
   against inferred type `PackageDescription'
In the first argument of `(confHook defaultUserHooks)', namely
`mydescrip'
In the expression:
let
  mydescrip = case os of
mingw32 - ...
_ - ...
in (confHook defaultUserHooks) mydescrip flags
In the definition of `customConfHook':
customConfHook descrip flags
 = let mydescrip = ...
   in (confHook defaultUserHooks) mydescrip flags

I'm new to Cabal and I couldn't see a fast way to fix it.

Thanks,
Nicu

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Building MissingH on Windows

2007-11-26 Thread Thomas Schilling
On Mon, 2007-11-26 at 21:24 +0100, [EMAIL PROTECTED] wrote:
 Hi,
 
 I'm trying to build MissingH (0.18.6) on Windows, but it looks like
 (probably because of changes in Cabal) the Setup.hs is broken. Im using GHC
 6.8.1. Following message:
 
 $ runhaskell Setup.hs configure
 
 Setup.hs:19:35:
 Couldn't match expected type `(Either
  GenericPackageDescription
 PackageDescription,
HookedBuildInfo)'
against inferred type `PackageDescription'
 In the first argument of `(confHook defaultUserHooks)', namely
 `mydescrip'
 In the expression:
 let
   mydescrip = case os of
 mingw32 - ...
 _ - ...
 in (confHook defaultUserHooks) mydescrip flags
 In the definition of `customConfHook':
 customConfHook descrip flags
  = let mydescrip = ...
in (confHook defaultUserHooks) mydescrip flags
 
 I'm new to Cabal and I couldn't see a fast way to fix it.
 
 Thanks,
 Nicu

Try replacing the original files with the attached files.
-- arch-tag: MissingH main description file
Name: MissingH
Version: 0.18.6
Cabal-Version: = 1.2
License: GPL
Maintainer: John Goerzen [EMAIL PROTECTED]
Author: John Goerzen
Copyright: Copyright (c) 2004-2007 John Goerzen
license-file: COPYRIGHT
extra-source-files: COPYING
homepage: http://software.complete.org/missingh
Category: Unclassified
synopsis: Large utility library
Description:  MissingH is a library of all sorts of utility functions for
 Haskell programmers.  It is written in pure Haskell and thus should
 be extremely portable and easy to use.
Stability: Beta

Library
 Hs-Source-Dirs: src

 Exposed-Modules: Data.String, System.IO.Utils, System.IO.Binary, Data.List.Utils,
  System.Daemon,
  Text.ParserCombinators.Parsec.Utils,
  Test.HUnit.Utils,
  Network.Email.Mailbox,
  Control.Concurrent.Thread.Utils,
  Network.Email.Sendmail,
Data.CSV,
  System.Cmd.Utils,
  Data.Progress.Tracker,
  Data.Progress.Meter,
  Data.Quantity,
  Data.Map.Utils, System.Path, System.Path.NameManip,
System.Path.WildMatch, System.Path.Glob,
  System.Time.Utils, System.Time.ParseDate,
  Network.Utils,
  Network.SocketServer,
  Data.Either.Utils,
  Data.Maybe.Utils,
  Data.Bits.Utils,
  Data.Hash.CRC32.Posix, Data.Hash.CRC32.GZip,
   Data.Hash.MD5, Data.Hash.MD5.Zord64_HARD,
  Data.Compression.Inflate,
  System.FileArchive.GZip,
  System.IO.HVFS,
System.IO.HVFS.Combinators,
System.IO.HVFS.InstanceHelpers,
System.IO.HVFS.Utils,
  System.IO.HVIO, System.IO.StatCompat, System.IO.WindowsCompat,
System.IO.PlafCompat, System.Posix.Consts,
  System.Debian, System.Debian.ControlParser,
  Data.MIME.Types,
  System.Console.GetOpt.Utils
 Extensions: ExistentialQuantification, OverlappingInstances, 
   UndecidableInstances, CPP
 Build-Depends: network, parsec, base,
   haskell98, mtl, HUnit, regex-compat, QuickCheck, filepath,
   hslogger
 if !os(windows)
  Build-Depends: unix

 GHC-Options: -O2

Executable runtests
 Buildable: False
 Main-Is: runtests.hs
 HS-Source-Dirs: testsrc, .
 Extensions: ExistentialQuantification, OverlappingInstances,
UndecidableInstances, CPP
#!/usr/bin/env runhaskell
module Main where
import Distribution.Simple
main :: IO ()
main = defaultMain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Building MissingH on Windows

2007-11-26 Thread Thomas Schilling
See also:  http://haskell.org/haskellwiki/Upgrading_packages

You probably have to adjust the build-depends field, due to the base
split up. 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Problems with split-objs

2007-11-26 Thread Magnus Therning
I've followed the instructions at [1] to create a .deb of vty[2].  It
seems the helper scripts for Debian passes `--enable-split-obj' when
running `./Setup.lhs configure'.  This results in numerous multiple
definitions of stuff.  I have a few questions regarding this...

I think I understand what --split-objs does, but why doesn't it work for
vty?  I've debianised other haskell libs using the same method without
problems.  The only difference I can see is that vty uses FFI.  Is that
what causes the problems?

How do I fix this?  I'd rather not go in and manually change any
automatically generated files, and the file that passes
`--enable-split-objs' is automatically generated :(

/M

[1]:
http://haskell.org/haskellwiki/Creating_Debian_packages_from_Cabal_package
[2]: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/vty-3.0.0

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

What if I don't want to obey the laws? Do they throw me in jail with
the other bad monads?
 -- Daveman



signature.asc
Description: OpenPGP digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] return in Monad class necessary?

2007-11-26 Thread Chris Eidhof

On 26 nov 2007, at 19:48, Henning Thielemann wrote:

I wonder whether it is a typical mistake of beginners
to write 'return' within a do-block (that is, not at the end)
and if it is possible to avoid this mistake by clever typing.
In a proper monad 'return' can be fused with subsequent actions,
and thus it is not necessary within a sequence of actions.
However, although sensible, 'return' is also not required at the end  
of a block.

Has someone already thought about a replacement for monads?
I also made that mistake in the beginning, I used return instead of  
lets. I don't think it's a big problem, most users will find out once  
they've got some more experience, and it doesn't really do any harm.


-chris

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Announce: strict-concurrency

2007-11-26 Thread Don Stewart
While writing some multi-core concurrent code I needed more precise
control over which thread evaluated particular expressions. The default
concurrent types, MVar and Chan, are lazy, and sometimes not suitable.

The little package,


http://hackage.haskell.org/cgi-bin/hackage-scripts/package/strict-concurrency

Provies the MVar type, but with strict putMVar by default, and an
element-strict Chan type. 

For some applications, these stricter types can yield improved time and
space use. (For others, they can make things worse)

The strict channel type in particular seems useful, as it can be used to 
force worker threads to evaluate to WHNF before returning values to
a driver thread.

Enjoy,
Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Browser action and new http library

2007-11-26 Thread bbrown

I am trying to use the HTTP library 3001 for ghc 6.8 and cant figure out how
to use a proxy to do a GET request as I am behind a proxy server.  My thinking
is that I could use the setProxy method it looks like it returns a
BrowserAction?  What do I do with that.  Here is the current code (I havent
really used the setProxy yet).

--
-- HTTP LIBRARY version: HTTP-3001.0.2

import Data.Char (intToDigit)
import Network.HTTP
import Network.URI
import Network.Browser (defaultGETRequest)
import System.Environment (getArgs)
import System.Exit (exitFailure)
import System.IO (hPutStrLn, stderr)

main = 
do
args - getArgs
case args of 
[addr] - case parseURI addr of
   Nothing - err Could not parse URI
   Just uri - do
   cont - get uri
   putStr cont
_ - err Usage: lman url

err :: String - IO a
err msg = do 
  hPutStrLn stderr msg
  exitFailure

get :: URI - IO String
get uri =
do
eresp - simpleHTTP (defaultGETRequest uri)
resp - handleErr (err . show) eresp
case rspCode resp of
  (2,0,0) - return (rspBody resp)
  _ - err (httpError resp)
where
  showRspCode (a,b,c) = map intToDigit [a,b,c]
  httpError resp = showRspCode (rspCode resp) ++   ++ rspReason resp

--
-- Handle Connection Errors
handleErr :: Monad m = (ConnError - m a) - Either ConnError a - m a
handleErr h (Left e) = h e
handleErr _ (Right v) = return v

-- End of File


--
Berlin Brown
[berlin dot brown at gmail dot com]
http://botspiritcompany.com/botlist/?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Strings and utf-8

2007-11-26 Thread Maurí­cio

Hi,

Are 'String's in GHC 6.6.1 UTF-8?

Thanks,
Maurício

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] return in Monad class necessary?

2007-11-26 Thread Derek Elkins
On Tue, 2007-11-27 at 00:15 +0100, Chris Eidhof wrote:
 On 26 nov 2007, at 19:48, Henning Thielemann wrote:
  I wonder whether it is a typical mistake of beginners
  to write 'return' within a do-block (that is, not at the end)
  and if it is possible to avoid this mistake by clever typing.
  In a proper monad 'return' can be fused with subsequent actions,
  and thus it is not necessary within a sequence of actions.
  However, although sensible, 'return' is also not required at the end  
  of a block.
  Has someone already thought about a replacement for monads?
 I also made that mistake in the beginning, I used return instead of  
 lets. I don't think it's a big problem, most users will find out once  
 they've got some more experience, and it doesn't really do any harm.

I may be mistaken, but I'm pretty sure he's talking about something
different.  Basically, where 'return' is confused for C's return.  I
have seen this occasionally in #haskell or on the mailinglist, but it
doesn't seem to be a big issue.  It doesn't come up all that often and
it's usually quickly resolved.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Strings and utf-8

2007-11-26 Thread Brandon S. Allbery KF8NH


On Nov 26, 2007, at 19:23 , Maurí cio wrote:


Are 'String's in GHC 6.6.1 UTF-8?


No.

type String = [Char]

and Char stores Unicode codepoints.  However, the IO system truncates  
them to 8 bits.  I think there are UTF8 marshaling libraries on  
hackage these days, though.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] return in Monad class necessary?

2007-11-26 Thread Neil Mitchell
Hi Henning,

 I wonder whether it is a typical mistake of beginners
 to write 'return' within a do-block (that is, not at the end)
 and if it is possible to avoid this mistake by clever typing.

There are legitimate uses of return inside a do, see:
http://www.cs.york.ac.uk/fp/darcs/catch/catch_1/Analyse/Fix.hs

The code has a bit like:

x - return $ apply x addReq (\y - y{requiredBy =
Set.insert k (requiredBy y)})
x - return $ apply x delReq (\y - y{requiredBy =
Set.delete k (requiredBy y)})

i.e. modify x, which you can't do with let's because of the scoping
(they are really let-rec's). I often use return to do binding and name
shadowing in do blocks.

Having said that, when I was learning Haskell, I didn't know you could
put let in a do block, and did use the return for all variables!

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Strings and utf-8

2007-11-26 Thread Don Stewart
allbery:
 
 On Nov 26, 2007, at 19:23 , Maurí cio wrote:
 
 Are 'String's in GHC 6.6.1 UTF-8?
 
 No.
 
 type String = [Char]
 
 and Char stores Unicode codepoints.  However, the IO system truncates  
 them to 8 bits.  I think there are UTF8 marshaling libraries on  
 hackage these days, though.

Yep, utf8string, in particular.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Why aren't Float and Double Bounded?

2007-11-26 Thread Jason Dusek
Among numeric types, it seems that only integer types are Bounded.

-- 
_jsn
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghc 6.8.1 bug?

2007-11-26 Thread SevenThunders



Ian Lynagh wrote:
 
 
 Can any of you give us a testcase for this, please?
 
 
 Thanks
 Ian
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

I started to work on this but so far it's been hard to shrink the size of
the test case.  It seems to need a little workout before it's starts to
exhibit the behavior.  Also there are always time limitations.  I'll keep
hacking away at it.
-- 
View this message in context: 
http://www.nabble.com/ghc-6.8.1-bug--tf4810375.html#a13964202
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] A tale of three shootout entries

2007-11-26 Thread Sterling Clover
In some spare time over the holidays I cooked up three shootout  
entries, for Fasta, the Meteor Contest, and Reverse Complement. I  
should probably have tossed them to haskell-cafe before submission,  
for review and ideas, but they're up now. In any case, all three were  
great learning experiences, but could use some other eyes and ideas  
to be the best that they can.


First up is the meteor-contest entry.

http://shootout.alioth.debian.org/gp4/benchmark.php? 
test=meteorlang=ghcid=5


This is the clear win of the bunch, with significantly improved time  
thanks to its translation of the better algorithm from Clean.  
However, it's still missing something. Nearly all its time is spent  
in a tight loop in the solveCell function near the end of the code. I  
tried unboxing this, but failed because it spends the bulk of its  
time applying a bitwise and between the recursively passed value and  
a piece of data retrieved from the masksAtCell data structure which  
is of type :: Array (Row,Col) (Array Color [Mask]). (Note that Mask,  
Color, Row and Col are all type synonyms for Int that I added for  
readability).  As each Mask is stored in this list, the masks can't  
easily be unboxed -- some sort of custom data structure built using  
the FFI seems in order here. If anyone wants to tackle this, I think  
it could be a big win for performance.


Next is reverse-complement.

http://shootout.alioth.debian.org/gp4/benchmark.php? 
test=revcomplang=ghcid=3


This *would* be a big win except I dimly doubled memory usage from  
the previous entry due to filtering newlines explicitly -- which  
does, one should note, provide a large performance gain. The solution  
here seems the most obvious -- roll the newline stripping into the  
destructive modifications performed in the revcomp function, as the  
winning C++ entry does. I'll probably get around to this eventually,  
but if someone else wants to try to implement this or any other  
performance improvements, please jump right in. Additionally, there  
might be some other tricks to reducing its memory usage that escape  
me at the moment (noting, of course, that using a strict bytestring,  
as we should, its unavoidable that we consume the entire contents of  
the input at once... I think?)


Finally, there's fasta.

http://shootout.alioth.debian.org/gp4/benchmark.php? 
test=fastalang=ghcid=2


This one really depresses me. It outperforms the previous version by  
roughly 20% on my machine (PPC) but underperforms by roughly the same  
amount on the shootout box. If you compare it to dons previous  
version, the optimizations I attempted should be pretty obvious.  
First, I precompute the partial sums for the frequency tables and  
alter the choose function accordingly. This is a pretty basic measure  
that all the better entries seem to do. Next, I unboxed the random  
function, which yielded big speedups However, given that we use an  
unfoldN, as we should, I couldn't very well pass it a function that  
returned something of kind #, (especially as Maybe, which unfoldN  
uses, is of kind *-*). Thus, I hid the unrolled loop in a lazy list  
of floats that is passed instead of a random seed. I suspect that for  
some reason I don't understand relating to differences in processors,  
GHC's internal handling of floating point math, or who knows what,  
this somehow is the source of the slowdown. If someone with an Intel  
Pentium 4 machine comparable to that of the shootout box wants to  
take a look at this code and see why it underperforms, I'd be much  
obliged. It really seems to me that GHC's fasta performance is far  
below where it should be (4x slower than Java!) , and I'd like to get  
its numbers up somehow.


Thanks,
Sterl

p.s. It looks like they've depreciated chameneos in favor of a new  
version, chameneos-redux. As this was one of the places Haskell  
really rocked the competition, it would probably be worth updating  
the Haskell entry for the new benchmark. Also, the n-bodies benchmark  
seems like another that could be much improved.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A tale of three shootout entries

2007-11-26 Thread Don Stewart
s.clover:
 In some spare time over the holidays I cooked up three shootout  
 entries, for Fasta, the Meteor Contest, and Reverse Complement. I  

Yay!

 First up is the meteor-contest entry.
 
 http://shootout.alioth.debian.org/gp4/benchmark.php? 
 test=meteorlang=ghcid=5
 
 This is the clear win of the bunch, with significantly improved time  
 thanks to its translation of the better algorithm from Clean.  

Well done! Though looks like we'll have to follow the C++ implementation 
to be really competitive.

 Next is reverse-complement.
 
 http://shootout.alioth.debian.org/gp4/benchmark.php? 
 test=revcomplang=ghcid=3

Very good. I'm glad someone looked at that, since the old code was
moderately naive (first bytestring effort).

 Finally, there's fasta.
 
 http://shootout.alioth.debian.org/gp4/benchmark.php? 
 test=fastalang=ghcid=2
  
Yeah, we should do something better here. Hmm.
  
 p.s. It looks like they've depreciated chameneos in favor of a new  
 version, chameneos-redux. As this was one of the places Haskell  
 really rocked the competition, it would probably be worth updating  

Definitely. I note also we're beating Erlang on the new thread-ring 
benchmark too,

http://shootout.alioth.debian.org/gp4/benchmark.php?test=threadringlang=all

 the Haskell entry for the new benchmark. Also, the n-bodies benchmark  
 seems like another that could be much improved.

Yeah, that's a hard one.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New slogan for haskell.org

2007-11-26 Thread David Fox
On Nov 26, 2007 11:38 AM, Thomas Schilling [EMAIL PROTECTED] wrote:


 Haskell is a general-purpose, pure functional programming languages
 that puts many interesting results from research into a practical
 programming language.  It's features include:


 I think it is stronger to say many powerful results rather than many
interesting results.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] return in Monad class necessary?

2007-11-26 Thread Jonathan Cast

On 26 Nov 2007, at 10:48 AM, Henning Thielemann wrote:



I wonder whether it is a typical mistake of beginners
to write 'return' within a do-block (that is, not at the end)
and if it is possible to avoid this mistake by clever typing.
In a proper monad 'return' can be fused with subsequent actions,
and thus it is not necessary within a sequence of actions.
However, although sensible, 'return' is also not required at the  
end of a block.

Has someone already thought about a replacement for monads?


As has been said, this isn't a big issue, and return is quite  
useful.  Furthermore, I can think of several cases where it would be  
awkward (to say the least) to dispense with return, and it's an  
invaluable base case for inductive definitions, e.g. of liftMn (which  
would have to replace it, I suppose).  And besides that, if there is  
one thing Haskellers believe more than anything else, it must surely  
be that every associative operator deserves a unit...


jcc


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe