Re: [Haskell-cafe] Blocking IO FIFOs

2012-10-21 Thread Donn Cave
From Jason Dusek jason.du...@gmail.com,
...
 If I could somehow arrange to detect EOF when /tmp/exitpipe is
 closed, then I might as well redirect 1 and 2 to FIFOs and wait
 for them to EOF, collecting the output.
 
 However, all of my experiments suggest that there is simply no
 way in Haskell to detect the closing of the write end of a FIFO.
 With `openFileBlocking', one can detect when a FIFO is *opened*;
 but not when it is closed.

It looks to me like our colleague in another followup may have it
working in an example.  I have run into some trouble myself, with
an example program demonstrating the approach I proposed.  With a 
pre-existing named pipe, that I would just keep using, for whatever
reason it worked the first time, failed the second, and so forth,
working every other time.  If the test program created the named
pipe, it failed every time.  There are probably reasons for all this,
but I haven't looked very hard.

That was using withFile.  If I use POSIX I/O, it works fine.
So it looks to me like there is indeed a way in Haskell to detect
a closed FIFO, it just may not be Haskell I/O without a lot more
work ironing out the possible causes of failure.

I believe that doesn't need to be a problem for you, though, because
1) your application is by nature exclusive to POSIX platforms, and
2) you need the named pipe only to detect command process exit, and
you can still apply Haskell I/O to the more interesting data that
accumulates in the command output disk file.

And there may be an answer for my problems with Haskell I/O.  Could
be as simple as using openFileBlocking, which apparently isn't supported
in the ghc I'm using.  Could have something to do with the fine points
of named pipes - for example, I believe you're supposed to open them
O_RDWR in situations you'd think would call for O_READONLY.  (Though
the latter worked for me with POSIX I/O.)

While I'm here ... I share the concern expressed in an earlier followup
about the outputs from bash in runInteractiveProcess.  This looks like
a feature of runInteractiveProcess that makes it intrinsically something
like a code smell.  input-only and output-only processes are commonly
used and fairly tractable, where input-output processes are unusual and
and fragile, so it's an unfortunate convenience.  I think the idea is
that you'd use createProcess specifying only the input redirection.

Donn

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


Re: [Haskell-cafe] Blocking IO FIFOs

2012-10-21 Thread Jason Dusek
2012/10/21 Donn Cave d...@avvanta.com:
 From Jason Dusek jason.du...@gmail.com:
 If I could somehow arrange to detect EOF when /tmp/exitpipe is
 closed, then I might as well redirect 1 and 2 to FIFOs and wait
 for them to EOF, collecting the output.

 However, all of my experiments suggest that there is simply no
 way in Haskell to detect the closing of the write end of a FIFO.
 With `openFileBlocking', one can detect when a FIFO is *opened*;
 but not when it is closed.

 [...] If I use POSIX I/O, it works fine.  So it looks to me
 like there is indeed a way in Haskell to detect a closed FIFO,
 it just may not be Haskell I/O without a lot more work ironing
 out the possible causes of failure.

Sadly, I can not do Posix IO on handles or read a ByteString
from a Posix FD.

 2) you need the named pipe only to detect command process
exit, and you can still apply Haskell I/O to the more
interesting data that accumulates in the command output
disk file.

Writing data to disk for communicating with other processes
is not a good pattern, I think.

 And there may be an answer for my problems with Haskell I/O.
 Could be as simple as using openFileBlocking, which apparently
 isn't supported in the ghc I'm using.  Could have something to
 do with the fine points of named pipes - for example, I
 believe you're supposed to open them O_RDWR in situations
 you'd think would call for O_READONLY.  (Though the latter
 worked for me with POSIX I/O.)

It is okay to open it O_READONLY if blocking when there is no
writer is acceptable. For this application, it is.

 While I'm here ... I share the concern expressed in an earlier
 followup about the outputs from bash in runInteractiveProcess.
 This looks like a feature of runInteractiveProcess that makes
 it intrinsically something like a code smell.  input-only
 and output-only processes are commonly used and fairly
 tractable, where input-output processes are unusual and and
 fragile, so it's an unfortunate convenience.  I think the idea
 is that you'd use createProcess specifying only the input
 redirection.

