Re: [GHC] #2737: add :tracelocal to ghci debugger to trace only the expressions in a given function

2008-11-04 Thread GHC
#2737: add :tracelocal to ghci debugger to trace only the expressions in a given
function
-+--
Reporter:  phercek   |Owner:  
Type:  feature request   |   Status:  new 
Priority:  normal|Milestone:  
   Component:  GHCi  |  Version:  6.8.3   
Severity:  normal|   Resolution:  
Keywords:  debugger  | Testcase:  
Architecture:  Unknown/Multiple  |   Os:  Unknown/Multiple
-+--
Changes (by mnislaih):

 * cc: [EMAIL PROTECTED] (added)

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2737#comment:2
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2722: loop when compiling with -O option with ghc-6.10.0.20081019

2008-11-04 Thread GHC
#2722: loop when compiling with -O option with ghc-6.10.0.20081019
---+
 Reporter:  uwe|  Owner: 
 Type:  bug| Status:  closed 
 Priority:  normal |  Milestone:  Not GHC
Component:  libraries (other)  |Version:  6.10.1 
 Severity:  normal | Resolution:  fixed  
 Keywords:  arrows | Difficulty:  Unknown
 Testcase: |   Architecture:  x86
   Os:  Linux  |  
---+
Changes (by ross):

  * status:  new = closed
  * resolution:  = fixed

Comment:

 It never occurred to me before that using a valid equation as a rule could
 change the semantics of a recursive definition, but it's obvious in
 retrospect.

 So with the Category split, this rule has to go, and I've pushed a patch
 to delete it.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2722#comment:9
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #1876: Complete shared library support

2008-11-04 Thread GHC
#1876: Complete shared library support
--+-
 Reporter:  simonmar  |  Owner:  clemens   
 Type:  task  | Status:  assigned  
 Priority:  high  |  Milestone:  6.10 branch   
Component:  Compiler  |Version:  6.8.1 
 Severity:  normal| Resolution:
 Keywords:| Difficulty:  Difficult (1 week)
 Testcase:|   Architecture:  Unknown/Multiple  
   Os:  Unknown/Multiple  |  
--+-
Changes (by spl):

 * cc: [EMAIL PROTECTED] (added)

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1876#comment:12
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #2740: free variable not available in debugger, field selection function not available in debugger

2008-11-04 Thread GHC
#2740: free variable not available in debugger, field selection function not
available in debugger
-+--
Reporter:  phercek   |   Owner:
Type:  bug   |  Status:  new   
Priority:  normal|   Component:  GHCi  
 Version:  6.8.2 |Severity:  normal
Keywords:  debugger  |Testcase:
Architecture:  x86   |  Os:  Linux 
-+--
 The attached test shows the bugs. Unpack and check the ghci_log.html file
 to see how to reproduce them. Stderr is in red, selected expression is
 underlined. Looks like these error messages should not be there:

 Not in scope: `mSnd'

 Not in scope: `a'

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2740
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #1876: Complete shared library support

2008-11-04 Thread GHC
#1876: Complete shared library support
--+-
 Reporter:  simonmar  |  Owner:  clemens   
 Type:  task  | Status:  assigned  
 Priority:  high  |  Milestone:  6.10 branch   
Component:  Compiler  |Version:  6.8.1 
 Severity:  normal| Resolution:
 Keywords:| Difficulty:  Difficult (1 week)
 Testcase:|   Architecture:  Unknown/Multiple  
   Os:  Unknown/Multiple  |  
--+-
Comment (by simonmar):

 Some issues to resolve before we can deploy shared libraries.  Some of
 these are probable just questions to be answered, but hint at
 documentation that we need to write.

  * Do GHC distributions contain both shared and static libraries?
  * Will Cabal build both shared and static libraries by default?
  * Can a module built with `-dynamic` link against static libraries, if
 the dynamic versions are not available?
  * If modules are compiled with `-fPIC` and/or `-dynamic`, can they then
 be linked statically?  On which platforms?  If not, what goes wrong if you
 try this?
  * On x86_64 we should have `-dynamic` turned on by default, for loading
 modules into GHCi, otherwise data references to shared libraries will only
 have 32-bit relocations and thus will break.
  * Using `-static` at compile-time on x86_64 should therefore come with a
 warning that the modules cannot be loaded into GHCi.  Can we detect this
 and report an error in GHCi?
  * What is the performance overhead of turning on `-dynamic` by default on
 x86_64?
  * What is the performance overhead (and code-size overhead) of shared
 libraries in general?

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1876#comment:11
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #2741: Delete key not working in GHCi

2008-11-04 Thread GHC
#2741: Delete key not working in GHCi
---+
Reporter:  guest   |   Owner:
Type:  bug |  Status:  new   
Priority:  normal  |   Component:  GHCi  
 Version:  6.10.1  |Severity:  normal
Keywords:  |Testcase:
Architecture:  x86 |  Os:  Linux 
---+
 In GHCi 6.10.1, on Ubuntu with libedit 2.11, pressing the delete key
 produces a beep and inserts a tilde into the line rather than deleting a
 character.

 http://bugs.mysql.com/bug.php?id=294 is essentially the same problem, but
 in MySQL. It seems they fixed it by reverting to using libreadline.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2741
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #2742: The - in ViewPatterns binds more weakly than infix data constructors.

2008-11-04 Thread GHC
#2742: The - in ViewPatterns binds more weakly than infix data constructors.
-+--
Reporter:  guest |   Owner:  
Type:  bug   |  Status:  new 
Priority:  normal|   Component:  Compiler
 Version:  6.10.1|Severity:  normal  
