Re: [Haskell-cafe] Cabal

2008-12-01 Thread Henning Thielemann


On Sun, 30 Nov 2008, Duncan Coutts wrote:


On Sun, 2008-11-30 at 21:14 +0100, Henning Thielemann wrote:

On Sun, 30 Nov 2008, Don Stewart wrote:


lemming:


Maybe you like to add a pointer in cabal-install.cabal/Homepage field to
this page.


Good idea. Duncan?


After I finished that article, I also found:
   http://hackage.haskell.org/trac/hackage/wiki/CabalInstall


I'm trying to work out what the best thing is to do with the Cabal
documentation. Currently it's kind of patchy and spread over about three
sites. There's the http://haskell.org/cabal website, the dev wiki and
trac and the pages on the main Haskell.org wiki.


... and it's divided into cabal and cabal-install documentation. Though, 
this separation might also be sensible.



I think ideally we'd have all the user documentation on the cabal
website, including the docs for cabal-install. Unless people think
that's a silly idea and we should just put everything on the haskellwiki
system.


For me, access to HaskellWiki is the easiest, because I have no access to 
haskell.org/cabal I think. :-) In general people might like to add 
personal comments about cabal, which is best done in the wiki. E.g. if you 
solve a problem you can quickly add that solution to the FAQ. I don't mind 
having an official static site like haskell.org/cabal which points to a 
dynamic haskellwiki/Cabal and vice versa, but I think another page at 
haskell.org/trac is redundant.

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


Re: [Haskell-cafe] Combining licences

2008-12-01 Thread Henning Thielemann


On Mon, 1 Dec 2008, Emil Axelsson wrote:

Or perhaps it's better to put the cell library in its own package? I'm a bit 
reluctant to do this, because it means that Wired will be essentially useless 
on its own.


It's more the question, whether a Haskell wrapper to the cell library is 
useful on its own. I assume yes, and thus it sounds like a good idea to 
make separate package for a cell library wrapper.

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


Re: [Haskell-cafe] Combining licences

2008-12-01 Thread Emil Axelsson

Henning Thielemann skrev:

On Mon, 1 Dec 2008, Emil Axelsson wrote:

Or perhaps it's better to put the cell library in its own package? I'm 
a bit reluctant to do this, because it means that Wired will be 
essentially useless on its own.


It's more the question, whether a Haskell wrapper to the cell library is 
useful on its own. I assume yes, and thus it sounds like a good idea to 
make separate package for a cell library wrapper.


Well, not really. It's not a Haskell wrapper in the normal sense where you 
make a Haskell API around some code in another language. A cell library is a 
bunch of cell models in various formats. For example, a VHDL file gives the 
logical models, and another file contains tables with timing data. Wired has its 
own way of modeling cells (a number of classes), and what I've done is to 
translate the cell library data to Wired's model. So if I make it a separate 
package, it would have to depend on Wired.


Of course, it still makes sense to have cell libraries as separate packages (I 
don't want to include every future cell lib in Wired). But I would like at least 
one cell lib to be shipped together with Wired.


/ Emil

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


Re: [Haskell-cafe] ANN: Real World Haskell, now shipping

2008-12-01 Thread Jules Bean

Andrew Coppin wrote:
What I *haven't* done yet is read the chapters where they try to claim 
that database programming is possible in Haskell. I'll have to do that 
at some point. Maybe this is where they reveal the Secret Formula that 
makes this stuff actually work properly... but somehow I doubt it.


What a ridiculous comment.

Are you hoping to provoke people into helping you by sounding more 
stupid than you are?


Database programming is obviously possible in haskell. Many many people 
are doing it.


The documentation may be patchy, the libraries may be hard to install 
(often the case with free software for databases, for some reason)

but that's quite a long way from impossible.

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


[Haskell-cafe] Re: Binary Trees missing on hackage

2008-12-01 Thread Andrew Wagner
The reasons I've always heard for this is that 1.) It's so easy to define a
tree and 2.) There are tons of different variations of trees and what you
can do with them. Not that I 100% agree, just what I've always heard.

On Mon, Dec 1, 2008 at 6:09 AM, Christian Maeder
[EMAIL PROTECTED]wrote:

 Hi,

 I was surprised that I could not find a classical binary tree data
 structure on hackage, mainly for teaching purposes, like:

  data BinTree a = Nil | Node (BinTree a) a (BinTree a)

 with a couple of utility functions and instances (i.e. in-order traversal).

 Surely, one may argue, that such a tree can always be defined on the fly
 when needed, but nobody would argue so for lists or tuples. (Although
 I've rarely seen someone redefining lists, it is quite common to
 introduce user-defined products or enumerations.)

 There are rose trees in Data.Tree and many other variants of trees are
 conceivable, ie.

  data Boom a = Leaf a | Node (Boom a) (Boom a)

 or a kind of combination:

  data BinLeafTree a b =
 Leaf b
   | Node (BinLeafTree a b) a (BinLeafTree a b)

 I don't know, why I find the above BinTree most important. I'm not even
 sure if such a tree could be re-used for Search- or AVL-trees that need
 strict fields with redundant size or height counters for efficiency
 reasons.

 In any case I would find such a data type at least as useful as
 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OneTuple

 Who would supply and maintain such a package? Or did I simply not search
 hard enough?

 Cheers Christian

 P.S. I took the (non-empty) Boom from the Boom-Hierarchy described in
 An Exploration of the Bird-Meertens Formalism by Roland Backhouse
 1988, Groningen

 ___
 Libraries mailing list
 [EMAIL PROTECTED]
 http://www.haskell.org/mailman/listinfo/libraries

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


Re: [Haskell-cafe] Haskell, successing crossplatform API standart

2008-12-01 Thread Bjorn Bringert
On Sun, Nov 30, 2008 at 17:51, Sterling Clover [EMAIL PROTECTED] wrote:
 Haxr provides a basic implementation of the XML-RPC protocol, and while it
 looks like it doesn' t build on 6.10 at the moment, getting it to build
 shouldn't be a problem, and although it doesn't appear to be under active
 development, it does seem to be getting maintenance uploads. [1]

HaXR should build with GHC 6.10 now, thanks for the prod.

 These days, however, web services seem to be moving towards a RESTful model
 with a JSON layer and there are plenty of JSON libraries on hackage, which
 you could just throw over the fastCGI bindings. Alternately you could try
 JSON over one of the really lightweight haskell web servers, such as shed
 [2] or lucu [3]. If you go the latter route, I'd love to hear how it went.