I am averse to adding just in case code that may not do
anything; too much system level code attains an air of mystery
this way.

--
Jason Dusek
pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B

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


[Haskell-cafe] How do I specify language literals in hsparql?

2012-10-21 Thread Andrew Pennebaker
If the raw SPARQL is rdfs:label D (programming language)@en, what would
the hsparql http://hackage.haskell.org/package/hsparql syntax be?

The docshttps://github.com/robstewart57/hsparql/blob/master/tests/DBPedia.hs
don't
include any language literal examples.

-- 
Cheers,

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


Re: [Haskell-cafe] Blocking IO FIFOs

2012-10-21 Thread Gregory Collins
On Sun, Oct 21, 2012 at 1:25 PM, Jason Dusek jason.du...@gmail.com wrote:

 Sadly, I can not do Posix IO on handles or read a ByteString
 from a Posix FD.


Try the unix-bytestring package.

G
-- 
Gregory Collins g...@gregorycollins.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] serialize an unknown type

2012-10-21 Thread Corentin Dupont
Nobody on this one?
Here is a simplified version:

data Event a where
InputChoice ::  a - Event a

How to serialize/deserialize this?

Cheers,
Corentin

On Sat, Oct 20, 2012 at 10:49 PM, Corentin Dupont corentin.dup...@gmail.com
 wrote:

 Hi the list!
 I have a simple question, how can I serialize/deserialize a structure like
 this:

 data InputChoice c  deriving Typeable
 data Event a where
 InputChoice :: (Eq c, Show c) = [c] - c - Event (InputChoice c)
  (...)

 I'd like that the values of type c get serialized to a String... That's
 the easy part, but for deserializing, oops!

 Cheers,
 Corentin

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


Re: [Haskell-cafe] serialize an unknown type

2012-10-21 Thread Brandon Allbery
On Sun, Oct 21, 2012 at 12:39 PM, Corentin Dupont corentin.dup...@gmail.com
 wrote:

 Nobody on this one?
 Here is a simplified version:

 data Event a where
 InputChoice ::  a - Event a

 How to serialize/deserialize this?


How were you expecting to serialize/deserialize a function?

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix/linux, openafs, kerberos, infrastructure  http://sinenomine.net
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] serialize an unknown type

2012-10-21 Thread MigMit
Seems like nobody really understands what is it that you want to accomplish or 
what your problem is.

Отправлено с iPhone

21.10.2012, в 20:39, Corentin Dupont corentin.dup...@gmail.com написал(а):

 Nobody on this one?
 Here is a simplified version:
 
 data Event a where
 InputChoice ::  a - Event a
 
 How to serialize/deserialize this?
 
 Cheers,
 Corentin
 
 On Sat, Oct 20, 2012 at 10:49 PM, Corentin Dupont corentin.dup...@gmail.com 
 wrote:
 Hi the list!
 I have a simple question, how can I serialize/deserialize a structure like 
 this:
 
 data InputChoice c  deriving Typeable
 data Event a where
 InputChoice :: (Eq c, Show c) = [c] - c - Event (InputChoice c)
  (...)
 
 I'd like that the values of type c get serialized to a String... That's 
 the easy part, but for deserializing, oops!
 
 Cheers,
 Corentin
 
 ___
 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] serialize an unknown type

2012-10-21 Thread Corentin Dupont
Hi,
Sorry if it was not enough explicit.
I want to write functions like this:

serialize :: (Show a) = Event a - IO ()
deserialize :: (Read a) = IO () - Event a

The functions would write and read the data in a file, storing/retrieving
also the type a I suppose...
BR,
C