Keywords:|Testcase:  
Architecture:  Unknown/Multiple  |  Os:  Unknown/Multiple
-+--
 The following code, essentially taken from the ViewPatterns page on the
 wiki doesn't seem to parse correctly.

 {{{
 mymap f [] = []
 mymap f (x : mymap f - xs) = f x : xs
 }}}

 However, this does:

 {{{
 mymap f [] = []
 mymap f (x : (mymap f - xs)) = f x : xs
 }}}

 (though it triggers bug #2395 about overlapping patterns)

 It would seem nicer to make the view pattern arrow bind ''tighter'' than
 any infix data constructors.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2742
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2742: The - in ViewPatterns binds more weakly than infix data constructors.

2008-11-04 Thread GHC
#2742: The - in ViewPatterns binds more weakly than infix data constructors.
-+--
Reporter:  guest |Owner:  
Type:  bug   |   Status:  new 
Priority:  normal|Milestone:  
   Component:  Compiler  |  Version:  6.10.1  
Severity:  normal|   Resolution:  
Keywords:| Testcase:  
Architecture:  Unknown/Multiple  |   Os:  Unknown/Multiple
-+--
Changes (by guest):

 * cc: [EMAIL PROTECTED] (added)

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2742#comment:1
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #2739: GHC API crashes on template haskell splices

2008-11-04 Thread GHC
#2739: GHC API crashes on template haskell splices
-+--
Reporter:  waern |   Owner:  
Type:  bug   |  Status:  new 
Priority:  normal|   Component:  Compiler
 Version:  6.10.1|Severity:  major   
Keywords:|Testcase:  
Architecture:  Unknown/Multiple  |  Os:  Unknown/Multiple
-+--
 The GHC API crashes when type checking these two modules:

 {{{TH.hs}}}:

 {{{
 {-# LANGUAGE TemplateHaskell #-}

 module TH where

 import Language.Haskell.TH

 decl = [d| f x = x]
 }}}

 {{{TH2.hs}}}:

 {{{
 {-# LANGUAGE TemplateHaskell #-}

 module TH2 where

 import TH

 $( decl )
 }}}


 The crash happens in {{{HscMain.compileExpr}}}, when compiling and linking
 the spliced-in
 code. The crash is due to a {{{fromJust: Nothing}}}. I don't have the
 error message at hand.

 It would be nice if this could be fixed in 6.10.* since it makes Haddock
 crash when processing several packages on Hackage.

 I will add both {{{TH.hs}}} and {{{TH2.hs}}} to the test suite in the
 {{{code.haskell.org/haddock}}} repository later. (I thought I had done
 this, but I apparently forgot to add TH.hs). You can the use
 {{{test/runtests.hs}}} to invoke the crash.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2739
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #2743: GHC 6.10.1 Win32 release is unusable

2008-11-04 Thread GHC
#2743: GHC 6.10.1 Win32 release is unusable
-+--
Reporter:  guest |   Owner:  
Type:  bug   |  Status:  new 
Priority:  normal|   Component:  Compiler
 Version:  6.10.1|Severity:  blocker 
Keywords:|Testcase:  
Architecture:  Unknown/Multiple  |  Os:  Unknown/Multiple
-+--
 1. Running ghc in cmd.exe shell delivers (in my config):

 ghc.EXE: panic! (the 'impossible' happened)
   (GHC version 6.10.1 for i386-unknown-mingw32):
 can't decompose ghc.exe path:
 G:\\Progs\\ghc-6.10.1\\Bin\\ghc.exe

 2. runghc.exe/runhaskell.exe hangs.

 3. $topdir\include\mingw\c++ contains subtrees 3.4.5 and 3.4.2.
 3.4.2 seems completely irrelevant here.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2743
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #2744: Missing requirement check for hsc2hs

2008-11-04 Thread GHC
#2744: Missing requirement check for hsc2hs
---+
Reporter:  jputcu  |   Owner:  
Type:  bug |  Status:  new 
Priority:  normal  |   Component:  Build System
 Version:  6.10.1  |Severity:  normal  
Keywords:  |Testcase:  
Architecture:  x86 |  Os:  Linux   
---+
 Using ghc-6.6.1 to build ghc-6.10.1 fails because it's missing the hsc2hs
 tools required by the hpc package.

 Installing the cabal hsc2hs-0.67.20061107 package fixed that problem.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2744
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: could ghci debugger search for free variables better?

2008-11-04 Thread Simon Marlow

Peter Hercek wrote:


As for as the rest of the message. Those are possible bugs.
 If I can reduce them to few tens of lines of a test, I'll
 post the bug reports. I use Archlinux and the last (non-testing)
 version of ghc there is ghc-6.8.2. Do you accept bug reports
 against it or do you need them against 6.10.1rc1 only?


Bug reports against 6.8.2 are fine, but if you can test against 6.10.1 
that's even better (it might weed out bugs that have been already fixed and 
thus save us some time).


Cheers,
Simon
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Control.Exception

2008-11-04 Thread Jason Dagit
On Tue, Nov 4, 2008 at 2:47 AM, Simon Marlow [EMAIL PROTECTED] wrote:
 Jason Dagit wrote:

 Thanks.  This helps a lot.  Mind if I put it somewhere, such as on the
 wiki?

 A good description of how to deal with exceptions would be great to have in
 the Haddock documentation for Control.Exception - would you (or someone
 else) like to write and submit a patch?  Or failing that, just putting it on
 the wiki would be useful too.

I don't mind submitting a patch.  What is the URL of the repo I should download?

Thanks!
Jason
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


ANNOUNCE: GHC version 6.10.1

2008-11-04 Thread Ian Lynagh

   ==
The (Interactive) Glasgow Haskell Compiler -- version 6.10.1
   ==

The GHC Team is pleased to announce a new major release of GHC. There
have been a number of significant changes since the last major release,
including:

 * Some new language features have been implemented:
   * Record syntax: wild-card patterns, punning, and field disambiguation
   * Generalised quasi-quotes
   * Generalised list comprehensions
   * View patterns

 * Type families have been completely re-implemented

 * Now comes with Haddock 2, which supports all GHC extensions

 * Parallel garbage collection

 * Base provides extensible exceptions

 * The GHC API is easier to use

 * External core (output only) now works again

 * Data Parallel Haskell (DPH) comes as part of GHC

The full release notes are here:

  http://haskell.org/ghc/docs/6.10.1/html/users_guide/release-6-10-1.html

How to get it
~

The easy way is to go to the web page, which should be self-explanatory:

http://www.haskell.org/ghc/

We supply binary builds in the native package format for many
platforms, and the source distribution is available from the same
place.

Packages will appear as they are built - if the package for your
system isn't available yet, please try again later.


Background
~~

Haskell is a standard lazy functional programming language; the
current language version is Haskell 98, agreed in December 1998 and
revised December 2002.

GHC is a state-of-the-art programming suite for Haskell.  Included is
an optimising compiler generating good code for a variety of
platforms, together with an interactive system for convenient, quick
development.  The distribution includes space and time profiling
facilities, a large collection of libraries, and support for various
language extensions, including concurrency, exceptions, and foreign
language interfaces (C, whatever).  GHC is distributed under a
BSD-style open source license.

A wide variety of Haskell related resources (tutorials, libraries,
specifications, documentation, compilers, interpreters, references,
contact information, links to research groups) are available from the
Haskell home page (see below).


On-line GHC-related resources
~~

Relevant URLs on the World-Wide Web:

GHC home page  http://www.haskell.org/ghc/
GHC developers' home page  http://hackage.haskell.org/trac/ghc/
Haskell home page  http://www.haskell.org/


Supported Platforms
~~~

The list of platforms we support, and the people responsible for them,
is here:

   http://hackage.haskell.org/trac/ghc/wiki/Contributors

Ports to other platforms are possible with varying degrees of
difficulty.  The Building Guide describes how to go about porting to a
new platform:

http://hackage.haskell.org/trac/ghc/wiki/Building


Developers
~~

We welcome new contributors.  Instructions on accessing our source
code repository, and getting started with hacking on GHC, are
available from the GHC's developer's site run by Trac:

  http://hackage.haskell.org/trac/ghc/


Mailing lists
~

We run mailing lists for GHC users and bug reports; to subscribe, use
the web interfaces at

http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

There are several other haskell and ghc-related mailing lists on
www.haskell.org; for the full list, see

http://www.haskell.org/mailman/listinfo/

Some GHC developers hang out on #haskell on IRC, too:

http://www.haskell.org/haskellwiki/IRC_channel

Please report bugs using our bug tracking system.  Instructions on
reporting bugs can be found here:

http://www.haskell.org/ghc/reportabug

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: ANNOUNCE: GHC version 6.10.1

2008-11-04 Thread Lennart Kolmodin

Hello fellow GHC users,


Ian Lynagh wrote:

   ==
The (Interactive) Glasgow Haskell Compiler -- version 6.10.1
   ==


[snip]



How to get it
~

The easy way is to go to the web page, which should be self-explanatory:

http://www.haskell.org/ghc/


Gentoo Linux users can get it from the gentoo-haskell overlay[1].

If you're not familiar with this overlay (a gold mine for haskell 
hackers using gentoo), you can easily use layman[2] to get access. Make 
sure you have darcs installed, as it is a requirement for our overlay.


Once layman is set up, add the overlay with:

 $ layman -a haskell

Note that ghc-6.10.1 still is masked by keyword, and you need to unmask 
it first. If you're not familiar with how to do this, here's a quick guide:


 # make sure /etc/portage exists
 $ [[ -d /etc/portage ]] || mkdir /etc/portage
 # accept ghc being ~arch
 $ echo dev-lang/ghc  /etc/portage/package.keywords
 # ghc requires the very latest libedit package
 $ echo dev-libs/libedit  /etc/portage/package.keywords

You may then install ghc-6.10.1 by saying:

 # this requires that you already have an older ghc version installed
 $ USE=ghcbootstrap -binary emerge ghc

The USE flags are required as we don't just yet provide the required 
binaries to bootstrap ghc. The command above requires that you already 
have a ghc version installed to bootstrap with. This version will be 
replaced with ghc-6.10.1 once the installation finishes.


GHC binaries will follow shortly, which will shorten the procedure to:

 $ emerge ghc

The packages from extralibs will also be available from the overlay.

If you run into trouble, reply to the ml, or find us in #gentoo-haskell 
at freenode.


Cheers,
  Lennart Kolmodin -- using his Gentoo Linux Developer hat

 [1] http://code.haskell.org/gentoo/gentoo-haskell/
 [2] http://www.gentoo.org/proj/en/overlays/userguide.xml
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: No atomic read on MVar?

2008-11-04 Thread Arnar Birgisson
On Mon, Nov 3, 2008 at 23:51, David Menendez [EMAIL PROTECTED] wrote:
 On Mon, Nov 3, 2008 at 6:29 AM, Philip K.F. Hölzenspies
 [EMAIL PROTECTED] wrote:

 I have now implemented my variable as a pair of MVars, one of which serves as
 a lock on the other. Both for performance reasons and for deadlock analysis,
 I would really like an atomic read on MVars, though. Does it exist? If not,
 why not?

 Have you considered using STM? All the operations on TMVars are atomic.

I will second this. At the very least, if you only need atomic
read/write operations you can use TMVars and make aliases that compose
with atomically:

takeMVar = atomically . takeTMVar
putMVar = atomically . putTMVar

etc.

cheers,
Arnar
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: could ghci debugger search for free variables better?

2008-11-04 Thread Peter Hercek

Simon Marlow wrote:

Peter Hercek wrote:


As for as the rest of the message. Those are possible bugs.
 If I can reduce them to few tens of lines of a test, I'll
 post the bug reports. I use Archlinux and the last (non-testing)
 version of ghc there is ghc-6.8.2. Do you accept bug reports
 against it or do you need them against 6.10.1rc1 only?


Bug reports against 6.8.2 are fine, but if you can test against 6.10.1 
that's even better (it might weed out bugs that have been already fixed 
and thus save us some time).


Here it is (against 6.8.2):
http://hackage.haskell.org/trac/ghc/ticket/2740

Peter.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Control.Exception

2008-11-04 Thread Simon Marlow

Jason Dagit wrote:

On Mon, Nov 3, 2008 at 6:24 AM, Simon Marlow [EMAIL PROTECTED] wrote:

Jason Dagit wrote:

On Wed, Oct 8, 2008 at 1:19 AM, Simon Marlow [EMAIL PROTECTED] wrote:

Johannes Waldmann wrote:

with 6.10, the following does not typecheck:

foo `Control.Exception.catch` \ _ - return bar

Ambiguous type variable `e' in the constraint:
`Control.Exception.Exception e'

It is probably bad programming style anyway but what is the workaround?

As long as you're aware that it is bad programming style.  We
deliberately
didn't include an easy way to do this, because we want people to think
about
why they need to catch *all* exceptions (most of the time it's a bug).

Since the above is bad form, what should I be doing?  Could someone
please provide some examples or point me at the list of exceptions
that I can catch?  What about catching multiple types of exceptions?

Let's distinguish two kinds of exception handling:


Thanks.  This helps a lot.  Mind if I put it somewhere, such as on the wiki?


A good description of how to deal with exceptions would be great to have in 
the Haddock documentation for Control.Exception - would you (or someone 
else) like to write and submit a patch?  Or failing that, just putting it 
on the wiki would be useful too.


Cheers,
Simon
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: No atomic read on MVar?

2008-11-04 Thread Chris Kuklewicz

It is true that STM's TMVars (which are TVar (Maybe _)) allow atomic readTMVar.

They are not a great replacement for MVars for serious performance reasons.

MVars have wake one semantics: There can be many threads stopped and waiting 
on a particular MVar to be filled/emptied.  These are actually in a FIFO queue. 
 Filling or emptying it will cause the next thread in the FIFO queue to run, 
and leave the others to sleep. [1]


TVars (and TMVars, and all STM threads) have wake all semantics: All threads 
which are stopped after a retry that are monitoring a particular TVar will be 
woken when the TVar is changed by the next STM commit.  This will cause the 
thundering herd problem that plagued big Apache web servers with the original 
multi-process model [2].


To understand MVars and Simon's comments on the atomic read proposal I went and 
read the code in [3] to see it first hand.  The putMVar# and tryPutMVar# 
operations, when a take operation is blocked, will perform the take operation 
and then wake the blocked thread.  The takeMVar# and tryTakeMVar# do the 
reverse.  So adding an atomicRead# operation would mean that on filling the MVar 
that all the atomicRead# that are waiting might need to be woken (or perhaps 
just those at the front of the FIFO).  This is a fairly large change.


The desire to atomically read an MVar could be expressed by
  (1) Use STM and lose the wake one performance
  (2) Use an (MVar ()) guarding the (MVar a)
  (3) Use an (MVar ()) guarding an (IORef a)

Where (3) has a performance advantage to (2) and (3) is safe when only the right 
operations are exposed.


I started looking at this with the opinion that readMVar and withMVar should 
have atomic semantics, i.e. edit PrimOps.cmm to add these operations.  Now I am 
leaning to taking (3) and packaging this as a new module that exposes the safe 
operations.


Cheers,
  Chris


[1] 
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent-MVar.html#v%3AtakeMVar


[2] http://www.google.co.uk/search?q=thundering+herd+apache

[3] http://darcs.haskell.org/ghc/rts/PrimOps.cmm
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: ANNOUNCE: GHC version 6.10.1

2008-11-04 Thread Jason Dagit
On Tue, Nov 4, 2008 at 10:11 AM, Ian Lynagh [EMAIL PROTECTED] wrote:

 How to get it
 ~

 The easy way is to go to the web page, which should be self-explanatory:

http://www.haskell.org/ghc/

 We supply binary builds in the native package format for many
 platforms, and the source distribution is available from the same
 place.

 Packages will appear as they are built - if the package for your
 system isn't available yet, please try again later.

I'm on OSX and I currently have ghc-6.6.1 and ghc-6.8.3 (installed
from a pkg). I would like to add ghc-6.10.1 to my system.  I tried to
do this with RC1 of 6.10, but I found that it uninstalled my
ghc-6.8.3.

What will I need to do to get both 6.8.3 and 6.10.1?

Thank you!
Jason
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Control.Exception

2008-11-04 Thread shelarcy
On Tue, 04 Nov 2008 19:41:58 +0900, Duncan Coutts [EMAIL PROTECTED] wrote:
  action
   `catches`
 [ \(e :: ExitCode) - ...
 , \(e :: PatternMatchFail) - ...
 ]
 
  or just by using multiple catch clauses:
 
  action
   `catch` (\(e :: ExitCode) - ...)
   `catch` (\(e :: PatternMatchFail) - ...)
 
  I don't think those are equivalent. In the second case, the
  PatternMatchFail handler scopes over the ExitCode handler.

 I think Duncan forgot to write parens. According to Ian's example,
 here is an equivalent code.

 (action
   `catch` (\(e :: ExitCode) - ...))
   `catch` (\(e :: PatternMatchFail) - ...)

 David is right. If the exit code handler throws a pattern match
 exception then the code behaves differently than the `catches` version.