I agree with this. I would only use XML-RPC to talk to legacy applications.

 [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haxr
 [2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/httpd-shed
 [3] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Lucu

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


[Haskell-cafe] Re: catting to cat gets stuck at 135K

2008-12-01 Thread Simon Marlow

Donn Cave wrote:

Quoth Duncan Coutts [EMAIL PROTECTED]:
| On Thu, 2008-11-27 at 11:38 -0500, Brandon S. Allbery KF8NH wrote:
|
| The way this is usually handled in the non-threaded case is to either  
| use SIGCHLD or non-blocking waitpid() so that green threads can  
| continue running.  I'm a little surprised this wasn't done.

|
| Yes, we've discussed this in detail a few months back. We even have a
| partial implementation. However it stalled on needing a better signals
| API which we have not managed to get through the standardisation
| process.
|
| Unfortunately there is no non-blocking (non-polling) waitpid() and the
| global (process-scope) nature of signals is a pain.

SIGCHLD can be a pain in its own unusual way.  Once you have a SIGCHLD
handler, process exits will interrupt long I/O, so every such read(),
recv() or whatever must now check for EINTR and restart.  Even though
the authors of GHC go to great lengths to convert all I/O to non-blocking
anyway, this will still apply to external library functions that are
beyond GHC's reach.  So it's a strategy I would use only if I were kind
of desperate.


We already have this issue since GHC's runtime uses a SIGVTALRM timer 
signal for context switching and profiling.  Indeed, it did cause trouble 
with the editline library which doesn't test for EINTR in one or two 
places, and we had to work around it by temporarily disabling the timer.


Still, it's standard practice to test for EINTR and all library code should 
do it.


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


[Haskell-cafe] Re: Binary Trees missing on hackage

2008-12-01 Thread Andrew Wagner
Hm, I've been thinking about this this morning as I've gone about my
commute. I could indeed imagine a class like the following that had multiple
implementations like you're talking about:
class Tree t where
  drawTree :: t String - String
  flatten :: t a - [a]
  etc. (see
http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Tree.html)http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Tree.html

I think that for this to be valuable, though, we would need to show that
there are functions which can take a generic Tree t and do something useful
with it. Still, I suspect there's something there. Maybe I'll take a stab at
it this week sometime.

On Mon, Dec 1, 2008 at 6:24 AM, Andrew Wagner [EMAIL PROTECTED]wrote:

 The reasons I've always heard for this is that 1.) It's so easy to define a
 tree and 2.) There are tons of different variations of trees and what you
 can do with them. Not that I 100% agree, just what I've always heard.

 On Mon, Dec 1, 2008 at 6:09 AM, Christian Maeder [EMAIL PROTECTED]
  wrote:

 Hi,

 I was surprised that I could not find a classical binary tree data
 structure on hackage, mainly for teaching purposes, like:

  data BinTree a = Nil | Node (BinTree a) a (BinTree a)

 with a couple of utility functions and instances (i.e. in-order
 traversal).

 Surely, one may argue, that such a tree can always be defined on the fly
 when needed, but nobody would argue so for lists or tuples. (Although
 I've rarely seen someone redefining lists, it is quite common to
 introduce user-defined products or enumerations.)

 There are rose trees in Data.Tree and many other variants of trees are
 conceivable, ie.

  data Boom a = Leaf a | Node (Boom a) (Boom a)

 or a kind of combination:

  data BinLeafTree a b =
 Leaf b
   | Node (BinLeafTree a b) a (BinLeafTree a b)

 I don't know, why I find the above BinTree most important. I'm not even
 sure if such a tree could be re-used for Search- or AVL-trees that need
 strict fields with redundant size or height counters for efficiency
 reasons.

 In any case I would find such a data type at least as useful as
 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OneTuple

 Who would supply and maintain such a package? Or did I simply not search
 hard enough?

 Cheers Christian

 P.S. I took the (non-empty) Boom from the Boom-Hierarchy described in
 An Exploration of the Bird-Meertens Formalism by Roland Backhouse
 1988, Groningen

 ___
 Libraries mailing list
 [EMAIL PROTECTED]
 http://www.haskell.org/mailman/listinfo/libraries



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


[Haskell-cafe] Re: getLine and ^C on Windows

2008-12-01 Thread Simon Marlow

Mitchell, Neil wrote:

Hi

I have the same experience with Windows XP and getContents, so I think
it's the entire IO layer on Windows, rather than just getLine on Vista.
This is being tracked here
http://hackage.haskell.org/trac/ghc/ticket/2758 


Which is now fixed, FYI.  6.10.2 will have the fix.

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


[Haskell-cafe] Re: Problem with directory-1.0.0.0

2008-12-01 Thread Simon Marlow

Bartosz Wójcik wrote:

Hi Folks,

I'm facing problem after I've reinstalled directory-1.0.0.0 (setup 
configure/build/install). Since then I cannot complie anything that needs 
this library. It fails with following messages:


Preprocessing library haddock-2.4.0...
Preprocessing executables for haddock-2.4.0...
Building haddock-2.4.0...
/usr/bin/ar: creating dist/build/libHShaddock-2.4.0.a
Linking dist/build/haddock/haddock ...
/usr/local/lib/ghc-6.8.2/libHSghc.a(Coverage.o): In function `scXR_info':
(.text+0x17b7c): undefined reference to 
`directoryzm1zi0zi0zi0_SystemziDirectory_lvl29_closure'

/usr/local/lib/ghc-6.8.2/libHSghc.a(Coverage.o): In function `s8xU_info':
(.text+0x1792c): undefined reference to 
`directoryzm1zi0zi0zi0_SystemziDirectory_a43_info'

/usr/local/lib/ghc-6.8.2/libHSghc.a(Coverage.o): In function `r7aC_closure':
(.data+0xd18): undefined reference to 
`directoryzm1zi0zi0zi0_SystemziDirectory_a43_closure'

collect2: ld returned 1 exit status

Situation is following:
Old directory-1.0.0.0 resides 
in /usr/local/lib/ghc-6.8.2/lib/directory-1.0.0.0.

New one in /usr/local/lib/directory-1.0.0.0.

Why new one doesn't work?
How to force linker to use old one?


What happened here is that you recompiled directory without recompiling the 
things that depend on it (e.g. GHC).  This is a problem because compiled 
Haskell libraries don't have a fixed ABI: if you recompile the library, you 
get a different result, and all the compiled clients of the library must be 
recompiled.


For libraries that GHC depends on, this is a problem, because it's usually 
not practical to recompile GHC.  You can usually install a newer version of 
these libraries without conflicting with the old version, though.


We do think this is something that needs to be fixed in a future version of 
GHC (hopefully 6.12).


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


[Haskell-cafe] Re: Binary Trees missing on hackage

2008-12-01 Thread Christian Maeder
I find classes for sequences, collections (edison) and graphs (fgl) and
your proposed trees a bit awkward. I'ld like to see the actual data
types first.

Like for lists I can imagine a whole bunch of useful functions for
BinTree (below) that are already implemented multiple times for user
defined binary trees (in other libraries).

Cheers Christian

Andrew Wagner wrote:
 Hm, I've been thinking about this this morning as I've gone about my
 commute. I could indeed imagine a class like the following that had
 multiple implementations like you're talking about:
 
 class Tree t where
   drawTree :: t String - String
   flatten :: t a - [a]
   etc.
 (see 
 http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Tree.html)
 http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Tree.html
 
 I think that for this to be valuable, though, we would need to show that
 there are functions which can take a generic Tree t and do something
 useful with it. Still, I suspect there's something there. Maybe I'll
 take a stab at it this week sometime.
 
 On Mon, Dec 1, 2008 at 6:24 AM, Andrew Wagner [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
 
 The reasons I've always heard for this is that 1.) It's so easy to
 define a tree and 2.) There are tons of different variations of
 trees and what you can do with them. Not that I 100% agree, just
 what I've always heard.
 
 On Mon, Dec 1, 2008 at 6:09 AM, Christian Maeder
 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:
 
 Hi,
 
 I was surprised that I could not find a classical binary tree data
 structure on hackage, mainly for teaching purposes, like:
 
  data BinTree a = Nil | Node (BinTree a) a (BinTree a)
 
 with a couple of utility functions and instances (i.e. in-order
 traversal).
 
 Surely, one may argue, that such a tree can always be defined on
 the fly
 when needed, but nobody would argue so for lists or tuples.
 (Although
 I've rarely seen someone redefining lists, it is quite common to
 introduce user-defined products or enumerations.)
 
 There are rose trees in Data.Tree and many other variants of
 trees are
 conceivable, ie.
 
  data Boom a = Leaf a | Node (Boom a) (Boom a)
 
 or a kind of combination:
 
  data BinLeafTree a b =
 Leaf b
   | Node (BinLeafTree a b) a (BinLeafTree a b)
 
 I don't know, why I find the above BinTree most important. I'm
 not even
 sure if such a tree could be re-used for Search- or AVL-trees
 that need
 strict fields with redundant size or height counters for
 efficiency reasons.
 
 In any case I would find such a data type at least as useful as
 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OneTuple
 
 Who would supply and maintain such a package? Or did I simply
 not search
 hard enough?
 
 Cheers Christian
 
 P.S. I took the (non-empty) Boom from the Boom-Hierarchy
 described in
 An Exploration of the Bird-Meertens Formalism by Roland Backhouse
 1988, Groningen
 
 ___
 Libraries mailing list
 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
 http://www.haskell.org/mailman/listinfo/libraries
 
 
 
 
 
 
 ___
 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] workarounds for Codec.Compression.Zlib errors in darcs