On Sun, Oct 21, 2012 at 7:03 PM, MigMit miguelim...@yandex.ru wrote:

 Seems like nobody really understands what is it that you want to
 accomplish or what your problem is.

 Отправлено с iPhone

 21.10.2012, в 20:39, Corentin Dupont corentin.dup...@gmail.com
 написал(а):

 Nobody on this one?
 Here is a simplified version:

 data Event a where
 InputChoice ::  a - Event a

 How to serialize/deserialize this?

 Cheers,
 Corentin

 On Sat, Oct 20, 2012 at 10:49 PM, Corentin Dupont 
 corentin.dup...@gmail.com wrote:

 Hi the list!
 I have a simple question, how can I serialize/deserialize a structure
 like this:

 data InputChoice c  deriving Typeable
 data Event a where
 InputChoice :: (Eq c, Show c) = [c] - c - Event (InputChoice c)
  (...)

 I'd like that the values of type c get serialized to a String... That's
 the easy part, but for deserializing, oops!

 Cheers,
 Corentin


 ___
 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] serialize an unknown type

2012-10-21 Thread Iustin Pop
On Sun, Oct 21, 2012 at 07:20:10PM +0200, Corentin Dupont wrote:
 Hi,
 Sorry if it was not enough explicit.
 I want to write functions like this:
 
 serialize :: (Show a) = Event a - IO ()
 deserialize :: (Read a) = IO () - Event a
 
 The functions would write and read the data in a file, storing/retrieving
 also the type a I suppose...

Can't you simply, when defining the type event, add a deriving (Show,
Read)? Then the standard (but slow) read/show serialisation would work
for you.

If you're asking to de-serialise an unknown type (i.e. you don't know
what type it should restore a-priori, but you want to do that based on
the contents of the file), things become a little more complex. Unless
you can further restrict the type 'a', really complex.

Maybe stating your actual problem, rather than the implementation
question, would be better?

regards,
iustin

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


Re: [Haskell-cafe] How do I specify language literals in hsparql?

2012-10-21 Thread Antoine Latter
On Sun, Oct 21, 2012 at 10:41 AM, Andrew Pennebaker
andrew.penneba...@gmail.com wrote:
 If the raw SPARQL is rdfs:label D (programming language)@en, what would
 the hsparql syntax be?

 The docs don't include any language literal examples.


Have you emailed the maintainer of the package? Not all package
authors subscribe to high-traffic lists like haskell-cafe.

Antoine

 --
 Cheers,

 Andrew Pennebaker
 www.yellosoft.us

 ___
 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] serialize an unknown type

2012-10-21 Thread Corentin Dupont
Hi Iustin,
yes I want to deserialize an unknown type based on the content of the file
(in this example).
Let's say I can reduce the spectum of types to: Strings, all the types in
Enum, Ints. Is it possible?

My real problem is that on my web interface I want to use web routes to
allow a user to pass an Event back to the engine.
The problem is that it seems that web-routes only accepts Strings (or some
known types) to be passed on the web route, whereas I need to pass random
types.


On Sun, Oct 21, 2012 at 8:00 PM, Iustin Pop iu...@k1024.org wrote:

 On Sun, Oct 21, 2012 at 07:20:10PM +0200, Corentin Dupont wrote:
  Hi,
  Sorry if it was not enough explicit.
  I want to write functions like this:
 
  serialize :: (Show a) = Event a - IO ()
  deserialize :: (Read a) = IO () - Event a
 
  The functions would write and read the data in a file, storing/retrieving
  also the type a I suppose...

 Can't you simply, when defining the type event, add a deriving (Show,
 Read)? Then the standard (but slow) read/show serialisation would work
 for you.

 If you're asking to de-serialise an unknown type (i.e. you don't know
 what type it should restore a-priori, but you want to do that based on
 the contents of the file), things become a little more complex. Unless
 you can further restrict the type 'a', really complex.

 Maybe stating your actual problem, rather than the implementation
 question, would be better?

 regards,
 iustin

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


Re: [Haskell-cafe] serialize an unknown type

2012-10-21 Thread MigMit
Oh, now I've got it.

First of all, functions of type IO () - Event a are impossible (unless you 
resort to tricks with unsafePerformIO, which is not what you want to deal with 
right now). You've probably meant something like IO (Event a) (at least, that 
is the type of function which would read Event a from file or input stream or 
something else external).