I see. I misunderstood the problem.

Thanks,

-- 
shelarcy shelarcyhotmail.co.jp
http://page.freett.com/shelarcy/
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: ANNOUNCE: GHC version 6.10.1 - MacOS installer

2008-11-04 Thread Manuel M T Chakravarty

Jason Dagit:

On Tue, Nov 4, 2008 at 10:11 AM, Ian Lynagh [EMAIL PROTECTED] wrote:


How to get it
~

The easy way is to go to the web page, which should be self- 
explanatory:


  http://www.haskell.org/ghc/

We supply binary builds in the native package format for many
platforms, and the source distribution is available from the same
place.

Packages will appear as they are built - if the package for your
system isn't available yet, please try again later.


I'm on OSX and I currently have ghc-6.6.1 and ghc-6.8.3 (installed
from a pkg). I would like to add ghc-6.10.1 to my system.  I tried to
do this with RC1 of 6.10, but I found that it uninstalled my
ghc-6.8.3.

What will I need to do to get both 6.8.3 and 6.10.1?


Are you sure it does deinstall the 6.8 compiler?  Or does it just  
overwrite the symbolic links in /usr/bin?  To check, have a look at


  /Library/Frameworks/GHC.framework/Versions

After installing 6.10, there should be a 608/ and a 610/ directory.   
This certainly happens on my Mac and I am not aware of an option to  
change that behaviour.


And while we are at it...a BIG FAT WARNING:

  If you installed the 6.10.200081007 pre-release installer package,
  uninstall that *before* installing the 6.10.1 package.

For reasons, I don't understand, the installer otherwise half removes  
the old package, but doesn't seem to install the new one.  Can a Mac  
expert shed any light on that behaviour?


If you tried installing 6.10.1 before reading that, just remove the  
partial installation you are left with, and install again.


Manuel
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: ANNOUNCE: GHC version 6.10.1 - MacOS installer

2008-11-04 Thread Jason Dagit
On Tue, Nov 4, 2008 at 4:26 PM, Manuel M T Chakravarty
[EMAIL PROTECTED] wrote:
 Jason Dagit:

 On Tue, Nov 4, 2008 at 10:11 AM, Ian Lynagh [EMAIL PROTECTED] wrote:

 How to get it
 ~

 The easy way is to go to the web page, which should be self-explanatory:

  http://www.haskell.org/ghc/

 We supply binary builds in the native package format for many
 platforms, and the source distribution is available from the same
 place.

 Packages will appear as they are built - if the package for your
 system isn't available yet, please try again later.

 I'm on OSX and I currently have ghc-6.6.1 and ghc-6.8.3 (installed
 from a pkg). I would like to add ghc-6.10.1 to my system.  I tried to
 do this with RC1 of 6.10, but I found that it uninstalled my
 ghc-6.8.3.

 What will I need to do to get both 6.8.3 and 6.10.1?

 Are you sure it does deinstall the 6.8 compiler?  Or does it just overwrite
 the symbolic links in /usr/bin?  To check, have a look at

  /Library/Frameworks/GHC.framework/Versions

 After installing 6.10, there should be a 608/ and a 610/ directory.  This
 certainly happens on my Mac and I am not aware of an option to change that
 behaviour.

I haven't tried the 6.10.1 install, but after using the 6.8.3 pkg
followed by the 6.10 RC1 pkg, followed by the 6.8.3 pkg, I have just
608 in the directory you mention.

I guess I should try the 6.10.1 install.  If I have to reinstall 6.8.3
again, not the end of the world for me.

 And while we are at it...a BIG FAT WARNING:

  If you installed the 6.10.200081007 pre-release installer package,
  uninstall that *before* installing the 6.10.1 package.

Okay thanks.  Although, I don't think that will be a problem for me
given the directories I can see.

Thanks,
Jason
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: ANNOUNCE: GHC version 6.10.1 - MacOS installer

2008-11-04 Thread Brandon S. Allbery KF8NH

On 2008 Nov 4, at 20:26, Jason Dagit wrote:

On Tue, Nov 4, 2008 at 4:26 PM, Manuel M T Chakravarty
[EMAIL PROTECTED] wrote:

Jason Dagit:

I'm on OSX and I currently have ghc-6.6.1 and ghc-6.8.3 (installed
from a pkg). I would like to add ghc-6.10.1 to my system.  I tried  
to

do this with RC1 of 6.10, but I found that it uninstalled my
ghc-6.8.3.

What will I need to do to get both 6.8.3 and 6.10.1?


Are you sure it does deinstall the 6.8 compiler?  Or does it just  
overwrite

the symbolic links in /usr/bin?  To check, have a look at

/Library/Frameworks/GHC.framework/Versions

After installing 6.10, there should be a 608/ and a 610/  
directory.  This
certainly happens on my Mac and I am not aware of an option to  
change that

behaviour.


I haven't tried the 6.10.1 install, but after using the 6.8.3 pkg
followed by the 6.10 RC1 pkg, followed by the 6.8.3 pkg, I have just
608 in the directory you mention.


I expect if you used the OSX installer then /Library/Receipts is  
screwing you (it wipes the old files listed in the .bom file).  Try  
finding and removing the receipt directory and bom file before  
installing.


--
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


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


[Haskell] ANNOUNCE: GHC version 6.10.1

2008-11-04 Thread Ian Lynagh

   ==
The (Interactive) Glasgow Haskell Compiler -- version 6.10.1
   ==

The GHC Team is pleased to announce a new major release of GHC. There
have been a number of significant changes since the last major release,
including:

 * Some new language features have been implemented:
   * Record syntax: wild-card patterns, punning, and field disambiguation
   * Generalised quasi-quotes
   * Generalised list comprehensions
   * View patterns

 * Type families have been completely re-implemented

 * Now comes with Haddock 2, which supports all GHC extensions

 * Parallel garbage collection

 * Base provides extensible exceptions

 * The GHC API is easier to use

 * External core (output only) now works again

 * Data Parallel Haskell (DPH) comes as part of GHC

The full release notes are here:

  http://haskell.org/ghc/docs/6.10.1/html/users_guide/release-6-10-1.html

How to get it
~

The easy way is to go to the web page, which should be self-explanatory:

http://www.haskell.org/ghc/

We supply binary builds in the native package format for many
platforms, and the source distribution is available from the same
place.

Packages will appear as they are built - if the package for your
system isn't available yet, please try again later.


Background
~~

Haskell is a standard lazy functional programming language; the
current language version is Haskell 98, agreed in December 1998 and
revised December 2002.

GHC is a state-of-the-art programming suite for Haskell.  Included is
an optimising compiler generating good code for a variety of
platforms, together with an interactive system for convenient, quick
development.  The distribution includes space and time profiling
facilities, a large collection of libraries, and support for various
language extensions, including concurrency, exceptions, and foreign
language interfaces (C, whatever).  GHC is distributed under a
BSD-style open source license.

A wide variety of Haskell related resources (tutorials, libraries,
specifications, documentation, compilers, interpreters, references,
contact information, links to research groups) are available from the
Haskell home page (see below).


On-line GHC-related resources
~~

Relevant URLs on the World-Wide Web:

GHC home page  http://www.haskell.org/ghc/
GHC developers' home page  http://hackage.haskell.org/trac/ghc/
Haskell home page  http://www.haskell.org/


Supported Platforms
~~~

The list of platforms we support, and the people responsible for them,
is here:

   http://hackage.haskell.org/trac/ghc/wiki/Contributors

Ports to other platforms are possible with varying degrees of
difficulty.  The Building Guide describes how to go about porting to a
new platform:

http://hackage.haskell.org/trac/ghc/wiki/Building


Developers
~~

We welcome new contributors.  Instructions on accessing our source
code repository, and getting started with hacking on GHC, are
available from the GHC's developer's site run by Trac:

  http://hackage.haskell.org/trac/ghc/


Mailing lists
~

We run mailing lists for GHC users and bug reports; to subscribe, use
the web interfaces at

http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

There are several other haskell and ghc-related mailing lists on
www.haskell.org; for the full list, see

http://www.haskell.org/mailman/listinfo/

Some GHC developers hang out on #haskell on IRC, too:

http://www.haskell.org/haskellwiki/IRC_channel

Please report bugs using our bug tracking system.  Instructions on
reporting bugs can be found here:

http://www.haskell.org/ghc/reportabug

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


[Haskell] FMICS 2009: First Call for Papers

2008-11-04 Thread FMICS 2009 workshop chair

FMICS 2009 - FIRST CALL FOR PAPERS
Please visit: http://www.dsic.upv.es/workshops/fmics2009

**
*14th International Workshop on  *
* Formal Methods for Industrial Critical Systems *
* FMICS 2009 *
**
*  November 2-3, 2009*
*  Eindhoven, The Netherlands*
**

IMPORTANT DATES
---
Deadline for abstracts:  1st April
Deadline for papers:   7 April
Accept/Reject notification:15 June
Camera-ready version:  15 July
Workshop: 2-3 November

SCOPE OF THE WORKSHOP
-
The aim of the ERCIM FMICS workshop series is to provide a forum for
researchers who are interested in the development and application of
formal methods in industry. In particular, these workshops bring
together scientists and engineers that are active in the area of
formal methods and interested in exchanging their experiences in the
industrial usage of these methods.
These workshops also strive to promote research and development for the
improvement of formal methods and tools for industrial applications.
Topics include, but are not restricted to:
- Design, specification, code generation and testing based on formal
methods.
- Methods, techniques and tools to support automated analysis,
certification, debugging, learning, optimization and transformation
of complex, distributed, real-time systems and embedded systems.
- Verification and validation methods that address shortcomings
of existing methods with respect to their industrial applicability
(e.g., scalability and usability issues).
- Tools for the development of formal design descriptions.
- Case studies and experience reports on industrial applications of formal
methods, focusing on lessons learned or identification of new research
directions.
- Impact of the adoption of formal methods on the development process
and associated costs.
- Application of formal methods in standardization and industrial
forums.

INVITED SPEAKERS

To be announced

CO-CHAIRS
-
Maria Alpuente   (Technical University of Valencia, Spain)
Byron Cook   (Microsoft Research, UK)

PROGRAM COMMITTEE
---
Hassan Ait-Kaci  (Ilog, Canada)
Maria Alpuente   (Technical University of Valencia, Spain)
Thomas Arts  (IT-Universitetet i Goteborg, Sweden)
Demis Ballis (Universita degli Studi di Udine, Italy)
Josh Berdine (Microsoft Research, UK)
Lubos Brim   (Masarykova Univerzita, Czech Republic)
Darren Cofer (Rockwell Collins, USA)
Byron Cook   (Microsoft Research, UK)
Patrick Cousot   (Ecole Normale Superieure, France)
Santiago Escobar (Technical University of Valencia, Spain)
Azadeh Farzan(University of Toronto, Canada)
Hubert Garavel   (INRIA Rhone-Alpes, France)
Stefania Gnesi   (ISTI-CNR, Italy)
Alexey Gotsman   (University of Cambridge, UK)
Holger Hermanns  (Universitat des Saarlandes, Germany)
Christophe Joubert   (Technical University of Valencia, Spain)
Daniel Kroening  (ETH Zurich, Switzerland)
Michael Leuschel (Heinrich-Heine-Universitat Dusseldorf, Germany)
Pedro Merino (Universidad de Malaga, Spain)
Juan Jose Moreno-Navarro (Universidad Politecnica de Madrid, Spain)
Corina Pasareanu (NASA Ames Research Center, USA)
Jaco van de Pol  (Universiteit Twente, The Netherlands)
Murali Rangarajan(Honeywell, USA)
Jakob Rehof  (Technische Universitat Dortmund, Germany)
Andrey Rybalchenko   (Max-Planck-Gesellschaft, Germany)
Marcel Verhoef   (Chess, The Netherlands)
Martin Wirsing   (Ludwig-Maximilians-Universitat Munchen, Germany)
Hongseok Yang(Queen Mary, University of London, UK)
Greta Yorsh  (IBM T.J. Watson Research Center, USA)