2008-12-01 Thread Neil Mitchell
 While that's true, Haskell also makes it easy to make the same sort of
 error with IO (or any other Monad) values, whether created with the FFI
 or not. If you say

f = do x
   y
   z

 and y has type IO CInt then you won't get an error (and I don't think
 you can even ask for a warning with the current implementations).

 Should we have
() :: (Monad m) = m () - m a - m a
 and force you to write
_ - y


It's intersting to note that F# follows exactly your proposal. If x
has a return type other than () then you do:

y | ignore

where ignore :: a - (), and | = flip ($)

In practice, I found this quite reasonable to use. You also eliminate
errors such as:

do mapM deleteFile files ; return 1

Where mapM requires more memory than the equivalent mapM_

Thanks

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


[Haskell-cafe] Re: howto tuple fold to do n-ary cross product?

2008-12-01 Thread Larry Evans

On 11/30/08 12:49, Larry Evans wrote:
[snip]


You'll see Domains can be an mpl::vector of any
length. The cross_nproduct_view_test.cpp tests
with a 3 element Domains:

typedef
  mpl::vector
   mpl::range_cint,0,4
  , mpl::range_cint,100,103
  , mpl::range_cint,2000,2002
  
domains;


OOPS.  That's in another test driver.  The one
in the cross_nproduct_view_test.cpp has:

typedef range_cint,0,1 seq0;
typedef range_cint,  100,  102 seq1;
typedef range_cint, 2000, 2002 seq2;
typedef range_cint,3,30003 seq3;
typedef
  list
   seq0
  , seq1
  , seq2
  , seq3
  
domains;

The range_cint, 100, 102 template instance:

http://www.boost.org/doc/libs/1_37_0/libs/mpl/doc/refmanual/range-c.html

produces a type sequence of length 2.
So mpl::listseq0,...,seq3 is a sequence of sequences
similar to haskell's [[a]] except that it's a sequence
of a sequences of types instead of a sequence of
sequences of values.



The cross_nproduct_view template  and test driver
are found in the cross_nproduct_view.zip file here:

  http://preview.tinyurl.com/5ar9g4


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


Re: [Haskell-cafe] ANN: Real World Haskell, now shipping

2008-12-01 Thread John Goerzen
Don Stewart wrote:

 Very curious. Did you file a bug report with the maintainers of the 30+
 database packages on hackage?
 
 Or did you not have the underlying database drivers installed?
 
 Did you make any attempt to contact the authors to determine the cause
 of your problem?

Incidentally, with my HDBC maintainer hat on, I can state:

1) That I have no Windows development machines myself;

2) That Windows people are using HDBC and HDBC-ODBC;

3) I actively try to maintain all of my packages in a
cross-platform-friendly manner (except those that are really tied to one
platform, such as HSH)

4) Windows users actively send me patches if something breaks, and these
are readily applied.

I don't think this state of affairs is unique in the Haskell world.
Some people use Linux, Mac, or Windows as their main development box,
but pretty much everybody tries to support all platforms.

Incidentally, Andrew Coppin (CCd on this thread already) is one of those
that has sent me patches.

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


[Haskell-cafe] Parallel alpha-beta search

2008-12-01 Thread Colin Paul Adams
Has anyone ever attempted this in Haskell? If so, what sort of
speed-up have you had (with which algorithm)?
-- 
Colin Adams
Preston Lancashire
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The Knight's Tour: solutions please

2008-12-01 Thread Bertram Felgenhauer
Don Stewart wrote:
 Lee Pike forwarded the following:
 
 Solving the Knight's Tour Puzzle In 60 Lines of Python
 
 http://developers.slashdot.org/article.pl?sid=08/11/30/1722203
 
 Seems that perhaps (someone expert in) Haskell could do even better?   
 Maybe even parallelize the problem? :)

As one of the posters there points out, for n=100 the program doesn't
actually backtrack if the 'loneliest neighbour' heuristic is used. Do any
of our programs finish quickly for n=99? The Python one doesn't.

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


[Haskell-cafe] Scala job in Boston writing quantitative finance software

2008-12-01 Thread Paul Chiusano
Hi folks,

The company I work for, ClariFI (http://clarifi.com/), is looking to hire
developers with a strong background in functional programming to do a
mixture of Scala and Java programming. It's fine if you don't happen to know
Scala but are strong in Haskell - we are looking for people who really get
FP and who we could turn loose designing and implementing clean, functional
code in Scala once up to speed with the language. You'd also work on
extending existing Scala modules and integrating the library code you write
with application code written in Java. For more info, check out our official
job posting:
http://www.clarifi.com/About-ClariFI-Careers.php#SoftwareEngineer

Some background on us: ClariFI is a small company (about 15 developers) that
specializes in software for quantitative investment management. Our chief
product, ModelStation, is used by portfolio managers for handling all stages
of the quant process: building and backtesting of factors, portfolio
optimization, simulation of trading strategies, performance and risk
attribution, overall data management (including organizing huge amounts of
time series data pulled from a diverse set of raw sources), and lots
more. We don't expect you to have a background in finance but you should be
willing and able to learn a lot once you start.

This position is in our Boston office, so you must live or be willing to
relocate here in order to be considered. If you're interested, send an email
to myself or my boss, Scott McFarland ([EMAIL PROTECTED]), along with
your resume. Also, feel free to contact either of us if you just have
questions about the position.

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


[Haskell-cafe] Re: The Knight's Tour: solutions please

2008-12-01 Thread Diego Echeverri
I've created a wiki page,
http://haskell.org/haskellwiki/The_Knights_Tour
I note the LogicT version is the shortest so far.
-- Don

Probably noob question. I was looking into the first solution in the
page and tried to replace

sortOn f = map snd . sortBy (comparing fst) . map (f  id)
for
sortOn' f = sortBy (comparing fst)

The first one was much faster? Why?

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


Re: [Haskell-cafe] ANN: Real World Haskell, now shipping

2008-12-01 Thread Andrew Coppin

John Goerzen wrote:

Don Stewart wrote:

  

Very curious. Did you file a bug report with the maintainers of the 30+
database packages on hackage?

Or did you not have the underlying database drivers installed?

Did you make any attempt to contact the authors to determine the cause
of your problem?



Incidentally, with my HDBC maintainer hat on, I can state:

1) That I have no Windows development machines myself;

