Re: Bug in users manual, 6.4.2, section on pattern guards

2006-07-21 Thread Simon Marlow

Matthew Cox wrote:

One example given in this discussion is:

clunky env var1 var1 = case lookup env var1 of
  Nothing - fail
  Just val1 - case lookup env var2 of
Nothing - fail
Just val2 - val1 + val2
where
  fail = val1 + val2

this needs to be fixed to:

clunky env var1 var1 = case lookup env var1 of
  Nothing - fail
  Just val1 - case lookup env var2 of
Nothing - fail
Just val2 - val1 + val2
where
  fail = var1 + var2(Added for emphasis)

I didn't see it myself on the first readthrough, but I was comparing structure 
between two examples
and noticed the discrepency. Let's fix it for correctness' sake.


fixed; thanks.

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


Re: Bug in GHC 6.4.1 and 6.4.2

2006-07-21 Thread Simon Marlow

Fritz Henglein wrote:

According to a message from GHCi, version 6.4.1 (see below; bug also
reproduceable with 6.4.2, though not shown here since it consistently
resulted in a core dump without prior message) under Windows XP (fully
updated per 2006-07-15), I am herewith reporting what appears to be a
bug in GHC.  Please see transcript below; the source file in question
is included as an attachment.  (Lacking both efficient Haskell
programming skills and an understanding of the internals of GHC I have
refrained from attempting to isolate the bug by reducing the code.)
Should there be a simple work-around or something unsafe in my code
(though I wouldn't know what: no unsafe operations are used; no
polymorphism is present), I would greatly appreciate hearing about it.


Thanks, good bug.  The problem was:

 index (minBound::Int16,maxBound) maxBound
-1

ie. index for Int16 should have converted to Int *before* doing the subtraction.

This is related to another problem (that I think we have a ticket for), namely 
that the type of index precludes having really large arrays:


  index :: Ix i = (i,i) - i - Int

if the index must fit in an Int, then GHC can't cope with arrays with more than 
2^31 elements (on a 32-bit machine), and in general Haskell doesn't allow arrays 
with more than 2^29 elements.


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


Lookup module and package defining x?

2006-07-21 Thread Marc Weber
Has somene already implemented something like:

$ghc-pkg --where-from ParseError
package parsec: defining modules: Text.ParserCombinators.Parsec.Error, 
Text.ParserCombinators.Parsec

?

lambdabot @index does what I want, but not with my libs installed only
locally..

This might be used by any developement system for easily importing
modules..

If not I'll start working on this and I'll post again after
   needing help ;)
or finishing

It can't be that hard because there is already
ghc-pkg list and ghc --show-iface ...

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


Re: Lookup module and package defining x?

2006-07-21 Thread Duncan Coutts
On Fri, 2006-07-21 at 10:12 +0200, Marc Weber wrote:
 Has somene already implemented something like:
 
 $ghc-pkg --where-from ParseError
 package parsec: defining modules: Text.ParserCombinators.Parsec.Error, 
 Text.ParserCombinators.Parsec

Have you tried Hoogle?

http://haskell.org/hoogle/


Your example gives me one result which includes the module name:
http://haskell.org/hoogle/?q=ParseError

Duncan

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


Re: Heap Profiling Question

2006-07-21 Thread Simon Marlow

Rich Fought wrote:
I'm trying to use heap profiling with +RTS -hc -i1 options and running 
my program for about 30 seconds.  However, I only get around 7 samples 
with seemingly bogus timetags (i.e. 0.00, 3.69, 3.73, 3.10, 4.05, 
4.12).  What's going on?


I'm running GHC 6.4.2 on Windows (MSYS/MinGW).


IIRC the timestamps ignore time spent in GC and time spent sampling the heap, so 
they measure runtime of the program only.


Still, it does look a little strange.  Maybe you could send us the output of 
+RTS -S?


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


Re: Lookup module and package defining x?

2006-07-21 Thread Marc Weber
  $ghc-pkg --where-from ParseError
  package parsec: defining modules: Text.ParserCombinators.Parsec.Error, 
  Text.ParserCombinators.Parsec
 
 Have you tried Hoogle?
 http://haskell.org/hoogle/
I know it. But I don't know yet which source it takes (haskell - source,
haddck html files, ...) ?

My purpose: After having found the a function I want to use it without
having to search where does it belong to and where does it come from.
I want it beeing as up to date as the installed libraries. That's why I
thought it might be best to integrate it into ghc?
 
I don't know wether you've ever prorgammed in Java using Eclipse?
After using a type you can press C-S-o to update all imports which will
give you the choice which one to use if there is more than one
opportunity. It would be nice to have this in haskell, too.

Do you think it would be better to integrate it in another tool such
like lambdabot or hoogle?

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


Re: Lookup module and package defining x?

2006-07-21 Thread Malcolm Wallace
Marc Weber [EMAIL PROTECTED] wrote:

 My purpose: After having found the a function I want to use it without
 having to search where does it belong to and where does it come from.
 I want it beeing as up to date as the installed libraries.