Secondly, functions (and values) with parametric types, like IO (Event a) 
require you to provide the type a in your code. They won't take it from 
somewhere magically. You can take a look at the read function in Prelude for 
example.

If you really want to store the type information and read it back, you should 
do it yourself, inventing some representation for your type, writing it to 
disk, reading back and parsing it. And you can't do that for all types in 
existence, so you'll need to do that for some specific types (and no, instances 
of Typeable aren't what you want). And you'll have to deal with type system, 
which won't allow you to just say hey, let that be whatever type it happens to 
be, I don't care; you'd have to wrap this into one existentially quantified 
type (or GADT).

Keep in mind that this is not very Haskell-y. First of all, try to analyse, 
what this a in Event a could be. What are the limits here? And don't say 
there aren't any, because if you don't know anything about the type, you can't 
do anything with it. So, maybe you would end up with a finite set of types — 
this would simplify matters a lot. Or maybe you'd find out that there are 
inifinitely many types of events — but they can be somehow generated with a 
finite number of constructors — that would be quite simple as well.

So, what is the bigger picture here?

On Oct 21, 2012, at 9:20 PM, Corentin Dupont corentin.dup...@gmail.com wrote:

 Hi,
 Sorry if it was not enough explicit.
 I want to write functions like this:
 
 serialize :: (Show a) = Event a - IO ()
 deserialize :: (Read a) = IO () - Event a
 
 The functions would write and read the data in a file, storing/retrieving 
 also the type a I suppose...
 BR,
 C
 
 
 
 On Sun, Oct 21, 2012 at 7:03 PM, MigMit miguelim...@yandex.ru wrote:
 Seems like nobody really understands what is it that you want to accomplish 
 or what your problem is.
 
 Отправлено с iPhone
 
 21.10.2012, в 20:39, Corentin Dupont corentin.dup...@gmail.com написал(а):
 
 Nobody on this one?
 Here is a simplified version:
 
 data Event a where
 InputChoice ::  a - Event a
 
 How to serialize/deserialize this?
 
 Cheers,
 Corentin
 
 On Sat, Oct 20, 2012 at 10:49 PM, Corentin Dupont 
 corentin.dup...@gmail.com wrote:
 Hi the list!
 I have a simple question, how can I serialize/deserialize a structure like 
 this:
 
 data InputChoice c  deriving Typeable
 data Event a where
 InputChoice :: (Eq c, Show c) = [c] - c - Event (InputChoice c)
  (...)
 
 I'd like that the values of type c get serialized to a String... That's 
 the easy part, but for deserializing, oops!
 
 Cheers,
 Corentin
 
 ___
 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] serialize an unknown type

2012-10-21 Thread Alberto G. Corona
You can include the type in the serialized string. When recovering you can
read the type and use to look for the appropriate deserializer in a lookup
table where you have registered the deserializer.

I use this trick in the IDynamic package,. that serializes-deserializes
dynamic types:

http://hackage.haskell.org/package/IDynamic-0.1


2012/10/20 Corentin Dupont corentin.dup...@gmail.com

 Hi the list!
 I have a simple question, how can I serialize/deserialize a structure like
 this:

 data InputChoice c  deriving Typeable
 data Event a where
 InputChoice :: (Eq c, Show c) = [c] - c - Event (InputChoice c)
  (...)

 I'd like that the values of type c get serialized to a String... That's
 the easy part, but for deserializing, oops!

 Cheers,
 Corentin

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




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


Re: [Haskell-cafe] serialize an unknown type

2012-10-21 Thread Iustin Pop
On Sun, Oct 21, 2012 at 08:11:50PM +0200, Corentin Dupont wrote:
 Hi Iustin,
 yes I want to deserialize an unknown type based on the content of the file
 (in this example).
 Let's say I can reduce the spectum of types to: Strings, all the types in
 Enum, Ints. Is it possible?

Maybe :) I don't know how to do all the types in enum. For Strings,
Ints and Float, you could have something like: serialise a pair instead
of just the type, and decode:

data Event = EventString String | EventInt Int | EventFloat Float
…
  (kind, val) - read in_data
  return $ case kind of
string - EventString val
int - EventInt (read val)
float - EventFloat (read val)

But this is only for a very few specific types.

 My real problem is that on my web interface I want to use web routes to
 allow a user to pass an Event back to the engine.
 The problem is that it seems that web-routes only accepts Strings (or some
 known types) to be passed on the web route, whereas I need to pass random
 types.

Are you sure you need to pass random types? Can't you define a (large)
set of known types, for example?

regards,
iustin

 On Sun, Oct 21, 2012 at 8:00 PM, Iustin Pop iu...@k1024.org wrote:
 
  On Sun, Oct 21, 2012 at 07:20:10PM +0200, Corentin Dupont wrote:
   Hi,
   Sorry if it was not enough explicit.
   I want to write functions like this:
  
   serialize :: (Show a) = Event a - IO ()
   deserialize :: (Read a) = IO () - Event a
  
   The functions would write and read the data in a file, storing/retrieving
   also the type a I suppose...
 
  Can't you simply, when defining the type event, add a deriving (Show,
  Read)? Then the standard (but slow) read/show serialisation would work
  for you.
 
  If you're asking to de-serialise an unknown type (i.e. you don't know
  what type it should restore a-priori, but you want to do that based on
  the contents of the file), things become a little more complex. Unless
  you can further restrict the type 'a', really complex.
 
  Maybe stating your actual problem, rather than the implementation
  question, would be better?
 
  regards,
  iustin
 

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


Re: [Haskell-cafe] serialize an unknown type

2012-10-21 Thread Corentin Dupont
On Sun, Oct 21, 2012 at 8:42 PM, MigMit miguelim...@yandex.ru wrote:

 Oh, now I've got it.

 First of all, functions of type IO () - Event a are impossible (unless
 you resort to tricks with unsafePerformIO, which is not what you want to
 deal with right now). You've probably meant something like IO (Event a)
 (at least, that is the type of function which would read Event a from
 file or input stream or something else external).


Yes, sorry, that's what I meant.



 Secondly, functions (and values) with parametric types, like IO (Event
 a) require you to provide the type a in your code. They won't take it
 from somewhere magically. You can take a look at the read function in
 Prelude for example.

 If you really want to store the type information and read it back, you
 should do it yourself, inventing some representation for your type, writing
 it to disk, reading back and parsing it. And you can't do that for all
 types in existence, so you'll need to do that for some specific types (and
 no, instances of Typeable aren't what you want). And you'll have to deal
 with type system, which won't allow you to just say hey, let that be
 whatever type it happens to be, I don't care; you'd have to wrap this into
 one existentially quantified type (or GADT).

 Keep in mind that this is not very Haskell-y. First of all, try to
 analyse, what this a in Event a could be. What are the limits here? And
 don't say there aren't any, because if you don't know anything about the
 type, you can't do anything with it. So, maybe you would end up with a
 finite set of types -- this would simplify matters a lot. Or maybe you'd
 find out that there are inifinitely many types of events -- but they can be
 somehow generated with a finite number of constructors -- that would be
 quite simple as well.

 So, what is the bigger picture here?