2) That Windows people are using HDBC and HDBC-ODBC;

3) I actively try to maintain all of my packages in a
cross-platform-friendly manner (except those that are really tied to one
platform, such as HSH)

4) Windows users actively send me patches if something breaks, and these
are readily applied.

I don't think this state of affairs is unique in the Haskell world.
Some people use Linux, Mac, or Windows as their main development box,
but pretty much everybody tries to support all platforms.

Incidentally, Andrew Coppin (CCd on this thread already) is one of those
that has sent me patches.
  


OK, now I'm puzzled. I don't remember that! :-}

I recall _trying_ to get a few of the database packages to build (I 
cannot remember which one(s) now - there's so many). In fact, IIRC, I 
even got the base package to build, but the driver for my database 
wouldn't build. (I forget why exactly.) In my experience, almost 
*everything* on Hackage consistently fails to build on Windows, so I 
think by this point I'd more or less given up even trying to make things 
build for me. In short, I didn't follow this one very far... At least, 
that's how I remember it. I guess this is where somebody digs up some 
thread on cafe from 3 years ago or something and proves me wrong. :-}


In other news... why the hell does my ISP never deliver any emails to 
cafe originating from Don? They show up in Gmane, but not my inbox... 
how frustrating! (I'd reply to his other email, but I can't because it's 
not in my inbox.)


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


Re: [Haskell-cafe] Re: The Knight's Tour: solutions please

2008-12-01 Thread Duncan Coutts
On Mon, 2008-12-01 at 22:48 +0100, Diego Echeverri wrote:
 I've created a wiki page,
 http://haskell.org/haskellwiki/The_Knights_Tour
 I note the LogicT version is the shortest so far.
 -- Don
 
 Probably noob question. I was looking into the first solution in the
 page and tried to replace
 
 sortOn f = map snd . sortBy (comparing fst) . map (f  id)
 for
 sortOn' f = sortBy (comparing fst)

Presumably you mean:

sortOn' f = sortBy (comparing (f . fst))

 The first one was much faster? Why?

Caching. It caches all the calls to f. So f gets called once per-element
in the input list rather than every time the sort needs to do a
comparison. The number of comparisons sort does is proportional to n *
log n. So that's a log factor more calls of f. Presumably f is
reasonably expensive in this case, enough to offset the extra
book-keeping needed to cache all the calls.

Duncan

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


Re: [Haskell-cafe] manipulating predicate formulae

2008-12-01 Thread Ganesh Sittampalam

On Sun, 30 Nov 2008, Neil Mitchell wrote:


http://www.cs.york.ac.uk/fp/darcs/proposition/

Unreleased, but might be of interest. It simplifies propositional
formulae, and can do so using algebraic laws, custom simplifications
or BDDs. I don't really use this library, so if it is of interest to
you, its all yours :-)