You can download Hoogle as a command-line tool, and give it your
complete installed libraries to index.  Then it will be accurate for
your own setup.  Of course, you would need to manually update it every
time you install a new library.

 That's why I thought it might be best to integrate it into ghc?

This kind of tool, though useful, has almost nothing in common with the
compiler.  Although I suppose it would be useful if Hoogle could read
the ghc-pkg file format when indexing all locally-available modules.

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


Re: Lookup module and package defining x?

2006-07-21 Thread Neil Mitchell

Hi,


My purpose: After having found the a function I want to use it without
having to search where does it belong to and where does it come from.

I'm not sure what you are asking for? Where does it come from? Surely
thats just the module name - which hoogle easily gives you. If there
is some information that hoogle doesn't provide about the location
of a module, I'll be happy to add it.


I want it beeing as up to date as the installed libraries. That's why I
thought it might be best to integrate it into ghc?

I want hoogle to always be as up to date as the latest stable GHC,
since that should be the one for most people. I am also working on
adding libraries, Gtk is already searchable, more will be with hoogle
4. This should cover all the libraries you have installed.

Of course, they won't match your versions, they'll be the most up to
date ones. If this is a problem feel free to install Hoogle locally,
generate hoogle databases using haddock with the -hoogle flag. With a
bit of shell script magic you should have everything you need to make
something that does what you want. And of course, once you have,
please release it back to the world :)


Do you think it would be better to integrate it in another tool such
like lambdabot or hoogle?

If you integrate something with hoogle, then you get it from lambdabot
for free, with @hoogle.

Thanks

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


Re: Heap Profiling Question

2006-07-21 Thread Rich Fought

Simon Marlow wrote:


IIRC the timestamps ignore time spent in GC and time spent sampling 
the heap, so they measure runtime of the program only.
So if I have a server that is idle most of the time waiting for 
requests, the timestamps recorded in the heap profile will not be real 
time but program execution time?
Still, it does look a little strange.  Maybe you could send us the 
output of +RTS -S?

   AllocCollectLiveGCGC TOT TOT  Page Flts
   bytes bytes bytes  user  elapuserelap
  264424262144 20592  0.00  0.000.030.0100  
(Gen:  1)
  311540270336 63732  0.00  0.003.845.2500  
(Gen:  0)
  270304290816102352  0.00  0.003.855.2600  
(Gen:  0)
  273472270336133644  0.00  0.003.855.2600  
(Gen:  0)
  314540294912167000  0.00  0.003.905.3100  
(Gen:  0)
  266356294912212212  0.00  0.003.905.3100  
(Gen:  0)
  262128331776214120  0.00  0.003.925.3300  
(Gen:  0)
  262128270336216456  0.00  0.003.925.3300  
(Gen:  0)
  262128266240218800  0.00  0.003.925.3300  
(Gen:  0)
  262128266240221140  0.00  0.003.925.3300  
(Gen:  0)
  262128266240225844  0.00  0.003.925.3300  
(Gen:  0)
  262128266240231052  0.00  0.003.925.3300  
(Gen:  0)
  262128266240236516  0.00  0.003.925.3300  
(Gen:  0)
  262128266240242344  0.00  0.003.925.3400  
(Gen:  0)
  262144266240248576  0.00  0.003.925.3400  
(Gen:  0)
  262128266240255212  0.00  0.003.925.3400  
(Gen:  0)
  262128266240262328  0.00  0.003.925.3400  
(Gen:  0)
  262128266240270016  0.00  0.003.925.3400  
(Gen:  0)
  262128266240278620  0.00  0.003.925.3400  
(Gen:  0)
  262128266240288648  0.01  0.013.945.3500  
(Gen:  0)
  262128266240300372  0.00  0.003.945.3500  
(Gen:  0)
  262128266240317000  0.00  0.003.945.3500  
(Gen:  0)
  262128266240346080  0.00  0.003.945.3500  
(Gen:  0)
  262128270336348424  0.00  0.003.945.3500  
(Gen:  0)
  262128266240350760  0.00  0.003.945.3500  
(Gen:  0)
  262128266240353364  0.00  0.003.945.3600  
(Gen:  0)
  262128266240358512  0.00  0.003.945.3600  
(Gen:  0)
  262128266240363748  0.00  0.003.945.3600  
(Gen:  0)
  262128266240369324  0.00  0.003.945.3600  
(Gen:  0)
  262128266240375232  0.00  0.003.945.3600  
(Gen:  0)
  262128266240381528  0.00  0.003.945.3600  
(Gen:  0)
  262128266240388320  0.00  0.003.945.3600  
(Gen:  0)
  262128266240395496  0.00  0.003.945.3600  
(Gen:  0)
  262128266240403424  0.00  0.003.945.3600  
(Gen:  0)
  262128266240412268  0.00  0.003.945.3600  
(Gen:  0)
  262128266240422584  0.00  0.003.945.3600  