ERCIM FMICS WG COORDINATOR
--
Alessandro Fantechi  (Universita degli Studi di Firenze and
ISTI-CNR, Italy)

WORKSHOP CHAIR
--
Christophe Joubert   (Technical University of Valencia, Spain)

PAPER SUBMISSIONS
-
Submissions must be made electronically.

Papers should be up to 16 pages in LNCS format, with the names and
affiliations of the authors and a clear and informative
abstract. Additional details may be included in a clearly marked
appendix, which will be read at the discretion of the program
committee. All submissions must report on original research.

Submitted papers must not have previously appeared in a journal or
conference with published proceedings and must not be concurrently
submitted to any other peer-reviewed 

[Haskell] Re: ANNOUNCE: GHC version 6.10.1

2008-11-04 Thread Lennart Kolmodin

Hello fellow GHC users,


Ian Lynagh wrote:

   ==
The (Interactive) Glasgow Haskell Compiler -- version 6.10.1
   ==


[snip]



How to get it
~

The easy way is to go to the web page, which should be self-explanatory:

http://www.haskell.org/ghc/


Gentoo Linux users can get it from the gentoo-haskell overlay[1].

If you're not familiar with this overlay (a gold mine for haskell 
hackers using gentoo), you can easily use layman[2] to get access. Make 
sure you have darcs installed, as it is a requirement for our overlay.


Once layman is set up, add the overlay with:

 $ layman -a haskell

Note that ghc-6.10.1 still is masked by keyword, and you need to unmask 
it first. If you're not familiar with how to do this, here's a quick guide:


 # make sure /etc/portage exists
 $ [[ -d /etc/portage ]] || mkdir /etc/portage
 # accept ghc being ~arch
 $ echo dev-lang/ghc  /etc/portage/package.keywords
 # ghc requires the very latest libedit package
 $ echo dev-libs/libedit  /etc/portage/package.keywords

You may then install ghc-6.10.1 by saying:

 # this requires that you already have an older ghc version installed
 $ USE=ghcbootstrap -binary emerge ghc

The USE flags are required as we don't just yet provide the required 
binaries to bootstrap ghc. The command above requires that you already 
have a ghc version installed to bootstrap with. This version will be 
replaced with ghc-6.10.1 once the installation finishes.


GHC binaries will follow shortly, which will shorten the procedure to:

 $ emerge ghc

The packages from extralibs will also be available from the overlay.

If you run into trouble, reply to the ml, or find us in #gentoo-haskell 
at freenode.


Cheers,
  Lennart Kolmodin -- using his Gentoo Linux Developer hat

 [1] http://code.haskell.org/gentoo/gentoo-haskell/
 [2] http://www.gentoo.org/proj/en/overlays/userguide.xml
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Re: ANNOUNCE: GHC version 6.10.1 - MacOS installer

2008-11-04 Thread Manuel M T Chakravarty

Jason Dagit:

On Tue, Nov 4, 2008 at 10:11 AM, Ian Lynagh [EMAIL PROTECTED] wrote:


How to get it
~

The easy way is to go to the web page, which should be self- 
explanatory:


  http://www.haskell.org/ghc/

We supply binary builds in the native package format for many
platforms, and the source distribution is available from the same
place.

Packages will appear as they are built - if the package for your
system isn't available yet, please try again later.


I'm on OSX and I currently have ghc-6.6.1 and ghc-6.8.3 (installed
from a pkg). I would like to add ghc-6.10.1 to my system.  I tried to
do this with RC1 of 6.10, but I found that it uninstalled my
ghc-6.8.3.

What will I need to do to get both 6.8.3 and 6.10.1?


Are you sure it does deinstall the 6.8 compiler?  Or does it just  
overwrite the symbolic links in /usr/bin?  To check, have a look at


  /Library/Frameworks/GHC.framework/Versions

After installing 6.10, there should be a 608/ and a 610/ directory.   
This certainly happens on my Mac and I am not aware of an option to  
change that behaviour.


And while we are at it...a BIG FAT WARNING:

  If you installed the 6.10.200081007 pre-release installer package,
  uninstall that *before* installing the 6.10.1 package.

For reasons, I don't understand, the installer otherwise half removes  
the old package, but doesn't seem to install the new one.  Can a Mac  
expert shed any light on that behaviour?


If you tried installing 6.10.1 before reading that, just remove the  
partial installation you are left with, and install again.


Manuel
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] Re: ANNOUNCE: GHC version 6.10.1 - MacOS installer

2008-11-04 Thread Brandon S. Allbery KF8NH

On 2008 Nov 4, at 20:26, Jason Dagit wrote:

On Tue, Nov 4, 2008 at 4:26 PM, Manuel M T Chakravarty
[EMAIL PROTECTED] wrote:

Jason Dagit:

I'm on OSX and I currently have ghc-6.6.1 and ghc-6.8.3 (installed
from a pkg). I would like to add ghc-6.10.1 to my system.  I tried  
to

do this with RC1 of 6.10, but I found that it uninstalled my
ghc-6.8.3.

What will I need to do to get both 6.8.3 and 6.10.1?


Are you sure it does deinstall the 6.8 compiler?  Or does it just  
overwrite

the symbolic links in /usr/bin?  To check, have a look at

/Library/Frameworks/GHC.framework/Versions

After installing 6.10, there should be a 608/ and a 610/  
directory.  This
certainly happens on my Mac and I am not aware of an option to  
change that

behaviour.


I haven't tried the 6.10.1 install, but after using the 6.8.3 pkg
followed by the 6.10 RC1 pkg, followed by the 6.8.3 pkg, I have just
608 in the directory you mention.


I expect if you used the OSX installer then /Library/Receipts is  
screwing you (it wipes the old files listed in the .bom file).  Try  
finding and removing the receipt directory and bom file before  
installing.


--
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 mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell-cafe] Typeable and Dynamic

2008-11-04 Thread Luke Palmer
On Mon, Nov 3, 2008 at 7:55 PM, minh thu [EMAIL PROTECTED] wrote:
 Well, it seems you can't really write

 (fromJust . fromDynamic) someDynamic

 without giving the type of what you expect.

Well not by itself.  But context will usually determine the type.  For example:

   putStrLn . fromJust . fromDynamic $ someDynamic

Will happily infer that it should cast to a String.

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


[Haskell-cafe] Re: Typeable and Dynamic

2008-11-04 Thread minh thu
2008/11/4, [EMAIL PROTECTED] [EMAIL PROTECTED]:

 minh thu asked a tricky question, about writing
  extract :: Typeable a = TypeRep - Dynamic - a

 The question here is what determines the type 'a'. One answer is that
 'a' is determined from the context, e.g.,
(extract tr dyn) + 1.0
 fixes 'a' to be an Int. In that case, extract is equivalent to `read'
 (indeed, String is a primitive sort of Dynamic). We do not need any
 argument TypeRep though as we obtain 'a' from the context. fromDynamic
 is sufficient there.

 One can also construe the question to be asking about writing an `inverse' of
 typeOf. Whereas,
typeOf :: Typeable a = a - TypeRep
 can give the TypeRep for any (Typeable) type,
undefinedOf :: Typeable a = TypeRep - a
 could give (an undefined) value for a given TypeRep.

Indeed, that's what I was asking.

 Now, the _type_ 'a' is determined by the _value_ of TypeRep: seemingly we
 need dependent types. To write function of exactly that signature, we
 need Template Haskell. Oftentimes, we can get away with a weaker
 function:

I'll look at Template Haskell then. It's a bit cumbersome to add type
annotations everywhere when using Dynamic.

  data Dyn = forall a. Typeable a = Dyn a
  reflect :: TypeRep - Dyn

 to be used to implement dynApply, dynFst, dynSnd, dynHead and other operations
 on Dynamics. Perhaps the following message may help then
  http://www.haskell.org/pipermail/haskell-cafe/2007-December/036820.html

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


[Haskell-cafe] Re: ANNOUNCE: Graphalyze-0.5 and SourceGraph-0.3

2008-11-04 Thread Ivan Lazar Miljenovic
Achim Schneider barsoap at web.de writes:

 
 That's about what I meant with a screenshot. Linking a copy of the html
 generated for e.g. the Prelude would greatly help people who are just
 browsing Hackage and are trying to figure out what your package is all
 about.
 

Well, I can't do the Prelude (as I said in the original announcement, at the
moment SourceGraph only works on cabalized projects, not individual files,
etc.), but here's the generated reports for Graphalyze and SouceGraph 
themselves:

http://community.haskell.org/~ivanm/Graphalyze/Graphalyze.html
http://community.haskell.org/~ivanm/SourceGraph/SourceGraph.html

I hope they give you a sufficient idea of what SourceGraph does.



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


Re[2]: [Haskell-cafe] a minimal Windows program in Haskell?

2008-11-04 Thread Bulat Ziganshin
Hello Nun,

Monday, November 3, 2008, 11:53:08 PM, you wrote:

 2) the Win32 package in this link gives a type error during the
 setup build phase (expecting exception and given ioerror?) but you
 can compile the example against the Win32 package in ghc 6.8.3

of course - it's written against 6.10.1. you should download sources
of your GHC version and use example from it. look in
http://www.haskell.org/ghc/dist/stable/dist/old


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Network.FastCGI does not emit stderr outputs to lighttpd's error.log?

2008-11-04 Thread Bjorn Bringert
On Thu, Jul 31, 2008 at 6:37 PM, Don Stewart [EMAIL PROTECTED] wrote:
 agentzh:
 On Thu, Jul 31, 2008 at 1:56 AM, Don Stewart [EMAIL PROTECTED] wrote:
 
  We've had no problems with this and apache at least. Is lighttpd
  doing something funny with error logging?

 It seems that Apache is doing something funny :) According to my
 teammate chaoslawful, apache redirects stderr to its error log files
 (if any) but the fastcgi spec actually says everything should go
 through the socket. And lighttpd seems to be following the spec
 exactly :)

 chaoslawful++ finally come up with the following patch for lighttpd
 1.4.19 to make lighttpd behave in the same way as apache. Devel.Debug
 is now finally working for me for my Haskell fastcgi hacking :))

  --- lighttpd-1.4.19/src/log.c2007-08-22 01:40:03.0 +0800
 +++ lighttpd-1.4.19-patched/src/log.c2008-07-31 15:13:10.0 +0800
 @@ -83,9 +83,14 @@
 /* move stderr to /dev/null */
 if (close_stderr 
 -1 != (fd = open(/dev/null, O_WRONLY))) {
 -close(STDERR_FILENO);
 +// XXX: modified by chaoslawful, don't close stderr
 when log into file
 +close(STDERR_FILENO);
 +if (srv-errorlog_mode == ERRORLOG_FILE 
 srv-errorlog_fd =0 ) {
 +dup2(srv-errorlog_fd,STDERR_FILENO);
 +} else {
 dup2(fd, STDERR_FILENO);
 -close(fd);
 +}
 +close(fd);
 }
 return 0;
 }

 Best,
 -agentzh

 Interesting result, thanks for looking into this.