Thanks, but I don't think a propositional library is a good starting point 
for a predicate library - the problems are too different. Sadly my 
predicates are over infinite domains, otherwise BDDs would have been 
really nice :-(


Cheers,

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


[Haskell-cafe] Re: '#' in literate haskell

2008-12-01 Thread John MacFarlane
+++ Bertram Felgenhauer [Nov 30 08 09:57 ]:
 John MacFarlane wrote:
  Can anyone explain why ghc does not treat the following
  as a valid literate haskell program?
  
  - test.lhs 
  # This is a test
  
   foo = reverse . words
  
  
 
 I believe this is an artifact of ghc trying to parse cpp style line
 number information:
 
  foo.lhs 
 # 123 foo.foo
 
  t = 
 
 
 will print this error:
foo.foo:124:6: parse error on input `'

Thanks!  Mystery solved.

John

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


Re: [Haskell-cafe] ANN: Real World Haskell, now shipping

2008-12-01 Thread John Goerzen
On Mon, Dec 01, 2008 at 09:59:24PM +, Andrew Coppin wrote:
 I don't think this state of affairs is unique in the Haskell world.
 Some people use Linux, Mac, or Windows as their main development box,
 but pretty much everybody tries to support all platforms.

 Incidentally, Andrew Coppin (CCd on this thread already) is one of those
 that has sent me patches.
   

 OK, now I'm puzzled. I don't remember that! :-}

OK, I went back and looked at my Git logs and you're right.  Wrong
Andrew.  Sorry.

 I recall _trying_ to get a few of the database packages to build (I  
 cannot remember which one(s) now - there's so many). In fact, IIRC, I  
 even got the base package to build, but the driver for my database  
 wouldn't build. (I forget why exactly.) In my experience, almost  
 *everything* on Hackage consistently fails to build on Windows, so I  
 think by this point I'd more or less given up even trying to make things  
 build for me. In short, I didn't follow this one very far... At least,  
 that's how I remember it. I guess this is where somebody digs up some  
 thread on cafe from 3 years ago or something and proves me
 wrong. :-}

I would welcome bug reports and, even better, patches for this stuff.

But I was pretty sure that HDBC and HDBC-ODBC in particular are
working on Windows.

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


Re: [Haskell-cafe] The Knight's Tour: solutions please

2008-12-01 Thread Dan Doel
On Monday 01 December 2008 1:39:13 pm Bertram Felgenhauer wrote:
 As one of the posters there points out, for n=100 the program doesn't
 actually backtrack if the 'loneliest neighbour' heuristic is used. Do any
 of our programs finish quickly for n=99? The Python one doesn't.

Nothing I tried finished. Do you have any figures on how much backtracking 
needs to be done to find a solution for n=99 (there is a solution, right?)? I 
tweaked the continuation version to print k when it backtracks, and it 
continuously spit out numbers around 9790. I get the feeling it doesn't matter 
how fast your backtracking infrastructure is in this case as long as you use 
the same general algorithm.

On a long shot, I even tried using Logic's alternate bind based on fair 
choice, but that didn't seem to be any better.

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


[Haskell-cafe] Can anybody give me some advice on this?

2008-12-01 Thread Georgel Calin
Hello everybody,

I have a piece of code that gives me headaches for some time now.

Simply put, I would like to know which is the best way to overpass a
Couldn't match expected type * against inferred type *-error and an
Occurs check: cannot construct the infinite type:-error in the following
situation:

{-# OPTIONS -fglasgow-exts #-}
 module Simple where
 import Text.ParserCombinators.Parsec

 data HData a = O | C a deriving (Eq,Ord,Show)
 data IN l = IN Int (HData l) deriving (Eq,Ord,Show)
 data CH l = CH Char (HData l) deriving (Eq,Ord,Show)
 -- data type is well-defined:
 sample = C(IN 0 (C(CH 'a' (C(IN 1 (C(CH 'b' (C(IN 2 O)

 embeddedParser types =  do string end; spaces; return O
 {-
 | do let h = head types
   let t = tail types
   case h of
  1 - do aux - pInt
 rest - embeddedParser $t++[h]
 return $ C (IN aux rest)
  2 - do aux - pCh
 rest - embeddedParser $t++[h]
 return $ C (CH aux rest)
  _ - error unallowed type
 -}
 pInt =  do n - fmap read $ many1 digit; return $ fromInteger n
 pCh =  do c - letter; return $ c
 simple = embeddedParser [1,2]

 -- the above result from sample I would like to get by running
 -- parseTest simple 0a1b2end


The way I see it, the defined datatype works but I am a bit clueless about
how to modify the parser to accept things of the type (e.g.): HData (IN (CH
(IN (CH (IN a) (and in general of any finite type embedded like this).

Thanks in advance for your help,
George
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] global variables for foreign C functions

2008-12-01 Thread Andrea Rossato
Hello,

I'm writing the bindings to a C library which uses, in some functions,
global variables.

To make it clearer, those functions need a global variable to be
defined. A C program using my_function, one of the library functions,
would look like:

char progname[] = a_program_name;

int
main( int argc, char *argv[] )
{
param p;
my_function ( p )
etc.

I've been searching the ML, the wiki, the net, etc. without finding
some examples on how such things are dealt with in Haskell - is it
possible, BTW?

If I import those functions without defining the global variable I get
a linker error:

/usr/lib/mylib.a(cfile.o): In function `my_function':
cfile.c:(.text+0x510): undefined reference to `progname'

I hope the issue is clear. Any help would be greatly appreciated.

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


Re: [Haskell-cafe] global variables for foreign C functions

2008-12-01 Thread Evan Laforge
On Mon, Dec 1, 2008 at 4:39 PM, Andrea Rossato
[EMAIL PROTECTED] wrote:
 Hello,

 I'm writing the bindings to a C library which uses, in some functions,
 global variables.

 To make it clearer, those functions need a global variable to be
 defined. A C program using my_function, one of the library functions,
 would look like:

I don't think you can use the FFI to declare symbols for C.  One
not-so-pretty but effective way to do it is create a stub.c with the
variables declared along with setting functions, then bind those
functions like any other.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] global variables for foreign C functions

2008-12-01 Thread Judah Jacobson
On Mon, Dec 1, 2008 at 4:55 PM, Evan Laforge [EMAIL PROTECTED] wrote:
 On Mon, Dec 1, 2008 at 4:39 PM, Andrea Rossato
 [EMAIL PROTECTED] wrote:
 Hello,

 I'm writing the bindings to a C library which uses, in some functions,
 global variables.

 To make it clearer, those functions need a global variable to be
 defined. A C program using my_function, one of the library functions,
 would look like:

 I don't think you can use the FFI to declare symbols for C.  One
 not-so-pretty but effective way to do it is create a stub.c with the
 variables declared along with setting functions, then bind those
 functions like any other.

You can limit the size of that stub file using:

foreign import ccall progname progname :: Ptr (Ptr CChar)

which lets you access that global variable and write the
getters/setters in Haskell rather than C.

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


Re: [Haskell-cafe] global variables for foreign C functions

2008-12-01 Thread John Meacham
On Mon, Dec 01, 2008 at 04:55:14PM -0800, Evan Laforge wrote:
 On Mon, Dec 1, 2008 at 4:39 PM, Andrea Rossato
 [EMAIL PROTECTED] wrote:
  Hello,
 
  I'm writing the bindings to a C library which uses, in some functions,
  global variables.
 
  To make it clearer, those functions need a global variable to be
  defined. A C program using my_function, one of the library functions,
  would look like:
 
 I don't think you can use the FFI to declare symbols for C.  One
 not-so-pretty but effective way to do it is create a stub.c with the
 variables declared along with setting functions, then bind those
 functions like any other.

Yes, it is unfortunate this is the case. my ForeignData proposal was
meant to address this:

http://hackage.haskell.org/trac/haskell-prime/wiki/ForeignData

I am not entirely sure about the proposal as described, but I think
something like it should be done.

John

-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Can anybody give me some advice on this?

2008-12-01 Thread Ryan Ingram
The problem is this: what is the type of embeddedParser?  Unless you
can answer that question, you're not going to be able to write it.

In particular, its *type* depends on the *value* of its argument; the
type of embeddedParser [1,2] is different from the type of
embeddedParser [1,1,2].  This isn't possible in Haskell; you need a
language with an even more exotic type system (Agda, for example) to
encode this dependency.  Google dependent types for more
information.

You can encode something similar using existentials:

data Sealed p = forall a. Sealed (p a)
type ParseResult = Sealed HData

...

case h of
1 - do
aux - pInt
Sealed rest - embeddedParser (t ++ [h])
return (Sealed (C (In aux rest)))

and a similar transformation on the (2) case and the end case; this
makes the type of embeddedParser into Parser ParseResult.  What you
are doing here is saying that the result of a parse is an HData a for
*some* a, but you aren't saying which one.   You extract the HData
from the existential when running the sub parser, then stuff it back
into another existential.

But you can't extract the type out of the existential ever; it is
lost.  In particular you can't prove to the compiler that the type
matches that of the [1,2] input and get back to the IN and CH values.
And you can't return a value that has been extracted out, you can only
stuff it back into another existential container or consume it in some
other way!

A better option is to use a type that matches what you expect to
parse, or just use Data.Dynamic if you want multiple types.  You
aren't going to get any benefit from HData a without a lot more
type-level work!

Also, for your type list, it'd be much more efficient to use (cycle
types) to construct an infinite list (in finite space!) rather than
keep appending the head back onto the tail.

2008/12/1 Georgel Calin [EMAIL PROTECTED]:
 Hello everybody,

 I have a piece of code that gives me headaches for some time now.

 Simply put, I would like to know which is the best way to overpass a
 Couldn't match expected type * against inferred type *-error and an
 Occurs check: cannot construct the infinite type:-error in the following
 situation:

 {-# OPTIONS -fglasgow-exts #-}
 module Simple where
 import Text.ParserCombinators.Parsec

 data HData a = O | C a deriving (Eq,Ord,Show)
 data IN l = IN Int (HData l) deriving (Eq,Ord,Show)
 data CH l = CH Char (HData l) deriving (Eq,Ord,Show)
 -- data type is well-defined:
 sample = C(IN 0 (C(CH 'a' (C(IN 1 (C(CH 'b' (C(IN 2 O)

 embeddedParser types =  do string end; spaces; return O
 {-
 | do let h = head types
   let t = tail types
   case h of
  1 - do aux - pInt
 rest - embeddedParser $t++[h]
 return $ C (IN aux rest)
  2 - do aux - pCh
 rest - embeddedParser $t++[h]
 return $ C (CH aux rest)
  _ - error unallowed type
 -}
 pInt =  do n - fmap read $ many1 digit; return $ fromInteger n
 pCh =  do c - letter; return $ c
 simple = embeddedParser [1,2]

 -- the above result from sample I would like to get by running
 -- parseTest simple 0a1b2end

 The way I see it, the defined datatype works but I am a bit clueless about
 how to modify the parser to accept things of the type (e.g.): HData (IN (CH
 (IN (CH (IN a) (and in general of any finite type embedded like this).

 Thanks in advance for your help,
 George
 ___
 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] Can anybody give me some advice on this?

2008-12-01 Thread Ryan Ingram
Also, if you can give up on the dependent types issue, and you just
want the equivalent of embeddedParser [1,2], you have a problem that
the type you are specifying is infinite; this is the cause of the
occurs checks errors you are getting.

Lets specify the type you are parsing directly, then abstract a bit:

 -- your HData is just Maybe!

 data IN1 = IN1 Int (Maybe CH1)
 data CH1 = CH1 Char (Maybe IN1)

 sample :: Maybe IN1
 sample = Just $
  IN1 0 $ Just $
  CH1 'a' $ Just $
  IN1 1 $ Just $
  CH1 'b' $ Just $
  IN1 2 $ Nothing

You can easily write a parser for this type with two mutually
recursive parsers that parse IN1 and CH1; I'll leave that as an
exercise for you.

Now, you might not want to explicitly specify the type of the result
in the data type; that's what you have done with your versions of IN
and CH that take the rest of the type as an argument.  But the
problem with that approach is that the resultant type is *infinite*!

 data
 -- broken:
 -- type ParserResult = Maybe (IN (Maybe (CH (Maybe (IN (Maybe ...

But there is a great trick to solve this; another type can wrap the
fixpoint of this type:

 newtype Mu f = In (f (Mu f))
 out (In x) = x

You can then use this structure to define the type of the parser:

 data ResultOpen a = O | C (IN (ResultOpen (CH (ResultOpen a
 type Result = Mu ResultOpen

What Mu does here is fill in the a in ResultOpen with (ResultOpen
(ResultOpen (ResultOpen (ResultOpen ..., infinitely large.  The price
you pay for this infinite type is that you have to explicitly mark the
boundaries with In; the constructor for Mu:

 sample2 :: Result
 sample2 = In (C(IN 0 (C(CH 'a' (In (C(IN 1 (C(CH 'b' (In (C(IN 2 O

A parser for this type is also not too difficult to write; you just
have to take care to use In and out in the right places.

  -- ryan

On Mon, Dec 1, 2008 at 6:08 PM, Ryan Ingram [EMAIL PROTECTED] wrote:
 The problem is this: what is the type of embeddedParser?  Unless you
 can answer that question, you're not going to be able to write it.

 In particular, its *type* depends on the *value* of its argument; the
 type of embeddedParser [1,2] is different from the type of
 embeddedParser [1,1,2].  This isn't possible in Haskell; you need a
 language with an even more exotic type system (Agda, for example) to
 encode this dependency.  Google dependent types for more
 information.

 You can encode something similar using existentials:

 data Sealed p = forall a. Sealed (p a)
 type ParseResult = Sealed HData

 ...

 case h of
1 - do
aux - pInt
Sealed rest - embeddedParser (t ++ [h])
return (Sealed (C (In aux rest)))

 and a similar transformation on the (2) case and the end case; this
 makes the type of embeddedParser into Parser ParseResult.  What you
 are doing here is saying that the result of a parse is an HData a for
 *some* a, but you aren't saying which one.   You extract the HData
 from the existential when running the sub parser, then stuff it back
 into another existential.

 But you can't extract the type out of the existential ever; it is
 lost.  In particular you can't prove to the compiler that the type
 matches that of the [1,2] input and get back to the IN and CH values.
 And you can't return a value that has been extracted out, you can only
 stuff it back into another existential container or consume it in some
 other way!

 A better option is to use a type that matches what you expect to
 parse, or just use Data.Dynamic if you want multiple types.  You
 aren't going to get any benefit from HData a without a lot more
 type-level work!

 Also, for your type list, it'd be much more efficient to use (cycle
 types) to construct an infinite list (in finite space!) rather than
 keep appending the head back onto the tail.

 2008/12/1 Georgel Calin [EMAIL PROTECTED]:
 Hello everybody,

 I have a piece of code that gives me headaches for some time now.

 Simply put, I would like to know which is the best way to overpass a
 Couldn't match expected type * against inferred type *-error and an
 Occurs check: cannot construct the infinite type:-error in the following
 situation:

 {-# OPTIONS -fglasgow-exts #-}
 module Simple where
 import Text.ParserCombinators.Parsec

 data HData a = O | C a deriving (Eq,Ord,Show)
 data IN l = IN Int (HData l) deriving (Eq,Ord,Show)
 data CH l = CH Char (HData l) deriving (Eq,Ord,Show)
 -- data type is well-defined:
 sample = C(IN 0 (C(CH 'a' (C(IN 1 (C(CH 'b' (C(IN 2 O)

 embeddedParser types =  do string end; spaces; return O
 {-
 | do let h = head types
   let t = tail types
   case h of
  1 - do aux - pInt
 rest - embeddedParser $t++[h]
 return $ C (IN aux rest)
  2 - do aux - pCh
 

Re: [Haskell-cafe] global variables for foreign C functions

2008-12-01 Thread John Van Enk
I would find a ForeignData extension incredibly helpful. This will be
crucial if Haskell ever wants to target out of the ordinary systems.

/jve


On Mon, Dec 1, 2008 at 8:38 PM, John Meacham [EMAIL PROTECTED] wrote:

 On Mon, Dec 01, 2008 at 04:55:14PM -0800, Evan Laforge wrote:
  On Mon, Dec 1, 2008 at 4:39 PM, Andrea Rossato
  [EMAIL PROTECTED] wrote:
   Hello,
  
   I'm writing the bindings to a C library which uses, in some functions,
   global variables.
  
   To make it clearer, those functions need a global variable to be
   defined. A C program using my_function, one of the library functions,
   would look like:
 
  I don't think you can use the FFI to declare symbols for C.  One
  not-so-pretty but effective way to do it is create a stub.c with the
  variables declared along with setting functions, then bind those
  functions like any other.

 Yes, it is unfortunate this is the case. my ForeignData proposal was
 meant to address this:

 http://hackage.haskell.org/trac/haskell-prime/wiki/ForeignData

 I am not entirely sure about the proposal as described, but I think
 something like it should be done.

John

 --
 John Meacham - ⑆repetae.net⑆john⑈
 ___
 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: Binary Trees missing on hackage

2008-12-01 Thread Brandon S. Allbery KF8NH

On 2008 Dec 1, at 8:28, Andrew Wagner wrote:
Hm, I've been thinking about this this morning as I've gone about my  
commute. I could indeed imagine a class like the following that had  
multiple implementations like you're talking about:


One can indeed --- but it turns out to be even more general than just  
trees.  Go look at the Foldable and Traversable classes.


--
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] bug in time libs?

2008-12-01 Thread Jason Dusek
  I'm on 6.10.1, using the libs provided with the binary of GHC
  for Mac OS X. I was fooling around with the time package in
  GHCi and something seems to be off. I have included a
  transcript.

  If I take a time diff, then the seconds are positive when the
  picos are negative and vice versa.

--
_jsn


 |...transcript...|


  Prelude System.Time :m + System.Time
  Prelude System.Time t0 - System.Time.getClockTime
  Prelude System.Time t1 - System.Time.getClockTime
  Prelude System.Time diffClockTimes t0 t1
  TimeDiff { tdYear = 0
   , tdMonth = 0
   , tdDay = 0
   , tdHour = 0
   , tdMin = 0
   , tdSec = -7
   , tdPicosec = 23884600
   }
  Prelude System.Time diffClockTimes t1 t0
  TimeDiff { tdYear = 0
   , tdMonth = 0
   , tdDay = 0
   , tdHour = 0
   , tdMin = 0
   , tdSec = 7
   , tdPicosec = -23884600
   }
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] bug in time libs?

2008-12-01 Thread sam lee
I can't find document for System.Time .

But I can import System.Time . It's weird...
I can't find document for TimeDiff and related functions. I guess this
is all deprecated.

A related bug report: http://hackage.haskell.org/trac/ghc/ticket/2519

I would use Data.Time.Clock

Prelude :m + Data.Time.Clock
Prelude Data.Time.Clock getCurrentTime
Prelude Data.Time.Clock t0 - getCurrentTime
Prelude Data.Time.Clock t1 - getCurrentTime
Prelude Data.Time.Clock t0
Prelude Data.Time.Clock diffUTCTime t0 t1
-2.912s
Prelude Data.Time.Clock diffUTCTime t1 t0
2.912s
Prelude Data.Time.Clock :t diffUTCTime t1 t0
diffUTCTime t1 t0 :: NominalDiffTime

On Mon, Dec 1, 2008 at 10:05 PM, Jason Dusek [EMAIL PROTECTED] wrote:
  I'm on 6.10.1, using the libs provided with the binary of GHC
  for Mac OS X. I was fooling around with the time package in
  GHCi and something seems to be off. I have included a
  transcript.

  If I take a time diff, then the seconds are positive when the
  picos are negative and vice versa.

 --
 _jsn


  |...transcript...|


  Prelude System.Time :m + System.Time
  Prelude System.Time t0 - System.Time.getClockTime
  Prelude System.Time t1 - System.Time.getClockTime
  Prelude System.Time diffClockTimes t0 t1
  TimeDiff { tdYear = 0
   , tdMonth = 0
   , tdDay = 0
   , tdHour = 0
   , tdMin = 0
   , tdSec = -7
   , tdPicosec = 23884600
   }
  Prelude System.Time diffClockTimes t1 t0
  TimeDiff { tdYear = 0
   , tdMonth = 0
   , tdDay = 0
   , tdHour = 0
   , tdMin = 0
   , tdSec = 7
   , tdPicosec = -23884600
   }
 ___
 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] Re: Cabal

2008-12-01 Thread mail
Don Stewart [EMAIL PROTECTED] writes:

 I'm a fan of gitit, and its 46 dependencies, that install via
 cabal-install. Pretty awesome.


gitit's 46 dependencies convinced me to install cabal-install, and now I
couldn't be happier!

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


Re: [Haskell-cafe] The Knight's Tour: solutions please

2008-12-01 Thread wren ng thornton

Dan Doel wrote:

On Monday 01 December 2008 1:39:13 pm Bertram Felgenhauer wrote:
 As one of the posters there points out, for n=100 the program doesn't
 actually backtrack if the 'loneliest neighbour' heuristic is used. Do any
 of our programs finish quickly for n=99? The Python one doesn't.

Nothing I tried finished. Do you have any figures on how much backtracking 
needs to be done to find a solution for n=99 (there is a solution, right?)? I 
tweaked the continuation version to print k when it backtracks, and it 
continuously spit out numbers around 9790. I get the feeling it doesn't matter 
how fast your backtracking infrastructure is in this case as long as you use 
the same general algorithm.


On a long shot, I even tried using Logic's alternate bind based on fair 
choice, but that didn't seem to be any better.


FWIW, fair choice (interleave) is much slower than unfair choice (mplus) 
in logict. Unfortunately this means you need to know a lot about the 
problem domain to correctly choose between them when maximal performance 
is at stake; just using fair choice everywhere costs too much for many 
problems.


--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] System.IO.UTF8 Problem

2008-12-01 Thread Ben George
Hi, so I've been working with System.IO.UTF8 trying to get it to render
Japanese characters correctly. Using just IO I've gotten it to output
the correct unicode values, however, replacing the IO.putStrLn commands
with System.IO.UTF8 yielded some strange errors. I went through the
program and replaced the System.IO.UTF8 putStrLn and hGetLine commands
with their normal IO counterparts, however, simply having the import
System.IO.UTF8 line at the beginning of the file causes an error during
compilation.

$ghc file.hs
compilation IS NOT required
byteindex.o: In function `sKE_info':
(.text+0x8bf): undefined reference to
`__stginit_utf8zmstringzm0zi3zi3_SystemziIOziUTF8_'
collect2: ld returned 1 exit status



Below is the output of ghc -v.

I am running Ubuntu 7.10 gutsy. I have been getting the same error
whether GHC was compiled from binaries or source. Currently I am running
GHC (version 6.8.3) compiled from source.

$ ghc -v file.hs
Glasgow Haskell Compiler, Version 6.8.3, for Haskell 98, stage 2 booted
by GHC version 6.8.3
Using package config file: /usr/local/lib/ghc-6.8.3/package.conf
wired-in package base mapped to base-3.0.2.0
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0.1.0
wired-in package template-haskell mapped to template-haskell-2.2.0.0
wired-in package ndp not found.
Hsc static flags: -static
Created temporary directory: /tmp/ghc6586_0
*** Checking old interface for main:Main:
compilation IS NOT required
*** Touching object file:
touch byteindex.o
*** Linker:
gcc -v -o a.out -DDONT_WANT_WIN32_DLL_SUPPORT byteindex.o
-L/usr/local/lib/ghc-6.8.3/lib/haskell98-1.0.1.0
-L/usr/local/lib/ghc-6.8.3/lib/array-0.1.0.0
-L/usr/local/lib/ghc-6.8.3/lib/process-1.0.0.1
-L/usr/local/lib/ghc-6.8.3/lib/unix-2.3.0.1
-L/usr/local/lib/ghc-6.8.3/lib/random-1.0.0.0
-L/usr/local/lib/ghc-6.8.3/lib/directory-1.0.0.1
-L/usr/local/lib/ghc-6.8.3/lib/filepath-1.1.0.0
-L/usr/local/lib/ghc-6.8.3/lib/old-time-1.0.0.0
-L/usr/local/lib/ghc-6.8.3/lib/old-locale-1.0.0.0
-L/usr/local/lib/ghc-6.8.3/lib/base-3.0.2.0 -L/usr/local/lib/ghc-6.8.3
-lHShaskell98-1.0.1.0 -lHSarray-0.1.0.0 -lHSprocess-1.0.0.1
-lHSunix-2.3.0.1 -lutil -ldl -lHSrandom-1.0.0.0 -lHSdirectory-1.0.0.1
-lHSfilepath-1.1.0.0 -lHSold-time-1.0.0.0 -lHSold-locale-1.0.0.0
-lHSbase-3.0.2.0 -lHSrts -lm -lgmp -ldl -lrt -u
base_GHCziBase_Izh_static_info -u base_GHCziBase_Czh_static_info -u
base_GHCziFloat_Fzh_static_info -u base_GHCziFloat_Dzh_static_info -u
base_GHCziPtr_Ptr_static_info -u base_GHCziWord_Wzh_static_info -u
base_GHCziInt_I8zh_static_info -u base_GHCziInt_I16zh_static_info -u
base_GHCziInt_I32zh_static_info -u base_GHCziInt_I64zh_static_info -u
base_GHCziWord_W8zh_static_info -u base_GHCziWord_W16zh_static_info -u
base_GHCziWord_W32zh_static_info -u base_GHCziWord_W64zh_static_info -u
base_GHCziStable_StablePtr_static_info -u base_GHCziBase_Izh_con_info -u
base_GHCziBase_Czh_con_info -u base_GHCziFloat_Fzh_con_info -u
base_GHCziFloat_Dzh_con_info -u base_GHCziPtr_Ptr_con_info -u
base_GHCziPtr_FunPtr_con_info -u base_GHCziStable_StablePtr_con_info -u
base_GHCziBase_False_closure -u base_GHCziBase_True_closure -u
base_GHCziPack_unpackCString_closure -u
base_GHCziIOBase_stackOverflow_closure -u
base_GHCziIOBase_heapOverflow_closure -u
base_GHCziIOBase_NonTermination_closure -u
base_GHCziIOBase_BlockedOnDeadMVar_closure -u
base_GHCziIOBase_BlockedIndefinitely_closure -u
base_GHCziIOBase_Deadlock_closure -u
base_GHCziIOBase_NestedAtomically_closure -u
base_GHCziWeak_runFinalizzerBatch_closure -u
base_GHCziConc_ensureIOManagerIsRunning_closure
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1
--enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug
--enable-mpfr --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
 /usr/lib/gcc/i486-linux-gnu/4.1.3/collect2 --eh-frame-hdr -m elf_i386
 --hash-style=both -dynamic-linker /lib/ld-linux.so.2 -o a.out -u
 base_GHCziBase_Izh_static_info -u base_GHCziBase_Czh_static_info -u
 base_GHCziFloat_Fzh_static_info -u base_GHCziFloat_Dzh_static_info -u
 base_GHCziPtr_Ptr_static_info -u base_GHCziWord_Wzh_static_info -u
 base_GHCziInt_I8zh_static_info -u base_GHCziInt_I16zh_static_info -u
 base_GHCziInt_I32zh_static_info -u base_GHCziInt_I64zh_static_info -u
 base_GHCziWord_W8zh_static_info -u base_GHCziWord_W16zh_static_info -u
 base_GHCziWord_W32zh_static_info -u base_GHCziWord_W64zh_static_info -u
 base_GHCziStable_StablePtr_static_info -u base_GHCziBase_Izh_con_info
 -u base_GHCziBase_Czh_con_info -u base_GHCziFloat_Fzh_con_info -u
 base_GHCziFloat_Dzh_con_info -u base_GHCziPtr_Ptr_con_info -u
 

Re: [Haskell-cafe] System.IO.UTF8 Problem

2008-12-01 Thread Brandon S. Allbery KF8NH

On 2008 Dec 2, at 0:38, Ben George wrote:

$ghc file.hs
compilation IS NOT required
byteindex.o: In function `sKE_info':
(.text+0x8bf): undefined reference to
`__stginit_utf8zmstringzm0zi3zi3_SystemziIOziUTF8_'
collect2: ld returned 1 exit status



Use ghc --make so it looks up the dependencies for System.IO.UTF8  
automatically.  Otherwise you need to add them explicitly with - 
package arguments.


--
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] serious defect in system-uuid

2008-12-01 Thread Jason Dusek
  I discovered that my UUID type causes a loop when tested
  for equality. Anyone who is using `system-uuid`, please
  upgrade to version 1.0.2.

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


[Haskell-cafe] Compatible problem with GHC 6.10.1

2008-12-01 Thread Andy Stewart
Hi all,

I use Debian and GHC 6.8.2-7
Have install cabal, xmonad, gtk2hs with GHC 6.8.2-7

But when upgrade to GHC 6.10.1, i failed to install XMonad 0.8 and gtk2hs 0.9.13
I heard someone install success with develop version.
So anyone success install XMonad and gtk2hs with GHC 6.10.1?

BTW, i want to know the details compatible problem between 6.8 with 6.10?
Is most libraries have compatible with GHC 6.10.1?

Any suggestions?

Thanks.

  -- Andy

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


Re: [Haskell-cafe] Compatible problem with GHC 6.10.1

2008-12-01 Thread Brandon S. Allbery KF8NH

On 2008 Dec 2, at 1:50, Andy Stewart wrote:
BTW, i want to know the details compatible problem between 6.8 with  
6.10?

Is most libraries have compatible with GHC 6.10.1?



The compatibility issue is mainly that GHC 6.10 ships with base-4.0,  
which as with past major revisions is not compatible with earlier  
major versions.  There are some tricks that can be used to make cabal- 
based packages use the compatibility base-3 package included; see the  
wiki page http://www.haskell.org/haskellwiki/Upgrading_packages for  
details.


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


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


Re: [Haskell-cafe] Compatible problem with GHC 6.10.1

2008-12-01 Thread Colin Paul Adams
 Andy == Andy Stewart [EMAIL PROTECTED] writes:

Andy But when upgrade to GHC 6.10.1, i failed to install XMonad
Andy 0.8 and gtk2hs 0.9.13 I heard someone install success with
Andy develop version.  So anyone success install XMonad and
Andy gtk2hs with GHC 6.10.1?

I am using the development version of gtk2hs OK with GHC 6.10.1.
-- 
Colin Adams
Preston Lancashire
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Compatible problem with GHC 6.10.1

2008-12-01 Thread Andy Stewart
Thank you very much.
So anyone install XMonad with GHC 6.10.1 success?

  -- Andy

Colin Paul Adams [EMAIL PROTECTED] writes:

 Andy == Andy Stewart [EMAIL PROTECTED] writes:

 Andy But when upgrade to GHC 6.10.1, i failed to install XMonad
 Andy 0.8 and gtk2hs 0.9.13 I heard someone install success with
 Andy develop version.  So anyone success install XMonad and
 Andy gtk2hs with GHC 6.10.1?

 I am using the development version of gtk2hs OK with GHC 6.10.1.

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


[Haskell-cafe] Re: Compatible problem with GHC 6.10.1

2008-12-01 Thread Andy Stewart
Hi Colin,

Colin Paul Adams [EMAIL PROTECTED] writes:

 Andy == Andy Stewart [EMAIL PROTECTED] writes:

 Andy But when upgrade to GHC 6.10.1, i failed to install XMonad
 Andy 0.8 and gtk2hs 0.9.13 I heard someone install success with
 Andy develop version.  So anyone success install XMonad and
 Andy gtk2hs with GHC 6.10.1?

 I am using the development version of gtk2hs OK with GHC 6.10.1.
When i ./configure gtk2hs souce code, i will got below information:

,
| * The following packages will be built:   
| * 
| * glib  : yes 
| * gtk   : yes 
| * glade : no  
| * cairo : yes 
| * svgcairo  : no  
| * gtkglext  : no  
| * gconf : no 
| * sourceview: no
| * mozembed  : no  
| * soegtk: yes 
| * gnomevfs  : no  
| * gstreamer : no 
| * documentation : no
`

So i want to ask, what libraries need to install for support full
gtk2hs?

Thank you very much!

  -- Andy

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


[Haskell-cafe] What causes loop?

2008-12-01 Thread Martin Hofmann
I am picking up a discussion with the same topic from haskell-users on
8th November.

Thunks with reference on themselves was mentioned as main reason for
loop.

 A safe recursive definition would be
   let x = Foo (x+1)
 However, if you leave out the constructor,
   let x = x + 1
 you get a loop (or a deadlock).
 

Are there any other reasons? 

I am trying to debug monadic code which stores state information in a
record maintaining several Data.Maps, but in vein so far. A state is
modified/changed in several steps by a compound function i.e.

changeA $ changeB $ changeC state

Is code using mtl, records or Maps more prone to loop or does this
not matter at all. How can I identify self-referencing thunks more
easily? Is there any rule of thumb to prevent loop? Are there any
less obvious newbie mistakes causing loop then the one above?

Any comments, experience, and tips are highly appreciated.

Thanks,

Martin

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