(Gen:  0)
  262128266240435088  0.00  0.003.965.3700  
(Gen:  0)
  262128266240454476  0.00  0.003.965.3700  
(Gen:  0)
  262224266240477316  0.00  0.003.965.3700  
(Gen:  0)
  262128270336479676  0.00  0.003.965.3700  
(Gen:  0)
  262128266240482012  0.00  0.003.965.3800  
(Gen:  0)
  262128266240485236  0.00  0.003.965.3800  
(Gen:  0)
  262128266240490364  0.00  0.003.965.3800  
(Gen:  0)
  262124266240495700  0.00  0.003.965.3800  
(Gen:  0)
  262128266240501292  0.00  0.003.965.3800  
(Gen:  0)
  262128266240507344  0.00  0.003.965.3800  
(Gen:  0)
  262128266240513676  0.00  0.003.965.3800  
(Gen:  0)
  262128266240520632  0.00  0.003.965.3800  
(Gen:  0)
  262128266240527924  0.00  0.003.965.3800  
(Gen:  0)
  262128266240536016  0.00  0.003.965.3800  
(Gen:  0)
  262128266240545180  0.00  0.003.965.3800  
(Gen:  0)
  262128266240555808  0.01  0.013.985.3900  
(Gen:  0)
  262128266240569148  0.00  0.003.985.3900  
(Gen:  0)
  262128266240593492  0.00  0.003.985.3900  
(Gen:  0)
  262152266240683760  0.00  0.003.985.3900  
(Gen:  0)
  262128266240779176  0.00  0.003.985.3900  
(Gen:  0)
  262128266240874588  0.00  0.00

Re[2]: Lookup module and package defining x?

2006-07-21 Thread Bulat Ziganshin
Hello Marc,

Friday, July 21, 2006, 3:21:29 PM, you wrote:

 I don't know wether you've ever prorgammed in Java using Eclipse?
 After using a type you can press C-S-o to update all imports which will
 give you the choice which one to use if there is more than one
 opportunity. It would be nice to have this in haskell, too.

there is EclipseFP plugin which supports some of Eclipse features for
haskell users

 Do you think it would be better to integrate it in another tool such
 like lambdabot or hoogle?

it will be great if Cabal after library installation runs local hoogle
to update its information


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

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


Re: Heap Profiling Question

2006-07-21 Thread Rich Fought
On a separate issue, I can't seem to get the -hcname or -hmname options 
to work.  For instance, profiling with just -hm yields an entry for 
module Network.HTTP, yet when I try to profile again with 
-hmNetwork.HTTP, I do not get a heap dump.  Is there some special 
formatting I am missing?


Thanks,
Rich

Rich Fought wrote:
I'm trying to use heap profiling with +RTS -hc -i1 options and running 
my program for about 30 seconds.  However, I only get around 7 samples 
with seemingly bogus timetags (i.e. 0.00, 3.69, 3.73, 3.10, 4.05, 
4.12).  What's going on?


I'm running GHC 6.4.2 on Windows (MSYS/MinGW).

Thanks,
Rich

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





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


regex.h included with GHC 6.4.2

2006-07-21 Thread Rich Fought

Am I crazy or is there an error in regex.h included with GHC?

On line 110 there appears to be an extraneous or unterminated 'extern C {'

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


[Haskell] ANN: monadic probabilistic functional programing

2006-07-21 Thread Stefan Karrmann
Dear all,

the library PFP by Martin Erwig is quite useful for probabilistic
calculations. I have extended it to abstract monads, cabal and darcs,
confer [1].

I cannot find a licence or legal note on the page of Martin Erwig.
Therefore, I can legally only publish a patch. Unfortunatly, darcs does
not provide a method to extract patches as far as I know. (Hints are
welcomed.) As a result you can download a stripped down version of my darcs
repository from [1]. How to create the complete repository is there
described, too.

[1] http://home.arcor.de/s.ka/haskell/pfp.html

Kind regards,
-- 
Stefan Karrmann
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] PLAN-X 2007: Call for Papers and Demos

2006-07-21 Thread Torsten Grust


  [ Dear all, I'd love to see contributions from the Haskell and FP
community to this upcoming edition of PLAN-X!  Best wishes, -- 
Torsten ]




 Call for Papers and Software Demonstrations

 P L A N - X   2 0 0 7
   Programming Language Techniques for XML
   An ACM SIGPLAN Workshop colocated with POPL 2007

   Nice, France -- January 20, 2007

 http://www.plan-x-2007.org/


-- PLAN-X 2007 Aim and Scope

  The XML data model and its associated languages add interesting  
twists

  to programming language practice as well as theory.  Just like its
  four predecessors, the PLAN-X 2007 workshop turns the spotlight on  
how

  programming languages can embrace, for example, tree-shaped XML data
  structures, regular expression types extracted from schema
  descriptions, very small or large XML instances, queries against XML
  data, and XML transformations.  XML reaches deep into all aspects of
  language design, type systems, compilers, as well as runtimes and
  PLAN-X 2007 is THE forum to present and discuss novel research  