In my application, the user can define the a. That's what makes it
difficult. For example, the user can define a new enumerate and submit it
to the program (it will be interpreted by hint):
data Choice = You | Me  | Them | Everybody deriving (Enum, Typeable, Show,
Eq, Bounded)
So, the list of types is not known in advance.
I could ask my user to make his new type an instance of a class as
suggested by Alberto...




 On Oct 21, 2012, at 9:20 PM, Corentin Dupont corentin.dup...@gmail.com
 wrote:

  Hi,
  Sorry if it was not enough explicit.
  I want to write functions like this:
 
  serialize :: (Show a) = Event a - IO ()
  deserialize :: (Read a) = IO () - Event a
 
  The functions would write and read the data in a file,
 storing/retrieving also the type a I suppose...
  BR,
  C
 
 
 
  On Sun, Oct 21, 2012 at 7:03 PM, MigMit miguelim...@yandex.ru wrote:
  Seems like nobody really understands what is it that you want to
 accomplish or what your problem is.
 
  Отправлено с iPhone
 
  21.10.2012, в 20:39, Corentin Dupont corentin.dup...@gmail.com
 написал(а):
 
  Nobody on this one?
  Here is a simplified version:
 
  data Event a where
  InputChoice ::  a - Event a
 
  How to serialize/deserialize this?
 
  Cheers,
  Corentin
 
  On Sat, Oct 20, 2012 at 10:49 PM, Corentin Dupont 
 corentin.dup...@gmail.com wrote:
  Hi the list!
  I have a simple question, how can I serialize/deserialize a structure
 like this:
 
  data InputChoice c  deriving Typeable
  data Event a where
  InputChoice :: (Eq c, Show c) = [c] - c - Event (InputChoice c)
   (...)
 
  I'd like that the values of type c get serialized to a String...
 That's the easy part, but for deserializing, oops!
 
  Cheers,
  Corentin
 
  ___
  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] ANN: hledger 0.19

2012-10-21 Thread Simon Michael
I'm pleased to announce the release of hledger 0.19! This release has just two 
visible changes: a much faster balance command, and support for the latest GHC 
and libs. (A hledger-web update will follow.)

hledger is a command-line tool and haskell library for tracking financial 
transactions, which are stored in a human-readable plain text format. In 
addition to reporting, it can also help you record new transactions, or convert 
CSV data from your bank. Add-on packages include hledger-web, a web interface. 
hledger is inspired by and compatible with John Wiegley's Ledger. For more, see 
http://hledger.org .

Install it:

cabal update; cabal install hledger . For installation help, see 
http://hledger.org/MANUAL.html#installing . Or, sponsor a ready-to-run binary 
for your platform: http://hledger.org/DOWNLOAD.html .

Release notes:

hledger, hledger-lib: support GHC 7.6 and latest cmdargs, haskeline, split

balance report no longer has an O(n^2) slowdown with large numbers of accounts, 
and is generally more speedy. Benchmark on a 2010 macbook:

+---++--+--++
|   || hledger-0.18 | hledger-0.19 | 
ledger |
+===++==+==++
| -f data/100x100x10.journal balance|| 0.21 | 0.07 |   
0.09 |
| -f data/1000x1000x10.journal   balance||10.13 | 0.47 |   
0.62 |
| -f data/1000x1x10.journal  balance||40.67 | 0.67 |   
1.01 |
| -f data/1x1000x10.journal  balance||15.01 | 3.22 |   
2.36 |
| -f data/1x1000x10.journal  balance aa || 4.77 | 4.40 |   
2.33 |
+---++--+--++
build version is set with CPP instead of cabal-file-th

Release contributors: Simon Michael, Sergei Trofimovich

Release stats: 106 days, 21 commits, 1 end-user fix, 0 end-user features since 
last release

Project stats: 222 unit  functional tests, 7740 lines of code including 
hledger-web, 21 committers___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Solving integer equations in Haskell

2012-10-21 Thread Levent Erkok
On Oct 17, 2012, at 3:35 AM, Justin Paston-Cooper paston.coo...@gmail.com 
wrote:
 Thanks for all the informative replies. SBV seems the simplest solution right 
 now, and speed isn't too much of an issue here. Anything under 20 seconds per 
 solution should be bearable.

I'm happy to announce the SMT based linear equation solver library: 
http://hackage.haskell.org/package/linearEqSolver

You can use it get solutions over Integers only, or over Rationals if so 
needed. Functions are provided to extract one solution, or all possible 
solutions (as a lazy list). The latter variant is useful for underspecified 
systems. 

Regarding performance: SMT solvers are very good at solving such equations, so 
aside from the overhead of calling out to an external program, it should be 
fairly fast. I'd expect no practical instance to come to anywhere near the 20 
second limit you've mentioned. For most practical instances, the process switch 
overhead would dominate computation time, which should be negligible. Let me 
know if you find otherwise. 

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