You could also handle this issue without modifying Lighttpd by
redirecting stderr to a file. Put this in your Haskell program:

import System.Posix.Files
import System.Posix.IO

stderrToFile :: FilePath - IO ()
stderrToFile file =
do let mode = ownerModes `unionFileModes` groupReadMode
`unionFileModes` otherReadMode
   fileFd - openFd file WriteOnly (Just mode) (defaultFileFlags {
append = True })
   dupTo fileFd stdError
   return ()

main = do stderrToFile my-fastcgi-log.log
 runFastCGI ...

Another way is to have a small wrapper shell script around your
FastCGI program that does the same redirection.

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


Re: [Haskell-cafe] Syntax question regarding 'import'

2008-11-04 Thread Bulat Ziganshin
Hello Maurí­cio,

Tuesday, November 4, 2008, 3:47:17 PM, you wrote:

 Haskell syntax allows a comma at the end of names
 to be imported or exported, like in the second
 line. What does that mean?

it simplifies editiing of lists: you can add/remove lines without
changing surrounding ones:

import XXX hiding(
  aaa,
  bbb,
  ccc,
 )


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


[Haskell-cafe] Re: Syntax question regarding 'import'

2008-11-04 Thread Achim Schneider
Maurcio [EMAIL PROTECTED] wrote:

 About this teste code:
 
 module Main (main) where {
 import Foreign hiding (unsafePerformIO,Foreign.Ptr,Data.Bits,) ;
 blo = xor 10 10 :: Int ;
 main = return ()
 }
 
You're only hiding the typeclass Data.Bits, not the function xor. To do
that, you have to write

import Foreign hiding (unsafePerformIO,Data.Bits(..))


Generally, I'd use 

import Foo(bar, Baz, Quux(..)) as F

(or even using qualified) instead of using hiding, it may be more
verbose but is way less confusing. Actually, I usually just write

import qualified Foo as F

and don't ever have to worry about name clashes.

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


[Haskell-cafe] Re: Syntax question regarding 'import'

2008-11-04 Thread Maurí­cio

 About this teste code:

 module Main (main) where {
 import Foreign hiding (unsafePerformIO,Foreign.Ptr,Data.Bits,) ;
 blo = xor 10 10 :: Int ;
 main = return ()
 }


 You're only hiding the typeclass Data.Bits, not
 the function xor. To do that, you have to write

 import Foreign hiding (unsafePerformIO,Data.Bits(..))


 Generally, I'd use (...)
 import qualified Foo as F
 and don't ever have to worry about name clashes.

Agree. I'm asking this because I'm wrting my
syntax reference. Is that a GHC extension? Look at
this (from haskell 98 report sections 5.2 and
5.3):

export   - qvar
 | qtycon [(..) | ( cname1 , ... , cnamen )]
 | qtycls [(..) | ( var1 , ... , varn )]
 | module modid

import   - var
 | tycon [ (..) | ( cname1 , ... , cnamen )]
 | tycls [(..) | ( var1 , ... , varn )]

It seems 'modid's are included when exporting
names, but not when importing.

Maurício

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


[Haskell-cafe] announce [(InfixApplicative, 1.0), (OpenGLCheck, 1.0), (obj, 0.1)]

2008-11-04 Thread Thomas Davie

Dear Haskellers,
  I've just uploaded a few packages to Hackage which I have produced  
while working at Anygma.  I thought that people might be interested in  
knowing about these:


obj-0.1:
A library for loading and writing obj 3D models.  This is still an  
early version and rather limited, but it's a starting point.

Features:
  • Load models, complete with normals, texture coordinates and  
materials

  • Compute normals where smoothing groups are specified
  • An example program to load an obj model and render it spinning on  
the screen.

  • Faster loading that Maya itself!
Bugs:
  • Memory usage is rather large
  • The exposed API is rather limited
To Dos:
  • Add support for loading groups
  • Support for smooth surfaces

OpenGLCheck-1.0:
A micro-package containing instances of Arbitrary for the data  
structures provided in Graphics.Rendering.OpenGL.


InfixApplicative-1.0:
A second micro-package containing a pair of functions -- (^) and (^)  
which can be used to provide an infix liftA2 thus:
Suppose we wanted to calculate liftA2 (+) [1,2] [2,3], but are unhappy  
with the fact that (+) is no longer infix, we may now use [1,2]  
^(+)^ [2,3]


Thanks -- any comments are greatly appreciated!

Tom Davie

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


[Haskell-cafe] Efficient parallel regular expressions

2008-11-04 Thread Martijn van Steenbergen

Hello all,

For my mud client Yogurt (see hackage) I'm currently working on
improving the efficiency of the hooks. Right now several hooks, each
consisting of a regex and an action can be active at the same time.
Every time a line of input is available (usually several times a second)
I run the line through all the available regexes and execute the first
matching action.

I figured this is not the cleverest approach and it'd be better if I
|'ed all regexes into one big DFA. However, how do I then find out which
of the original hooks matched and so which action to execute?

As far as I know there's no way to do that with Text.Regex. Alex looks
promising but is really only an executable and doesn't offer an API.
I've also found mr. João Saraiva's HaLex but I don't know if that was
meant to be used seriously.

Does anyone have any experience with this? What's the best way to
achieve this?

Thanks much,

Martijn.

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


[Haskell-cafe] Re: Efficient parallel regular expressions

2008-11-04 Thread Achim Schneider
Martijn van Steenbergen [EMAIL PROTECTED] wrote:

 Does anyone have any experience with this? What's the best way to
 achieve this?
 
For anything remotely connected to parsing, always use parsec. 

I'd not be surprised if the beast is touring complete in itself... or
can parse something that can parse itself, which'd be a reverse quine or
something.

(I'm going to shut up already)

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


Re: [Haskell-cafe] Re: Efficient parallel regular expressions

2008-11-04 Thread Jonathan Cast
On Tue, 2008-11-04 at 18:26 +0100, Achim Schneider wrote:
 Martijn van Steenbergen [EMAIL PROTECTED] wrote:
 
  Does anyone have any experience with this? What's the best way to
  achieve this?
  
 For anything remotely connected to parsing, always use parsec. 
 
 I'd not be surprised if the beast is touring complete in itself...

This is an interesting question: what would constitute
Turing-completeness for an EDSL, independently of the host language?

jcc


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


RE: [Haskell-cafe] Efficient parallel regular expressions

2008-11-04 Thread Mitchell, Neil
Hi Martijn,

It's not that tricky if you do a regular expression state machine yourself, but 
that's probably a bit too much work. One way to get a speed up might be to take 
the regular expressions a,b,c,d and generate a regex a+b+c+d, and one a+b. You 
can then check any string s against a+b+c+d, if that matches check a+b, if that 
matches check a. At each stage you eliminate half the regular expressions, 
which means a match will take log n, where n is the number of regular 
expressions.

This assumes the underlying regular expression engine constructs a finite state 
machine, making it O(m) where m is the length of the string to match.

Thanks

Neil

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Martijn van Steenbergen
 Sent: 04 November 2008 5:05 pm
 To: Haskell Cafe
 Subject: [Haskell-cafe] Efficient parallel regular expressions
 
 Hello all,
 
 For my mud client Yogurt (see hackage) I'm currently working 
 on improving the efficiency of the hooks. Right now several 
 hooks, each consisting of a regex and an action can be active 
 at the same time.
 Every time a line of input is available (usually several 
 times a second) I run the line through all the available 
 regexes and execute the first matching action.
 
 I figured this is not the cleverest approach and it'd be better if I
 |'ed all regexes into one big DFA. However, how do I then 
 find out which
 of the original hooks matched and so which action to execute?
 
 As far as I know there's no way to do that with Text.Regex. 
 Alex looks promising but is really only an executable and 
 doesn't offer an API.
 I've also found mr. João Saraiva's HaLex but I don't know if 
 that was meant to be used seriously.
 
 Does anyone have any experience with this? What's the best 
 way to achieve this?
 
 Thanks much,
 
 Martijn.
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

==
Please access the attached hyperlink for an important electronic communications 
disclaimer: 

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==

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


Re: [Haskell-cafe] Re: Efficient parallel regular expressions

2008-11-04 Thread Dan Piponi
On Tue, Nov 4, 2008 at 9:26 AM, Achim Schneider [EMAIL PROTECTED] wrote:
 Martijn van Steenbergen [EMAIL PROTECTED] wrote:
 For anything remotely connected to parsing, always use parsec.

 I'd not be surprised if the beast is touring complete in itself...

Actually, this can count against you. It's very easy to use Parsec to
build an innocent looking grammar that's too slow to use because it'll
do all kinds of backtracking to find a way to make your input fit the
grammar. I recommend Parsec for lots of tasks, but take care to design
the grammar so it doesn't take exponential time to do anything.
--
Dan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Memory efficiency questions for real-time graphics

2008-11-04 Thread Sebastian Sylvan
On Mon, Nov 3, 2008 at 3:45 PM, Svein Ove Aas [EMAIL PROTECTED] wrote:

 On Mon, Nov 3, 2008 at 11:31 AM, Tobias Bexelius
 [EMAIL PROTECTED] wrote:
  Before Direct3D 10, its too costly to read back the updated vertex data
  in every frame, which force you to make this kind of operations on the
  CPU.
  With D3D 10 however, you should use the new Stream-Output stage which is
  used to return updated vertex data directly to a vertex buffer on the
  GPU. So if you can afford a new graphics card and likes Vista, that's
  the way to go :)
 
 Or you could use OpenGL, which has supported that since the first GPUs
 that did were released.


I think that came with OpenGL 3.0. Unless you're counting vendor-specific
extensions...
-- 
Sebastian Sylvan
+44(0)7857-300802
UIN: 44640862
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-04 Thread Kim-Ee Yeoh


David Menendez-2 wrote:
 
 On Mon, 3 Nov 2008, Luke Palmer wrote:

 I was actually being an annoying purist.  f is strict means f _|_ =
 _|_, so strictness is a semantic idea, not an operational one.
 
 I think Luke was commenting on the terminology, not the optimization.
 We have a tendency to say lazy when we mean non-strict and
 strict when we mean eager.
 

Good point. If it sheds light on such elusive, important distinctions 
then this incorrigible pedantry can only be encouraged.

-- 
View this message in context: 
http://www.nabble.com/Problems-with-strictness-analysis--tp20301967p20319740.html
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


Re: [Haskell-cafe] code generation

2008-11-04 Thread Martin Hofmann
Sorry for referring to a post, a bit ago.

 http://www-users.cs.york.ac.uk/~ndm/derive/ (Deriving Generic Functions
 by Example).
 