work in

  this area.

  We invite contributions -- papers as well as software demonstrations
  -- from members of the programming language, database, theory, and
  document processing communities and look forward to a workshop in
  which this diversity of contributions and attendees leads to lively
  discussion and a fun event.

  If you are architecting a software system that fuses programming
  language and XML technology in interesting and innovative ways,  
please
  submit a software demonstration proposal to PLAN-X 2007.  The  
workshop
  program will feature a special demo session.  A two-page  
description of

  the accepted software demonstrations will be included in the
  proceedings.

  PLAN-X 2007 will be held in cooperation with and just after POPL  
2007,

  the 34th ACM SIGPLAN-SIGACT Symposium on Principles of Programming
  Languages in the Plaza Hotel in Nice, France, on Januar 20, 2007.


-- PLAN-X 2007 Topics of Interest

  Topics of interest include the following (though interesting
  and/or innovative papers on all aspects of programming languages for
  XML are welcome):

  - Design of programming and query languages for XML
  - Programming in the XML data model itself (e.g., extending XQuery
into a full-fledged programming language)
  - Formal accounts of XML and its processors (based on logic,  
automata,

variants of lambda calculus, etc.)
  - Compilers and interpreters for XML-aware languages and optimization
techniques
  - Type systems, schema languages, and other constraints (e.g., keys)
for tree-shaped data
  - Tree automata and transducers
  - Languages and systems that can cope with XML fragments  
(messages) or

very large XML instances (beyond main-memory size)
  - Programming language glue between browsers, web services, and
databases
  - Pioneering applications of XML-aware language technology


-- Proceedings

  Accepted submissions will be collected to form the informal PLAN-X
  2007 proceedings, to be indexed on Michael Ley's DBLP site and
  distributed at the workshop.  The material may thus be published
  elsewhere at a later date.


-- Paper Submission

  PLAN-X 2007 calls for contributions relevant to the open list of
  topics sketched above.  We explicitly welcome reports on innovative,
  off-beat, and ''early stage'' approaches as long as the submission
  reports on original work not published or submitted elsewhere.

  - Please format your papers according to the ACM guidelines and SIG
proceedings templates available at

http://www.acm.org/sigs/pubs/proceed/template.html

The mandatory submission file format is PDF.

  - Papers should not exceed 10 pages in length including references  
and

appendices, but shorter abstracts (of, e.g., 2000 words) often
suffice and are acceptable as well.

  - Software demonstration proposals are limited to 2 pages and should
include a sketch of the methods you employ as well as a description
of what exactly will be demoed.

  Details on the PLAN-X 2007 paper submission process will be posted
  on the workshop web site and mailing lists in due course.


-- Important Dates

  - Paper submission:   Sun, Oct 1, 2006
  - Notification of acceptance: Thu, Nov 23, 2006
  - Camera-ready copy due:  Sun, Dec 17, 2006
  - Workshop:   Sat, Jan 20, 2007


-- PLAN-X 2007 Program Committee

  - Michael Benedikt(Lucent, USA)
  - Daniela Florescu(Oracle, USA)
  - Alain Frisch(INRIA Roquencourt, France)
  - Giorgio Ghelli, Chair   (U Pisa, Italy)
  - Haruo Hosoya(U Tokyo, Japan)
  - Anders Møller   (U Aarhus, Denmark)
  - Mukund Raghavachari (IBM T.J. Watson Research Center, USA)
  - Alan Schmitt(INRIA Rhône-Alpes, France)
  - 

Re: [Haskell] ANN: monadic probabilistic functional programing

2006-07-21 Thread Taral

On 7/19/06, Stefan Karrmann [EMAIL PROTECTED] wrote:

Unfortunatly, darcs does
not provide a method to extract patches as far as I know. (Hints are
welcomed.)


darcs diff and darcs annotate.

--
Taral [EMAIL PROTECTED]
You can't prove anything.
   -- Gödel's Incompetence Theorem
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] using the ffi with callbacks

2006-07-21 Thread Taral

On 7/20/06, Evan Martin [EMAIL PROTECTED] wrote:

But I also don't quite understand how the typing works out.
For example, can you use StablePtr directly with FFI functions, or do
they require you casting through Ptr?


Yes. You can use any Storable with FFI functions, as far as I know.
StablePtr is explicitly designed for this purpose, allowing you to
export an object to the FFI while keeping the GC apprised of its use
by external code.


/* C code, as before but with a typedef for clarity */
typedef void (*Callback)(void*);
void register_callback(
   Callback callback_fcn,
   void *callback_data,
   Callback free_fcn);

-- importing this function.
-- you had:
type Callback = StablePtr (Callback, DataStructure)- IO ()

foreign import ccall register_callback ::
  FunPtr Callback -   -- because mkCallback gives a FunPtr
  Ptr (Callback, DataStructure) -  -- or StablePtr?
  Callback -  -- but here don't we again need a FunPtr?
  IO ()


Oh, right. Try:

type CallbackData = StablePtr (CallbackData, DataStructure)
type Callback = CallbackData - IO ()

foreign import ccall register_callback :: FunPtr Callback -
CallbackData - FunPtr Callback - IO ()

You get that FunPtr by the import/export trick described by Anatoly or
you can just construct the FunPtr in main or an unsafePerformIO CAF.
(We need a constructor syntax for top-level objects requiring IO!)

--
Taral [EMAIL PROTECTED]
You can't prove anything.
   -- Gödel's Incompetence Theorem
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Package mounting proposal

2006-07-21 Thread Stefan Karrmann
My 2 cents:

Sven Moritz Hallberg (Sun, Jul 16, 2006 at 01:24:43AM +0200):
 [...]
 She must specify it somehow. Two possibilities come to mind:
 
   1. Add a field to the package description of foo (v1.4, say) that says
  I'm backwards-compatible with 1.3. When building, this relation
  would have to be inspected to see whether any currently installed
  version of foo satisfies the dependency specified by the mount.
   2. Declare a convention for version numbers to carry compatibility
  information, like the OpenGL standard, for example: If the new
  version is backwards-compatible, only the minor version number
  changes. If it isn't, the major version number must be incremented.
 

I prefer 1. The FSF use 2 for its GNU software and others started with it,
too. But after a while most of them tend to increase major numbers. E.g.
3.0, 3.11, 95, 98, 2000

Regards,
-- 
Stefan Karrmann

If A equals success, then the formula is _A = _X + _Y + _Z.  _X is work.  
_Y
is play.  _Z is keep your mouth shut.
-- Albert Einstein
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] ANN: monadic probabilistic functional programing

2006-07-21 Thread Stefan Karrmann
Dear all,

I have renamed all files. Because of this the darcs diff contains *all*
source lines. Then it is not only a patch but also the complete original
work. Moreover, the patch does not contain a move from or unlink of the old
locations.

Taral (Fri, Jul 21, 2006 at 11:22:22AM -0500):
 On 7/19/06, Stefan Karrmann [EMAIL PROTECTED] wrote:
 Unfortunatly, darcs does
 not provide a method to extract patches as far as I know. (Hints are
 welcomed.)
 
 darcs diff and darcs annotate.

Regards,
-- 
Stefan Karrmann
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] ANN: monadic probabilistic functional programing

2006-07-21 Thread Tomasz Zielonka
On Fri, Jul 21, 2006 at 10:26:04PM +0200, Stefan Karrmann wrote:
 I have renamed all files. Because of this the darcs diff contains *all*
 source lines. Then it is not only a patch but also the complete original
 work. Moreover, the patch does not contain a move from or unlink of the old
 locations.

If the original code was already in a darcs repository, you can create
a darcs patch bundle by 'darcs send'ing against a repository, which
contains only the original patches. You do it like this:

$ cd repository-with-your-extensions
$ darcs send -o my.patchse original-repository

Now if someone has an original repository, he/she can apply your patches
in this repository. The patch bundle can still contain parts of the
original work as parts of primitive patches.

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


Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-21 Thread Jon Fairbairn
On 2006-07-20 at 18:31BST I wrote:
 On 2006-07-13 at 10:16BST I wrote:
  Hooray!  I've been waiting to ask Why aren't we asking what
  laws hold for these operations?
 
 Having thought about this for a bit, I've come up with the
 below. This is intended to give the general idea -- it's not
 polished code,

And already some changes (but all to comments) I'd
appreciate comments on the law below.

--- lib/split.lhs   2006/07/21 08:54:28 1.1
+++ lib/split.lhs   2006/07/21 09:42:49
@@ -17,10 +17,17 @@

   = A Random List Of Words\nOn Lines

+  I think the relevant law is
+  (forall x. all (not . p) (map f x)) =
+  segmentsSatisfying (not . p) . fromParts . mapRight f . parts p
+  == segmentsSatisfying (not . p)
+
+  In other words, if f doesn't add any not . p elements,
+  the segments satisfying not . p are unchanged.

  contiguousParts p l = [a | Right a - parts p l]

-  so words = contiguousParts Char.isAlphaNum
+  so words = contiguousParts (not . Char.isSpace)

  segmentsSatisfying predicate
  = concat . map dropSeps . parts predicate

-- 
Jón Fairbairn  Jon.Fairbairn at cl.cam.ac.uk


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


RE: Re[4]: [Haskell-cafe] REALLY simple STRef examples

2006-07-21 Thread Simon Peyton-Jones

|  | ps: you successfully going through all the standard Haskell
troubles
|  in
|  | this area :)  seems that making FAQ about using ST monad will be a
|  | good idea :)
| 
|  Indeed. If someone would like to start one, a good place for it
would be
|  GHC's collaborative-documentation Wiki
| 
http://haskell.org/haskellwiki/GHC#Collaborative_documentation
| 
| they are not ghc-specific, afaik