Thanks for the pointer, it was already on my to-read-pile :-)

 I think using Template Haskell for your work would fit very nicely, so
 is a good choice to learn :-)
 
I already got used to TH a bit, but I am not sure if it is appropriate
for my purpose, or at least not completely.

I want to load Haskell code into my program at runtime in an abstract
representation (as TH), modify it and then type-check it or coerce it
into a value (or execute it). For me it looks like I need a combination
of Hint and TH. 

However, Hint can only interpret strings and to get a string from a QExp
I have to enter the IO Monad using runQ. So, wouldn't it deteriorate my
performance to do it all in the IO? Is there another way?


Thanks,


Martin


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


[Haskell-cafe] Re: Efficient parallel regular expressions

2008-11-04 Thread Achim Schneider
Dan Piponi [EMAIL PROTECTED] wrote:

 On Tue, Nov 4, 2008 at 9:26 AM, Achim Schneider [EMAIL PROTECTED]
 wrote:
  Martijn van Steenbergen [EMAIL PROTECTED] wrote:
  For anything remotely connected to parsing, always use parsec.
 
  I'd not be surprised if the beast is touring complete in itself...
 
 Actually, this can count against you. It's very easy to use Parsec to
 build an innocent looking grammar that's too slow to use because it'll
 do all kinds of backtracking to find a way to make your input fit the
 grammar. I recommend Parsec for lots of tasks, but take care to design
 the grammar so it doesn't take exponential time to do anything.

Considering that he's talking about a mud, I figure the grammar is a
quite straightforward

command = l[eft] | r[ight] | ... | t[ake] item | c[ast] spell

That is, I'd be very surprised if you even need more than two or three
characters lookahead, much less backtracking.

Parsec is a thousand times more efficient for such things than regular
expressions, and you can just lazily parse all the input into a list
of data constructors and happily fold it into your state...
The only thing more straightforward than this is reading a xml with
HaXML (if you have a DTD, that is)


-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


[Haskell-cafe] Re: Problems with strictness analysis?

2008-11-04 Thread Dominic Steinitz
wren ng thornton wren at freegeek.org writes:

[snick]

  isum 0 s = s
  isum n s = isum (n-1) (s+n)
 
 This is tail recursive, and will be optimized to an iterative loop; 

[snick]

 
 In terms of having a compiler 'smart enough', it's not clear that 
 functions of this sort ought to be inferred strict simply because the 
 accumulator is ultimately returned to the caller. Consider for example:

I thought this was strict as Luke Palmer has already pointed out. My 
understanding is that a compiler may be able to infer it is strict and then 
perform eager evaluation.

 
f 0 xs = xs
f n xs = f (n-1) (replicate n n ++ xs)
 
 Since (++) can indeed return partial answers, it's fine for the 
 accumulator to be lazy. Indeed, making it strict harms performance 
 significantly. Another example is when the accumulator is a function, as 

Can this function be strict if (++)isn't? And if it isn't strict, why would it 
make sense to evaluate it eagerly?

Dominic.

PS This subject seems to come up often enough to be worth a wiki entry (maybe 
there already is one). I think we should also be careful with terminology (as 
Luke Palmer and David Menendez have pointed out. Maybe that could be included 
in the wiki entry.

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


Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-04 Thread Ketil Malde
Patai Gergely [EMAIL PROTECTED] writes:

 My only problem is that if I try to write a program without
 thinking about performance first and not bothering with annotations as
 long as it works, I end up with something that's practically
 impossible to profile as the costs spread everywhere.

I didn't think that was the case, does that happen with the example
you posted?  (I find GHC's heap profiling to be useful in tracking down
these strictness leaks.)

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] code generation

2008-11-04 Thread Mitchell, Neil
 
  I think using Template Haskell for your work would fit very 
 nicely, so 
  is a good choice to learn :-)
  
 I already got used to TH a bit, but I am not sure if it is 
 appropriate for my purpose, or at least not completely.
 
 I want to load Haskell code into my program at runtime in an 
 abstract representation (as TH), modify it and then 
 type-check it or coerce it into a value (or execute it). For 
 me it looks like I need a combination of Hint and TH.

Perhaps. You might be able to use the GHC API to get some of what you
want too.

 However, Hint can only interpret strings and to get a string 
 from a QExp I have to enter the IO Monad using runQ. So, 
 wouldn't it deteriorate my performance to do it all in the 
 IO? Is there another way?

I wouldn't worry about performance just yet. In general, Haskell code in
the IO Monad is just as efficient as normal code - the IO Monad gets
almost entirely optimised away by GHC.

Thanks

Neil

==
Please access the attached hyperlink for an important electronic communications 
disclaimer: 

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==

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


Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-04 Thread Patai Gergely
Thanks everyone for the answers. I understood the underlying mechanism,
and I did see that turning on optimisation helps, as I said in the
comments. I just wasn't aware that this analysis is not turned on by
default, my bad for not reading the FM.

So the final verdict is that type and strictness annotations are
unavoidable when it comes to improving performance. This is no big
surprise. My only problem is that if I try to write a program without
thinking about performance first and not bothering with annotations as
long as it works, I end up with something that's practically
impossible to profile as the costs spread everywhere. I'd be curious to
hear about best practices to avoid this, while also getting the most
out of type inference and various analyses to cut down on developer
effort. How should I approach writing a large application in Haskell?

Gergely

-- 
http://www.fastmail.fm - IMAP accessible web-mail

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


[Haskell-cafe] Re: Efficient parallel regular expressions

2008-11-04 Thread ChrisK

The regex-tdfa package (and regex-posix) implement subexpressions capture.

So if you want to match alpha beta and gamma in parallel you could write

(alpha)|(beta)|(gamma) and check which subexpression has the non-empty match.

This becomes slightly complicated if there are parenthesis and captures inside 
alpha beta or gamma.  Then you need to compute the indices that are the top 
level captures.


In particular, the regex-tdfa package (get the latest from 
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-tdfa ) will 
create a DFA and run through the input once without backtracking.  It will find 
the leftmost-longest match, so the order of the branches only matters if there 
is a tie in length.


If you need to be left-biased then you need a perl-style engine, and you can use 
the regex-pcre or pcre-light haskell package and the PCRE library.  These are 
obtainable from Hackage.  I doubt PCRE uses a simple DFA...


Cheers,
  Chris

Martijn van Steenbergen wrote:

Hello all,

For my mud client Yogurt (see hackage) I'm currently working on
improving the efficiency of the hooks. Right now several hooks, each
consisting of a regex and an action can be active at the same time.
Every time a line of input is available (usually several times a second)
I run the line through all the available regexes and execute the first
matching action.

I figured this is not the cleverest approach and it'd be better if I
|'ed all regexes into one big DFA. However, how do I then find out which
of the original hooks matched and so which action to execute?

As far as I know there's no way to do that with Text.Regex. Alex looks
promising but is really only an executable and doesn't offer an API.
I've also found mr. Jo�o Saraiva's HaLex but I don't know if that was
meant to be used seriously.

Does anyone have any experience with this? What's the best way to
achieve this?

Thanks much,

Martijn.


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


Re: [Haskell-cafe] Re: Efficient parallel regular expressions

2008-11-04 Thread pierre
On Tue, Nov 04, 2008 at 08:34:37PM +0100, Achim Schneider wrote:
 
 Parsec is a thousand times more efficient for such things than regular
 expressions, and you can just lazily parse all the input into a list
 of data constructors and happily fold it into your state...

I would recommend you to use parsec too; my experience suggests that
parsec often results in much cleaner and readable implementation than
obscure regexps.

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


Re: [Haskell-cafe] HDBC Oracle bindings(?/!)

2008-11-04 Thread Thiago Arrais
On Thu, Oct 30, 2008 at 11:53 AM, Daniil Elovkov
[EMAIL PROTECTED] wrote:
 Yes, HSQL supports Oracle natively, through OCI. hsql-oracle isn't on
 hackage, only in the repository.

That's exactly what I was looking for, but for HDBC instead. Since OCI
bindings for HDBC don't seem to exist, I guess I'll have to write my
own instead.

 I don't know how Takusen's oci code looks, but I would suspect that porting
 HSQL Oracle code to HDBC could be simpler, because HDBC and HSQL are quite
 similar in their interfaces, unlike Takusen.

Thanks for the tip. I really wasn't aware that HSQL already had OCI
bindings. I'll take a look at the HSQL code, steal some ideas from it
and hopefully make my little HDBC driver production ready some day.

Cheers,

Thiago Arrais
--
Enjoy Chaos - http://blog.thiagoarrais.com
Thoughts, ideas and useless ranting about software development and technology
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Efficient parallel regular expressions

2008-11-04 Thread Martin DeMello
On Tue, Nov 4, 2008 at 9:05 AM, Martijn van Steenbergen
[EMAIL PROTECTED] wrote:

 For my mud client Yogurt (see hackage) I'm currently working on
 improving the efficiency of the hooks. Right now several hooks, each
 consisting of a regex and an action can be active at the same time.
 Every time a line of input is available (usually several times a second)
 I run the line through all the available regexes and execute the first
 matching action.

 I figured this is not the cleverest approach and it'd be better if I
 |'ed all regexes into one big DFA. However, how do I then find out which
 of the original hooks matched and so which action to execute?

Is this really a problem in practice? I've done similar things in
Ruby, which is a much slower language, and not had any issues -
particularly in something IO bound like a MUD client it doesn't seem
that running down a few tens of regexps would be a bottleneck of any
sort.

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


[Haskell-cafe] Syntax question regarding 'import'

2008-11-04 Thread Maurí­cio

Hi,

About this teste code:

module Main (main) where {
import Foreign hiding (unsafePerformIO,Foreign.Ptr,Data.Bits,) ;
blo = xor 10 10 :: Int ;
main = return ()
}

Data.Bits is in the 'hiding' list. According to
the syntax reference, this seems not to be allowed.
GHC allows it, but do allow following code to use
'xor' from Data.Bits. I think this is correct, since
'xor' was exported by Foreign unqualified, but does
'Data.Bits' in that list mean something or it's
just ignored?

Haskell syntax allows a comma at the end of names
to be imported or exported, like in the second
line. What does that mean?

Thanks,
Maurício

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


Re: [Haskell-cafe] HDBC Oracle bindings(?/!)

2008-11-04 Thread Thiago Arrais
John,

On Thu, Oct 30, 2008 at 2:48 PM, John Goerzen [EMAIL PROTECTED] wrote:
 I would certainly happily reference anyone's native Oracle HDBC
 backend too, though!

You may want to reference mine, given that there aren't any others
currently. Just be aware that it really isn't ready for mass
consumption yet.

Cheers,

Thiago Arrais
--
Enjoy Chaos - http://blog.thiagoarrais.com
Thoughts, ideas and useless ranting about software development and technology
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] foldl vs foldl'

2008-11-04 Thread Daryoush Mehrtash
Are there cases (function or list) where the result of foldl (or foldr)would
be different that foldl' (or foldr')?

thanks,

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


[Haskell-cafe] Re: foldl vs foldl'

2008-11-04 Thread Achim Schneider
Daryoush Mehrtash [EMAIL PROTECTED] wrote:

 Are there cases (function or list) where the result of foldl (or
 foldr)would be different that foldl' (or foldr')?
 