Some aspects are -- e.g. the behaviour of higher-rank types.   But by
all means attach it somewhere else

S


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


[Haskell-cafe] seq - RTFM?

2006-07-21 Thread Dusan Kolar

Hello all,

 my question is probably dull. So answers to better investigate manual 
are welcome. Why is this correct?


  ___ ___ _
 / _ \ /\  /\/ __(_)
/ /_\// /_/ / /  | |  GHC Interactive, version 6.4.1, for Haskell 98.
/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/
\/\/ /_/\/|_|  Type :? for help.

Loading package base-1.0 ... linking ... done.
Prelude putStr Ahoj\n
Ahoj
Prelude putStr Ahoj\n `seq` 3+3
6
Prelude :q
Leaving GHCi.

And not

Prelude putStr Ahoj\n
Ahoj
Prelude putStr Ahoj\n `seq` 3+3
Ahoj
6

???

Does it have something common with monads or is it a behavior of seq?

Thanks,

 Dusan


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


Re: [Haskell-cafe] seq - RTFM?

2006-07-21 Thread Piotr Kalinowski

On 21/07/06, Dusan Kolar [EMAIL PROTECTED] wrote:

Prelude putStr Ahoj\n
Ahoj
Prelude putStr Ahoj\n `seq` 3+3
6
Prelude :q
Leaving GHCi.

And not

Prelude putStr Ahoj\n
Ahoj
Prelude putStr Ahoj\n `seq` 3+3
Ahoj
6


Well, I understand that seq evaluates the first argument. But the
result of evaluating putStr is a monadic action. Not execution of that
action.

Regards,
Piotr Kalinowski


--
Intelligence is like a river: the deeper it is, the less noise it makes
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] seq - RTFM?

2006-07-21 Thread Christophe Poucet
Hello Dusan,

The reason why that does not work as you expect it to is because the
type of the whole expression is not monadic.  Therefore it will
basically evaluate the action until it's an action ready to be executed,
but not execute it, cause it's not in the IO monad.  It's the same as
having a list of [putStr a, putStr b].  Until you start placing
these actions in the IO monad, they'll just be values.

Hope that's somewhat clear

Dusan Kolar wrote:
 Hello all,
 
  my question is probably dull. So answers to better investigate manual
 are welcome. Why is this correct?
 
   ___ ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |  GHC Interactive, version 6.4.1, for Haskell 98.
 / /_\\/ __  / /___| |  http://www.haskell.org/ghc/
 \/\/ /_/\/|_|  Type :? for help.
 
 Loading package base-1.0 ... linking ... done.
 Prelude putStr Ahoj\n
 Ahoj
 Prelude putStr Ahoj\n `seq` 3+3
 6
 Prelude :q
 Leaving GHCi.
 
 And not
 
 Prelude putStr Ahoj\n
 Ahoj
 Prelude putStr Ahoj\n `seq` 3+3
 Ahoj
 6
 
 ???
 
 Does it have something common with monads or is it a behavior of seq?
 
 Thanks,
 
  Dusan
 
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 


-- 
Christophe Poucet
Ph.D. Student
DESICS - DDT

Phone:+32 16 28 87 20
E-mail: Christophe (dot) Poucet (at) imec (dot) be
IMEC vzw -- Register of Legal Entities Leuven VAT BE 0425.260.668 --
Kapeldreef 75, B-3001 Leuven, Belgium -- http://www.imec.be

IMEC e-mail disclaimer: http://www.imec.be/wwwinter/email-disclaimer.shtml
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Still not dead

2006-07-21 Thread Einar Karttunen
Hello

As many of you may have noticed I have been away for some months.
This has been due to health problems which have unfortunately
kept me unable to work on Haskell projects.

I am not dead and will be working on resolving the backlog
of messages (will probably take a week). I will be slowly
back to hacking things when I get everything fixed.

- Einar Karttunen

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


[Haskell-cafe] HXT - problems with runIOSLA or xread

2006-07-21 Thread Niklas

Hi everybody,

and especially Uwe Schmidt et al.

I ran into some problems trying to process some xml from a string source,
illustrated in the code below. From file, using readDocument, everything works
great though. I've probably missed a finer detail or two in the arrow handling,
or it could be a bug in HXT (if I run the code in ghci, it will crash hard).

Output:
--main.exe
NTree (XTag (QN {namePrefix = , localPart = small, namespaceUri = }) []) [
NTree (XTag (QN {namePrefix = , localPart = xml, namespaceUri = }) []) [],
NTree (XTag (QN {namePrefix = , localPart = example, namespaceUri = }) [])
 []]
--

So it seems that the string gets read, since it shows up as a result from
procString, but I get no output from writeDocument in writeStrDoc. Could anybody
enlighten me?

I'm using GHC 6.5 and HXT 6.0 on Windows XP.

Regards,

/Niklas

---8---

module Main where

import Text.XML.HXT.Arrow

wa = [(a_indent, 1), (a_remove_whitespace, 1)]

main = procString tststr = mapM_ print . snd

procString = runIOSLA writeStrDoc (initialState ())

writeStrDoc = xread  writeDocument wa -

tststr = smallxml/example//small

---8---


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


Re: Re[4]: [Haskell-cafe] REALLY simple STRef examples

2006-07-21 Thread Chad Scherrer

The IO monad hasn't given me too much trouble, but I want to be sure
to structure things the way they should be. If I get everything
running using IO first and then have type-checking problems with ST,
it will be tempting to just slap on an unsafePerformIO and call it
good. Sure, it's really doing the same thing anyway, but it just comes
out looking like a hack.

On 7/20/06, Bulat Ziganshin [EMAIL PROTECTED] wrote:

Hello Chad,

Friday, July 21, 2006, 12:26:58 AM, you wrote:

 Ok, I see now why the return is necessary.

btw, it may be helpful to read IO inside material. ST monad is not
very different from IO monad - it only limited to operations on STRef
and STArray, so that it can't have side-effects visible outside of
runST statement used to run ST computation


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


[Haskell-cafe] Re: ANN: System.FilePath 0.9

2006-07-21 Thread Simon Marlow

Neil Mitchell wrote:


I have also added a canonicalPath function, support for spotting
file\con as invalid and fixing it, support for \\?\ paths (if you
don't know what they are, don't look it up, they are quite painful!)
and a few very obscure corner cases which broke some of the
properties.


I haven't been following this discussion very closely, but this caught my eye. 
Has anyone pointed out yet that eliminating .. in a FilePath isn't valid in 
the presence of symbolic links?  I vaguely recall that this is why Krasimir's 
System.FilePath library doesn't include normalisation.  Normalisation that just 
changes separators, removes redundant separators and removes . components is 
probably ok.


I don't really see the point of fullPathWith.  Isn't it just combine?

I think shortPath is on dodgy ground, given the difficulty with normalising 
FilePaths, and the fact that paths are not unique in the presence of symlinks.


The temporary file stuff is wrong - see System.IO.openTemporaryFile.  The only 
way to reliably create a temporary file is to open it at the same time, 
otherwise there's a race condition.


I have some other issues with naming, and the fact that the library mixes IO and 
non-IO functions.  We should avoid referring to $PATH as the path, since we 
already have FilePath.  eg. spiltPath and getPath are talking about two very 
different things.  Where you use the term Filename, I think it should probably 
be FilePath.  I think we should consistently use a single term, preferably FilePath.


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


[Haskell-cafe] Re: ANN: System.FilePath 0.9

2006-07-21 Thread Neil Mitchell

Hi,


I haven't been following this discussion very closely, but this caught my eye.
Has anyone pointed out yet that eliminating .. in a FilePath isn't valid in
the presence of symbolic links?  I vaguely recall that this is why Krasimir's
System.FilePath library doesn't include normalisation.  Normalisation that just
changes separators, removes redundant separators and removes . components is
probably ok.

Ok, I'll remove this behaviour


I don't really see the point of fullPathWith.  Isn't it just combine?

It also applies normalise to the result, although I'm not sure thats a
particularly useful thing to do. I'll think about this.


I think shortPath is on dodgy ground, given the difficulty with normalising
FilePaths, and the fact that paths are not unique in the presence of symlinks.

I think this is still a useful thing, but I'll think harder about it
in relation to symlinks, and figure out what properties it should
have.


The temporary file stuff is wrong - see System.IO.openTemporaryFile.  The only
way to reliably create a temporary file is to open it at the same time,
otherwise there's a race condition.

Looking at it again, I'm not sure that the temporary operations belong
in this module. Ditto for the directory operations. It would be handy
if the directory operations (particularly ensureDirectory) were
somewhere else in the standard libraries though.


I have some other issues with naming, and the fact that the library mixes IO and
non-IO functions.

I think this is unavoidable, I tried to make as many functions as
possible pure, but where the filesystem must be consulted they have to
be IO based. For example canonicalPath probably belongs in this
module, but has to be IO based.


 We should avoid referring to $PATH as the path, since we
already have FilePath.

Agreed, but I couldn't come up with a better name, if anyone has any
suggestions.


Where you use the term Filename, I think it should probably
be FilePath. I think we should consistently use a single term, preferably 
FilePath.

I have tried to consistently use FilePath as a path to a file, and
filename as the actual name once you get there. For example:

/usr/bin/ghc

Has a FilePath of /usr/bin/ghc and a FileName of ghc. That
distinction seems more logical to me, but if everyone thinks otherwise
I'm happy to change it.

Thanks

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


Re: [Haskell-cafe] REALLY simple STRef examples

2006-07-21 Thread S C Kuo
Not totally relevant to what the discussion has evolved to, but I wrote 
a factorial function using STRefs (in the spirit of the Evolution of a 
Haskell programmer) and I think it qualifies as a really simple example. 
Code follows:


import Data.STRef
import Control.Monad.ST