Yes, in two cases folds can differ:

a) You've got an infinite list, in which case you don't want to go to
the end of it before starting to return values

b) You don't have infinite memory and thus need things to be strict (or
just don't want to pay the overhead of allocating millions of thunks
for no good reason whatsoever, in case you're lucky enough to have
enough memory for your data)

-- 
(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.


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


Re: [Haskell-cafe] foldl vs foldl'

2008-11-04 Thread Derek Elkins
On Tue, 2008-11-04 at 15:08 -0800, Daryoush Mehrtash wrote:
 
 Are there cases (function or list) where the result of foldl (or
 foldr)would be different that foldl' (or foldr')?

There is no foldr'.  And yes, foldl and foldl' are different functions
and thus return different results on some inputs; however, you almost
always want foldl' (v. foldl).  See
http://www.haskell.org/haskellwiki/Stack_overflow

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


Re: [Haskell-cafe] foldl vs foldl'

2008-11-04 Thread Daniel Fischer
Am Mittwoch, 5. November 2008 00:08 schrieb Daryoush Mehrtash:
 Are there cases (function or list) where the result of foldl (or
 foldr)would be different that foldl' (or foldr')?

 thanks,

 daryoush

Simple example:
import Data.List

weird :: Int - Int - Int
weird _ 0 = 0
weird x y = x*y

list :: [Int]
list = [1, 2, 3, 4, undefined, 6, 7, 8, 9, 0]

okey = foldl weird 1 list

boom = foldl' weird 1 list

*Main okey
0
*Main boom
*** Exception: Prelude.undefined

since foldl' evaluates strictly (to WHNF), it can die on encountering an 
undefined value in the list where foldl doesn't.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Efficient parallel regular expressions

2008-11-04 Thread Derek Elkins
On Tue, 2008-11-04 at 10:02 -0800, Dan Piponi wrote:
 On Tue, Nov 4, 2008 at 9:26 AM, Achim Schneider [EMAIL PROTECTED] wrote:
  Martijn van Steenbergen [EMAIL PROTECTED] wrote:
  For anything remotely connected to parsing, always use parsec.
 
  I'd not be surprised if the beast is touring complete in itself...
 
 Actually, this can count against you. It's very easy to use Parsec to
 build an innocent looking grammar that's too slow to use because it'll
 do all kinds of backtracking to find a way to make your input fit the
 grammar. I recommend Parsec for lots of tasks, but take care to design
 the grammar so it doesn't take exponential time to do anything.

Backtracking points are explicit in Parsec which is one of the whole
points of it.  This makes it pretty difficult to innocently end up
with exponential behavior.  Backtracking requires a use of the 'try'
combinator.  It's pretty easy to recognize potentially dangerous uses of
'try'.  If you use 'try' willy-nilly or you just throw 'try' in when you
are having difficulties then I can quite easily imagine one quickly
ending up with exponential behavior.  Otherwise, it should not be easy
to do and if you like you can not use 'try' (or 'try' using combinators)
at all and you surely won't get exponential behavior (as far as Parsec
is concerned).

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


Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-04 Thread Derek Elkins
On Tue, 2008-11-04 at 12:18 +0100, Patai Gergely wrote:
 Thanks everyone for the answers. I understood the underlying mechanism,
 and I did see that turning on optimisation helps, as I said in the
 comments. I just wasn't aware that this analysis is not turned on by
 default, my bad for not reading the FM.
 
 So the final verdict is that type and strictness annotations are
 unavoidable when it comes to improving performance. This is no big
 surprise. My only problem is that if I try to write a program without
 thinking about performance first and not bothering with annotations as
 long as it works, I end up with something that's practically
 impossible to profile as the costs spread everywhere. I'd be curious to
 hear about best practices to avoid this, while also getting the most
 out of type inference and various analyses to cut down on developer
 effort. How should I approach writing a large application in Haskell?

Strictness annotations aren't optimizations.  As Luke Palmer pointed
out, making something strict is a change in semantics.  Similarly for
type annotations; either they do nothing or they restrict the type which
certainly has semantic ramifications.  Neither strictness nor type
annotations should be viewed as something outside of your program.
They are a part of your program.

At any rate, for the particular issues you've mentioned in this thread
I'd recommend not writing code you know is bad in the first place, in
much the same way that Scheme programmers usually write code tail
recursively from the start.  They don't write code (non tail)
recursively and then profile to find the hotspots.  There are a few
well-known problematic patterns in Haskell that can be relatively easily
recognized and remedied.  Those should be dealt with as you write the
code.  Note that here I'm talking about issues like stack overflow; you
shouldn't rely on strictness analysis to avoid stack overflow, but it is
fine to rely on strictness analysis for things like unboxing and such.  

Basically, if you don't do stupid stuff, such as well-known
anti-patterns or obviously inefficient things, then you should typically
get reasonable performance with maybe a few things that the profiler can
help you with.  If you are specifically going for performance, then
there are techniques and approaches geared toward that.

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


Re: [Haskell-cafe] foldl vs foldl'

2008-11-04 Thread Bas van Dijk
2008/11/5 Daryoush Mehrtash [EMAIL PROTECTED]:
 Are there cases (function or list) where the result of foldl (or foldr)would
 be different that foldl' (or foldr')?

Maybe this wiki article I wrote some time ago will answer your question:

http://haskell.org/haskellwiki/Foldr_Foldl_Foldl'

regards,

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


Re: [Haskell-cafe] foldl vs foldl'

2008-11-04 Thread Bas van Dijk
On Wed, Nov 5, 2008 at 12:43 AM, Bas van Dijk [EMAIL PROTECTED] wrote:
 2008/11/5 Daryoush Mehrtash [EMAIL PROTECTED]:
 Are there cases (function or list) where the result of foldl (or foldr)would
 be different that foldl' (or foldr')?

 Maybe this wiki article I wrote some time ago will answer your question:

 http://haskell.org/haskellwiki/Foldr_Foldl_Foldl'

Oops that link should be:

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


Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-04 Thread Lennart Augustsson
Nonsense, isum is strict in s.  If s is bottom, isum will always return bottom.
This is the definition of being strict.

  -- Lennart

On Mon, Nov 3, 2008 at 10:35 PM, Don Stewart [EMAIL PROTECTED] wrote:
 frantisek.kocun:
yet I need to add a $! to the recursive call of isum to get a truly
iterative ???

Wait a minute Patai. How would you do that? I'm only beginner I thought I
can only add strict ! to data parameters. But to make isum function
strict would be helpful.


 Consider this program,

isum  0  s = s
isum  n  s = isum (n-1) (s+n)

main = case isum 1000 0 {- rsum 1000 -} of
 0 - print 0
 x - print x

 Now, isum is *not* strict in 's', so without some additional hints or 
 analysis, this
 won't be evaluated until the result of isum is required. It will build up a 
 long change of (s + n)
 on the stack.

-O0
$ time ./A
Stack space overflow: current size 8388608 bytes.

 Of course, we make this strict in a number of ways:


 * Turning on optimisations:
-O2
$ time ./A
500500
./A  0.31s user 0.00s system 99% cpu 0.312 total

 * Use an explict bang pattern on the 's' variable:

{-# LANGUAGE BangPatterns #-}

isum  0  s = s
isum  n !s = isum (n-1) (s+n)

   -O0
$ time ./A
500500
./A  0.69s user 0.00s system 95% cpu 0.721 total

 Note that by being explict about the strictness in 's' this program produces 
 the desired result
 even with all optimisations disabled.

 We can then turn on other optimisations:

-O2 -fvia-C -optc-O2
$ time ./A
500500
./A  0.31s user 0.00s system 101% cpu 0.313 total

 And it just gets faster.

 Now, we can also add an explicit type signature to constrain to a machine Int:

-O2 -fvia-C -optc-O2
$ time ./A
500500
./A  0.03s user 0.00s system 100% cpu 0.033 total

 Meaing the final version is:

isum :: Int - Int - Int
isum  0  s = s
isum  n !s = isum (n-1) (s+n)

 So: if you rely on tail recursion on a particular variable, make sure it is
 enforced as strict. That's the simplest, most robust way to ensure the
 reduction strategy you want is used.

 -- Don

 ___
 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


[Haskell-cafe] pure programs

2008-11-04 Thread Jason Dusek
  Informally, a pure program an executable such that the
  stream of bytes entering it totally determines the stream of
  bytes leaving it.

  Many useful programs that I would like to write in Haskell
  don't fall into this category -- for example, network servers
  -- but a lot of their components do. Can these components can
  be Haskell functions without IO in their signatures?

  Though that seems reasonable, it is not, in general, true. For
  example,System.Info.osis generally treated as pure,
  though it is not. It's not clear to me how to disambiguate
  these born again values from really pure values.

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


Re: [Haskell-cafe] pure programs

2008-11-04 Thread Jamie Brandon
You're essentially describing functional reactive programming. You end
up with the system being described as pure, reactive values and
plugging IO based streams in at the edges.

Have a look at the wiki description
(http://www.haskell.org/haskellwiki/Functional_Reactive_Programming)
and especially the Reactive library
(http://www.haskell.org/haskellwiki/Reactive).

Theres been a fair amount of work on using frp for distributed,
network-orientated systems. Flask
(http://portal.acm.org/citation.cfm?id=1411203.1411251) and Opis
(http://perso.eleves.bretagne.ens-cachan.fr/~dagand/opis/) are
particularly interesting. Opis really shows the value of using pure
functions by allowing the same reactive system to be run in
production, attached to a debugger, run in a step-by-step simulator or
run in a model checker without altering the systems code.

On Wed, Nov 5, 2008 at 12:12 AM, Jason Dusek [EMAIL PROTECTED] wrote:
  Informally, a pure program an executable such that the
  stream of bytes entering it totally determines the stream of
  bytes leaving it.

  Many useful programs that I would like to write in Haskell
  don't fall into this category -- for example, network servers
  -- but a lot of their components do. Can these components can
  be Haskell functions without IO in their signatures?

  Though that seems reasonable, it is not, in general, true. For
  example,System.Info.osis generally treated as pure,
  though it is not. It's not clear to me how to disambiguate
  these born again values from really pure values.

 --
 _jsn
 ___
 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] pure programs

2008-11-04 Thread Brandon S. Allbery KF8NH

On 2008 Nov 4, at 19:12, Jason Dusek wrote:

 Many useful programs that I would like to write in Haskell
 don't fall into this category -- for example, network servers
 -- but a lot of their components do. Can these components can
 be Haskell functions without IO in their signatures?



I'm working on a report generator (for my own use, probably will be  
too limited for practical use until/unless I have a need); the input  
data and output ultimately have to be in IO, but the bulk of the  
program (and all of the library) is pure; you *want* a report to  
produce the same output for the same input.


--
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


[Haskell-cafe] HXT/Practical/Weather.hs difficulties

2008-11-04 Thread Brian Troutwine
Hello all,

I'm working through the practical HXT examples and have gotten stumped
with the weather example[1]. I'm using GHC 6.8.3 and HXT 8.1.0. I
compile the example like so...

 [EMAIL PROTECTED]:~
 $ ghc --make weather.hs
 [1 of 1] Compiling Main ( weather.hs, weather.o )
 Linking weather ...

And execute it...

 [EMAIL PROTECTED]:~
 $ ./weather

 error: !DOCTYPE HTML PUBLIC \-//IETF//DTD HTML 2.0/... (line 1, column 
 16):
 unexpected P
 expecting white space, [ or 

 Unable to parse weather data.

Woops. Would someone be so kind as to explain why this is failing? I'm
at rather a loss.

[1] http://www.haskell.org/haskellwiki/HXT/Practical/Weather1

--Brian

P.S. Is this question better suited to the haskell-beginner list?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HXT/Practical/Weather.hs difficulties

2008-11-04 Thread Brian Troutwine
Oh my, how silly of me. The page has moved to
http://www.weather.gov/xml/current_obs/KAGC.xml ! Firefox simply
follows the redirect.

Thanks for the putStrLn suggestion, George.

On Tue, Nov 4, 2008 at 5:28 PM, George Pollard [EMAIL PROTECTED] wrote:
 On Tue, 2008-11-04 at 17:04 -0800, Brian Troutwine wrote:
  [EMAIL PROTECTED]:~
  $ ./weather
 
  error: !DOCTYPE HTML PUBLIC \-//IETF//DTD HTML 2.0/... (line 1, 
  column 16):
  unexpected P
  expecting white space, [ or 
 
  Unable to parse weather data.

 Woops. Would someone be so kind as to explain why this is failing? I'm
 at rather a loss.

 The HXT parser is stopping because it's expecting XML not HTML, which is
 what you're receiving for some reason.

 I just loaded up the weather URL in Firefox
 [http://www.weather.gov/xml/current_obs/KAGC.xml] and it is XML... Is it
 possible that you are behind a proxy that is blocking the page? (I can't
 run the code at the moment; cleaning out Haskell packages to upgrade to
 6.10.)

 You could try printing out the contents of the page as well (putStrLn
 doc) so you can see the rest of the HTML that `weather` is receiving.




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


Re: [Haskell-cafe] Re: Efficient parallel regular expressions

2008-11-04 Thread ajb

G'day all.

Quoting Achim Schneider [EMAIL PROTECTED]:


Considering that he's talking about a mud, I figure the grammar is a
quite straightforward

command = l[eft] | r[ight] | ... | t[ake] item | c[ast] spell

That is, I'd be very surprised if you even need more than two or three
characters lookahead, much less backtracking.


In the case of a command followed by arguments, it would make more
sense to use a keyword recogniser followed by a command-specific parser.

One suggestion follows.

Cheers,
Andrew Bromage
8---CUT HERE---8
module KeywordMatch (keywordMatch) where

import Data.List
import Data.Function
import Control.Arrow

-- Exercise: Why would it be wrong to curry this function?
keywordMatch :: (Ord k) = [([k],v)] - [k] - Maybe v
keywordMatch kvs
= compileTrie . generateTrie . sortBy (compare `on` fst) $ kvs

data Trie k v
= Trie (Maybe v) (Trie' k v)

data Trie' k v
= Node0
| Node1 k (Trie k v)
| Node2 k (Trie k v) k (Trie k v)
| Branch k (Trie' k v) (Trie k v) (Trie' k v)

generateTrie :: (Ord k) = [([k],v)] - Trie k v
generateTrie (([],v):rest)
= Trie (Just v) (generateTrie' rest)
generateTrie rest
= Trie Nothing (generateTrie' rest)

generateTrie' :: (Ord k) = [([k],v)] - Trie' k v
generateTrie' []
= Node0
generateTrie' [(k:ks,v)]
= Node1 k $ foldr (\k - Trie Nothing . Node1 k) (Trie (Just v) Node0) ks
generateTrie' [(k1:ks1,v1),(k2:ks2,v2)]
= Node2 k1 (generateTrie [(ks1,v1)]) k2 (generateTrie [(ks2,v2)])
generateTrie' kvs
= gt . map (head.fst.head  map (first tail))
. groupBy ((==) `on` head.fst) $ kvs
where
gt [] = Node0
gt [(k,kvs)] = Node1 k (generateTrie kvs)
gt [(k1,kvs1),(k2,kvs2)] = Node2 k1 (generateTrie kvs1)
 k2 (generateTrie kvs2)
gt kvs
= let (l,(k,m):r) = splitAt (length kvs `div` 2) kvs
  in Branch k (gt l) (generateTrie m) (gt r)

compileTrie :: (Ord k) = Trie k v - [k] - Maybe v
compileTrie (Trie emptyCase trie')
= let ctrie' = compileTrie' trie'
  in \key - case key of
[] - emptyCase
(k:ks) - ctrie' k ks

compileTrie' :: (Ord k) = Trie' k v - k - [k] - Maybe v
compileTrie' Node0
= \k ks - Nothing
compileTrie' (Node1 k' t)
= let t' = compileTrie t
  in \k ks - if k == k' then t' ks else Nothing
compileTrie' (Node2 k1 t1 k2 t2)
= let t1' = compileTrie t1
  t2' = compileTrie t2
  in \k ks - if k == k1 then t1' ks
  else if k == k2 then t2' ks
  else Nothing
compileTrie' (Branch k' l m r)
= let
cl = compileTrie' l
cm = compileTrie m
cr = compileTrie' r
  in
\k ks - case compare k k' of
LT - cl k ks
EQ - cm ks
GT - cr k ks

-- vim: ts=4:sts=4:expandtab
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Efficient parallel regular expressions

2008-11-04 Thread ajb

G'day all.

Quoting Achim Schneider [EMAIL PROTECTED]:


Considering that he's talking about a mud, I figure the grammar is a
quite straightforward

command = l[eft] | r[ight] | ... | t[ake] item | c[ast] spell

That is, I'd be very surprised if you even need more than two or three
characters lookahead, much less backtracking.


In the case of a command followed by arguments, it would make more
sense to use a keyword recogniser followed by a command-specific parser.

One suggestion follows.

Cheers,
Andrew Bromage
8---CUT HERE---8
module KeywordMatch (keywordMatch) where

import Data.List
import Data.Function
import Control.Arrow

-- Exercise: Why would it be wrong to curry this function?
keywordMatch :: (Ord k) = [([k],v)] - [k] - Maybe v
keywordMatch kvs
= compileTrie . generateTrie . sortBy (compare `on` fst) $ kvs

data Trie k v
= Trie (Maybe v) (Trie' k v)

data Trie' k v
= Node0
| Node1 k (Trie k v)
| Node2 k (Trie k v) k (Trie k v)
| Branch k (Trie' k v) (Trie k v) (Trie' k v)

generateTrie :: (Ord k) = [([k],v)] - Trie k v
generateTrie (([],v):rest)
= Trie (Just v) (generateTrie' rest)
generateTrie rest
= Trie Nothing (generateTrie' rest)

generateTrie' :: (Ord k) = [([k],v)] - Trie' k v
generateTrie' []
= Node0
generateTrie' [(k:ks,v)]
= Node1 k $ foldr (\k - Trie Nothing . Node1 k) (Trie (Just v) Node0) ks
generateTrie' [(k1:ks1,v1),(k2:ks2,v2)]
= Node2 k1 (generateTrie [(ks1,v1)]) k2 (generateTrie [(ks2,v2)])
generateTrie' kvs
= gt . map (head.fst.head  map (first tail))
. groupBy ((==) `on` head.fst) $ kvs
where
gt [] = Node0
gt [(k,kvs)] = Node1 k (generateTrie kvs)
gt [(k1,kvs1),(k2,kvs2)] = Node2 k1 (generateTrie kvs1)
 k2 (generateTrie kvs2)
gt kvs
= let (l,(k,m):r) = splitAt (length kvs `div` 2) kvs
  in Branch k (gt l) (generateTrie m) (gt r)

compileTrie :: (Ord k) = Trie k v - [k] - Maybe v
compileTrie (Trie emptyCase trie')
= let ctrie' = compileTrie' trie'
  in \key - case key of
[] - emptyCase
(k:ks) - ctrie' k ks

compileTrie' :: (Ord k) = Trie' k v - k - [k] - Maybe v
compileTrie' Node0
= \k ks - Nothing
compileTrie' (Node1 k' t)
= let t' = compileTrie t
  in \k ks - if k == k' then t' ks else Nothing
compileTrie' (Node2 k1 t1 k2 t2)
= let t1' = compileTrie t1
  t2' = compileTrie t2
  in \k ks - if k == k1 then t1' ks
  else if k == k2 then t2' ks
  else Nothing
compileTrie' (Branch k' l m r)
= let
cl = compileTrie' l
cm = compileTrie m
cr = compileTrie' r
  in
\k ks - case compare k k' of
LT - cl k ks
EQ - cm ks
GT - cr k ks

-- vim: ts=4:sts=4:expandtab
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Automatic parallelism in Haskell, similar to make -j4?

2008-11-04 Thread Chad Scherrer
T Willingham t.r.willingham at gmail.com writes:
 I am thinking of our troglodytic friend 'make', which will run (for
 example) 4 parallel jobs when given the option make -j4.  Even
 'rake', the ruby version of make, now has a branch (called drake)
 which does the parallel -j option.

From the replies I've seen about this, I think it's been interpreted as asking
whether ghc could compile a given program so that it will execute in parallel.
In general that's a hard problem.

On the other hand, it should be really straightforward (in principle, I mean) to
get something going like
ghc --make -j4 Foo.hs
similar to your make example, so that compile time could be reduced, while the
execution could either be sequential or parallel. I don't think there's anything
like this yet (is there?). 

Does anyone have any thought what it would take to get this going?

Chad

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


[Haskell-cafe] view patterns

2008-11-04 Thread Cetin Sert
let has [] = False; has _ = True

-- this one is ok
let empty list = case has list of True - False; False - True

-- the following is problematic
let emp (has - True) = False; emp (has - False) = True

interactive:1:4:
Warning: Pattern match(es) are overlapped
 In the definition of `emp':
 emp ((has - True)) = ...
 emp ((has - False)) = ...

Why do I get this error in ghc or when I try to compile a file with view
patterns?
(using -fglasgow-exts  and -XViewPatterns, ghc 6.10.1)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] pure programs

2008-11-04 Thread Bulat Ziganshin
Hello Jason,

Wednesday, November 5, 2008, 3:12:29 AM, you wrote:

   Many useful programs that I would like to write in Haskell
   don't fall into this category -- for example, network servers
   -- but a lot of their components do. Can these components can
   be Haskell functions without IO in their signatures?

pure function is one those result depends only on its arguments. as
far as you can provide input stream as an function argument, it
should be possible to write it in pure way (as far as you don't
concern efficiency. sometimes imperative algorithms mauy be just
faster than pure ones since data structures are different)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] Re: Automatic parallelism in Haskell, similar to make -j4?

2008-11-04 Thread Bulat Ziganshin
Hello Chad,

Wednesday, November 5, 2008, 6:34:01 AM, you wrote:

 ghc --make -j4 Foo.hs

afair, it was implemented and not shown speed improvements. ask Simon

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: [Haskell-cafe] view patterns

2008-11-04 Thread Bulat Ziganshin
Hello Cetin,

Wednesday, November 5, 2008, 8:34:14 AM, you wrote:

  let emp (has - True) = False; emp (has - False) = True

      Warning: Pattern match(es) are overlapped

proibably it's because GHC can't check view patterns for overlaps?

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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