foreach :: (Monad m) = [a] - (a - m b) - m ()
foreach = flip mapM_
-- Bryn Keller's foreach, but with type restrictions

fac :: (Num a, Enum a) = a - a
fac n   = runST (fac' n)

fac':: (Num a, Enum a) = a - ST s a
fac' n  = dor - newSTRef 1
foreach [1..n] (\x - modifySTRef r (*x))
x - readSTRef r
return x

Chad Scherrer wrote:

The IO monad hasn't given me too much trouble, but I want to be sure
to structure things the way they should be. If I get everything
running using IO first and then have type-checking problems with ST,
it will be tempting to just slap on an unsafePerformIO and call it
good. Sure, it's really doing the same thing anyway, but it just comes
out looking like a hack.

On 7/20/06, Bulat Ziganshin [EMAIL PROTECTED] wrote:

Hello Chad,

Friday, July 21, 2006, 12:26:58 AM, you wrote:

 Ok, I see now why the return is necessary.

btw, it may be helpful to read IO inside material. ST monad is not
very different from IO monad - it only limited to operations on STRef
and STArray, so that it can't have side-effects visible outside of
runST statement used to run ST computation


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


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


Re: [Haskell-cafe] Re: ANN: System.FilePath 0.9

2006-07-21 Thread David Menendez
Neil Mitchell writes:

   We should avoid referring to $PATH as the path, since we
  already have FilePath.
 Agreed, but I couldn't come up with a better name, if anyone has any
 suggestions.

searchPath?
-- 
David Menendez [EMAIL PROTECTED] http://www.eyrie.org/~zednenem/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] incoherent instance selection when it should be still coherent

2006-07-21 Thread Ralf Lammel
The following pain is sort of ghc (6.4.2) specific.
(The same behavior is achievable with hugs -98 +O which is Ok in so far
that +O (as opposed to +o) is not strongly supposed to be coherent.)

Note the following GHC options preceding the code.
They do not contain -fallow-incoherent-instances.

{-# OPTIONS -fglasgow-exts #-}

{-# OPTIONS -fallow-undecidable-instances #-}

{-# OPTIONS -fallow-overlapping-instances #-}


-- A single parameter class with two silly instances

class Foo x where foo :: x - (); foo = const ()

instance Foo ()

instance Foo Bool


-- A two-parameter class with a generic and a non-generic instance

class (Foo x, Foo y) = Bar x y where bar :: x - y - String

instance (Foo x, Foo y) = Bar x y where bar _ _ = generic instance

instance Foo z = Bar () z where bar _ _ = non-generic instance


-- An existential wrapper around foos

data Wrap = forall x. Foo x = Wrap x


-- A wrapper-based variation on the type-class member bar

uuh :: Wrap - Wrap - String

uuh (Wrap x) (Wrap y) = bar x y


-- Let's try all unwrapped and wrapped combinations of bar and uuh

t1 = ()

t2 = True

w1 = Wrap t1

w2 = Wrap t2

main = do 
  print $ bar t1 t1
  print $ uuh w1 w1 -- uuh!
  print $ bar t1 t2
  print $ uuh w1 w2 -- uuh!
  print $ bar t2 t1
  print $ uuh w2 w1
  print $ bar t2 t2
  print $ uuh w2 w2

We get:

{-

non-generic instance
generic instance
non-generic instance
generic instance
generic instance
generic instance
generic instance
generic instance

-}

This means that the generic instance is consistently chosen by uuh.
This is clearly incoherent.
I would also complain that uuh type-checks in the first place.
Opinions?

Regards,
Ralf

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


Re: [Haskell-cafe] REALLY simple STRef examples

2006-07-21 Thread Bryan Burgers

On 7/21/06, S C Kuo [EMAIL PROTECTED] wrote:

Not totally relevant to what the discussion has evolved to, but I wrote
a factorial function using STRefs (in the spirit of the Evolution of a
Haskell programmer) and I think it qualifies as a really simple example.
Code follows:

import Data.STRef
import Control.Monad.ST

foreach :: (Monad m) = [a] - (a - m b) - m ()
foreach = flip mapM_
-- Bryn Keller's foreach, but with type restrictions

fac :: (Num a, Enum a) = a - a
fac n   = runST (fac' n)

fac':: (Num a, Enum a) = a - ST s a
fac' n  = dor - newSTRef 1
foreach [1..n] (\x - modifySTRef r (*x))
x - readSTRef r
return x


Forgive me for not understanding, but I was hoping you would explain a
choice you made in your code. Why did you define foreach and then use


foreach [1..n] (\x - modifySTRef r (*x))


Instead of simply using


mapM_ (\x - modifySTRef r (*x)) [1..n]


? I tried it out in GHCi, and it worked fine, and I have seen code
that has been defined as a flip to take advantage of partial
application. But your code doesn't seem to take advantage of partial
application, so why did you define 'foreach' and then use it instead
of using 'mapM_'? I am just curious, and have always been interested
in reasons behind coding style.

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