Re: [Haskell-cafe] Terminology

2010-06-15 Thread Roman Cheplyaka
* Emmanuel Castro emmanuel.cas...@laposte.net [2010-06-15 00:10:09+0200]
 I am looking for the name of the property linking two functions f and g
 when :
 [f(a),f(b),f(c)] = g([a,b,c])
 
 Is there a standard name?
 
 In practice, g is an optimised version of f when working on large
 amount of elements.

Sometimes (particularly in Data Parallel Haskell, but also in other
languages) 'g' is called vectorized version of 'f'.

-- 
Roman I. Cheplyaka :: http://ro-che.info/
Don't let school get in the way of your education. - Mark Twain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-15 Thread Ketil Malde
braver delivera...@gmail.com writes:

 In fact, the tag cafe2, when run on the full dataset, gets stuck at 11
 days, with RAM slowly getting into 50 GB

One tip might be to limit available heap memory by using +RTS -M2G (or
whatever your real memory is).  If (as seems likely) the RAM usage leads to
thrashing (the symptoms being 'top' showing substantially less than 100%
CPU usage, and a less responsive system), limiting heap will cause your
program to fail faster, which is always an advantage when debugging.

Unless you actually expect the working set to be fifty gig, that is.

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


Re: [Haskell-cafe] How to browse code written by others

2010-06-15 Thread Jean-Marie Gaillourdet

On 15.06.2010, at 01:35, Luke Palmer wrote:

 On Mon, Jun 14, 2010 at 2:02 AM, Jean-Marie Gaillourdet
 j...@gaillourdet.net wrote:
 Hello,
 
 On 13.06.2010, at 22:32, Martin Drautzburg wrote:
 
 I need your advice about how to browse code which was written by someone 
 else
 (Paul Hudak's Euterpea, to be precise, apx. 1 LOC). I had set some hopes
 on leksah, and it indeed shows me the interfaces, but I have not yet
 convinced it to show me more than that.
 
 I ran haddock over the sources, and again I could not see more that just
 signatures.
 
 I would be very happy with something like a Smalltalk browser. Something 
 that
 would let me zoom down to the source code, but with search and hyperlink
 capabilities (senders and implementers in Smalltalk).
 
 Anyways, how do you guys do it, i.e. how to you dive into non-trivial 
 foreign
 code?
 
 I use the following tools:
 
 * haddock generated docs with hyperlinked sources
 * MacVim (or just vim) with Claus Reinke's haskellmode-vim, see: 
 http://projects.haskell.org/haskellmode-vim/index.html
  Have a look at the screencasts to see documentation lookup, and code 
 navigation: http://projects.haskell.org/haskellmode-vim/screencasts.html
  Make sure you know how to use tags inside of vim. ghci is able to generate 
 the tagsfiles for you. This allows you to jump to definitions of   
 identifiers.
 
 If you go this route, I will shamelessly promote hothasktags instead
 of ghci.  It generates proper tags for qualified imports.

That sounds interesting. Thanks for the hint.

Regards,
Jean-Marie___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Haddock Problem

2010-06-15 Thread Dominic Steinitz
David Waern david.waern at gmail.com writes:

 I think using --optghc=-package-conf is the correct way to point to
 another package DB, so I'll look into why it doesn't work.

Perhaps another line of attack would be to see why haddock thinks I have 
an E: drive?



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


[Haskell-cafe] Haskell Indonesia

2010-06-15 Thread vipex.id
Hi, I'm new in Haskell  wondering is there Indonesian people using Haskell
here.

Nice meet* you all :)

Regards,
vipex

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


[Haskell-cafe] Accounting Engine in Haskell

2010-06-15 Thread Amiruddin Nagri
My current project is about making an accounting engine that handles all
the journal entries, transactions, portfolios etc. The communication
with the engine is based on simple protocol, the things to be taken
care of in the order are consistency, handling large data(performance) and
availability.

I came across a video lecture by Simon Peyton Jones where he gives an
example from Financial domain (derivatives etc) to explain how haskell is
being used and the advantages provided.

I am interested in knowing if Haskell will be the right fit for my project.
My requirements are transactional nature, which I believe is one of the
strengths of functional programming, also handling large data set and being
available. there is no such requirement for partitioning of data and the
application is going to be centrally hosted on a single server.

AFAIK OCaml and other functional languages are heavily used in financial
domain, some of the reason are same as features I am looking for.
I wanted some insight as to how Haskell is going to help me with my project.
Also there has been some concerns because of lazy evaluation in Haskell and
memory leaks associated with it.
http://jlouisramblings.blogspot.com/2010/04/haskell-vs-erlang-for-bittorent-clients.html

Also, if you have any suggestions of the choice of programming
language, we have been looking into other functional languages like
 Scala and Clojure. But we have not dig deep on the performance
aspects of these languages, if someone can shed a light on the pros-
cons of these languages, it will help us very much to come to a
decision.

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


[Haskell-cafe] Re: [Haskell-beginners] Accounting Engine in Haskell

2010-06-15 Thread Lyndon Maydwell
I don't think I can be of much help with regards to the questions, but
would you be able to post a link to the SPJ lecture?

Thanks :-)

On Tue, Jun 15, 2010 at 4:08 PM, Amiruddin Nagri amir.na...@gmail.com wrote:

 My current project is about making an accounting engine that handles all
 the journal entries, transactions, portfolios etc. The communication
 with the engine is based on simple protocol, the things to be taken
 care of in the order are consistency, handling large data(performance) and
 availability.

 I came across a video lecture by Simon Peyton Jones where he gives an
 example from Financial domain (derivatives etc) to explain how haskell is
 being used and the advantages provided.

 I am interested in knowing if Haskell will be the right fit for my project.
 My requirements are transactional nature, which I believe is one of the
 strengths of functional programming, also handling large data set and being
 available. there is no such requirement for partitioning of data and the
 application is going to be centrally hosted on a single server.

 AFAIK OCaml and other functional languages are heavily used in financial
 domain, some of the reason are same as features I am looking for.
 I wanted some insight as to how Haskell is going to help me with my project.
 Also there has been some concerns because of lazy evaluation in Haskell and
 memory leaks associated with it.
 http://jlouisramblings.blogspot.com/2010/04/haskell-vs-erlang-for-bittorent-clients.html

 Also, if you have any suggestions of the choice of programming
 language, we have been looking into other functional languages like
  Scala and Clojure. But we have not dig deep on the performance
 aspects of these languages, if someone can shed a light on the pros-
 cons of these languages, it will help us very much to come to a
 decision.

 -Regards,
 Amir

 ___
 Beginners mailing list
 beginn...@haskell.org
 http://www.haskell.org/mailman/listinfo/beginners


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


Re: [Haskell-cafe] learning advanced haskell

2010-06-15 Thread Aran Donohue
Thanks for the great responses. My haskell-learning todo list is refreshed
and renewed :)

I would point out, though, that had I followed a Learn when needed
philosophy more broadly I would never have come to Haskell or even
functional programming in general.

Aran

On Mon, Jun 14, 2010 at 12:33 PM, Andrew Coppin andrewcop...@btinternet.com
 wrote:

 John Lato wrote:

 I sort of agree with this, with some very large caveats.



 Well, yes. If you don't know what a feature does, then you won't know that
 it solves the problem you have.

  However, there's a lot to be said for both intellectual curiosity and
 learning for the sake of knowledge. Just because you may never need

 to use a feature doesn't mean you shouldn't be able to understand it.



 There is that. However, in my experience, most of the advanced techniques
 tend to be described in language beyond my comprehension. (And most examples
 seem overly complex - although maybe that's just a reflection of the fact
 that simple problems don't require sophisticated techniques in the first
 place.) Having a specific problem to solve can be quite helpful. Unlike an
 example, you already understand what the problem is, and why it can't easily
 be solved any other way.


 ___
 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: [Haskell-beginners] Accounting Engine in Haskell

2010-06-15 Thread Amiruddin Nagri
It should be somewhere here -
http://www.haskell.org/haskellwiki/Video_presentations

-Amir


On Tue, Jun 15, 2010 at 1:42 PM, Lyndon Maydwell maydw...@gmail.com wrote:

 I don't think I can be of much help with regards to the questions, but
 would you be able to post a link to the SPJ lecture?

 Thanks :-)

 On Tue, Jun 15, 2010 at 4:08 PM, Amiruddin Nagri amir.na...@gmail.com
 wrote:
 
  My current project is about making an accounting engine that handles all
  the journal entries, transactions, portfolios etc. The communication
  with the engine is based on simple protocol, the things to be taken
  care of in the order are consistency, handling large data(performance)
 and
  availability.
 
  I came across a video lecture by Simon Peyton Jones where he gives an
  example from Financial domain (derivatives etc) to explain how haskell is
  being used and the advantages provided.
 
  I am interested in knowing if Haskell will be the right fit for my
 project.
  My requirements are transactional nature, which I believe is one of the
  strengths of functional programming, also handling large data set and
 being
  available. there is no such requirement for partitioning of data and the
  application is going to be centrally hosted on a single server.
 
  AFAIK OCaml and other functional languages are heavily used in financial
  domain, some of the reason are same as features I am looking for.
  I wanted some insight as to how Haskell is going to help me with my
 project.
  Also there has been some concerns because of lazy evaluation in Haskell
 and
  memory leaks associated with it.
 
 http://jlouisramblings.blogspot.com/2010/04/haskell-vs-erlang-for-bittorent-clients.html
 
  Also, if you have any suggestions of the choice of programming
  language, we have been looking into other functional languages like
   Scala and Clojure. But we have not dig deep on the performance
  aspects of these languages, if someone can shed a light on the pros-
  cons of these languages, it will help us very much to come to a
  decision.
 
  -Regards,
  Amir
 
  ___
  Beginners mailing list
  beginn...@haskell.org
  http://www.haskell.org/mailman/listinfo/beginners
 
 

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


Re: [Haskell-cafe] learning advanced haskell

2010-06-15 Thread John Lato
 Message: 7
 Date: Mon, 14 Jun 2010 20:33:30 +0100
 From: Andrew Coppin andrewcop...@btinternet.com
 Subject: Re: [Haskell-cafe] learning advanced haskell
 To: haskell-cafe@haskell.org
 Message-ID: 4c16840a.7060...@btinternet.com
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed

 John Lato wrote:

 However, there's a lot to be said for both intellectual curiosity and
 learning for the sake of knowledge. Just because you may never need
 to use a feature doesn't mean you shouldn't be able to understand it.

 There is that. However, in my experience, most of the advanced
 techniques tend to be described in language beyond my comprehension.
 (And most examples seem overly complex - although maybe that's just a
 reflection of the fact that simple problems don't require sophisticated
 techniques in the first place.) Having a specific problem to solve can
 be quite helpful. Unlike an example, you already understand what the
 problem is, and why it can't easily be solved any other way.

Yes, having a specific problem to solve can be very helpful.  The OP
requested examples of them.  I'd like to see them myself, partially as
a reference but mostly to satisfy my own curiosity.  More examples
please!

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


[Haskell-cafe] Re: [Haskell-beginners] Accounting Engine in Haskell

2010-06-15 Thread Yitzchak Gale
Hi Amir,

Amiruddin Nagri wrote:
 My current project is about making an accounting engine...

Take a look at the related but different project hledger.

http://hackage.haskell.org/package/hledger
http://hackage.haskell.org/package/hledger-lib

 consistency, handling large data(performance) and
 availability...
 I am interested in knowing if Haskell will be the right fit
 for my project.

These things can certainly be achieved, and Haskell is
a great platform for it. Reliability and assurance of correctness
are very important for financial systems, and Haskell is
especially good at providing them together with good
performance.

However, keep in mind that you are undertaking a very
ambitious project. There are a lot of little design decisions
to be made along the way which, if made without a lot of
previous experience in whatever language you are using,
could lead to serious problems later on in a large system
like this.

I recommend:

o Start with a less ambitious version of the project -
  a simpler prototype with less requirements, or components
  that can be developed as a stand-alone and later integrated
  into your larger system.

o Work closely with the community, on the #haskell
  IRC channel and the Haskell Cafe mailing list, to get
  guidance from experienced Haskellers. Share and discuss
  your code as you go along.

(Or, if you select a different language that you are not
very experienced in for developing large high-assurance
commercial systems, do the same with that language's
community.)

 Also there has been some concerns because of lazy evaluation
 in Haskell and memory leaks associated with it.

The possibility for memory and performance leaks in large
systems written in Haskell is no more or less than in any
other mature programming language. As in any language,
it takes experience and care to avoid them as your application
scales up.

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


[Haskell-cafe] Re: Problems with threading?

2010-06-15 Thread Simon Marlow

On 12/06/2010 02:48, Don Stewart wrote:

igouy2:


parallel, regex-posix, regex-pcre are now installed and the current
compile errors are caused by the programs not the absence of required
libraries -

http://shootout.alioth.debian.org/u64q/program.php?test=binarytreeslang=ghcid=2#log

http://shootout.alioth.debian.org/u64q/program.php?test=binarytreeslang=ghcid=3#log

http://shootout.alioth.debian.org/u64q/program.php?test=regexdnalang=ghcid=4#log

http://shootout.alioth.debian.org/u64q/program.php?test=regexdnalang=ghcid=1#log


Great work!

For those keen to help out the Haskell programs, both compile failures
in regexdna and binarytrees are related to the change in how parallel
strategies work, as described here.

 
http://hackage.haskell.org/packages/archive/parallel/2.2.0.1/doc/html/Control-Parallel-Strategies.html


Change rnf to rdeepseq, that should fix it.

Cheers,
Simon

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


[Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-15 Thread Simon Marlow

On 15/06/2010 06:09, braver wrote:

In fact, the tag cafe2, when run on the full dataset, gets stuck at 11
days, with RAM slowly getting into 50 GB; a previous version caused
ghc 6.12.1 to segfault around day 12 -- -debug showing an assert
failure in Storage.c.  ghc 6.10 got stuck at 30 days for good, and
when profiling crashed twice with  a strange closure or a stack
overflow.  So allocation is a problem still.


I'd be happy to help you track this down, but I don't have a machine big 
enough.  Do you have any runs that display a problem with a smaller heap 
( 16GB)?


If the program is apparently hung, try connecting to it with 'gdb 
--pid=pid' and doing 'info thread' and 'where'.  That might give me 
enough clues to find out where the problem is.


Is this with -threaded, BTW?  With residency on that scale, I'd expect 
the parallel GC to help quite a lot.  But obviously getting it to not 
crash/hang is the first priority :)


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


Re: [Haskell-cafe] Mining Twitter data in Haskell and Clojure

2010-06-15 Thread Ron de Bruijn

Op 14-06-10 07:00, braver schreef:

I'm computing a communication graph from Twitter data and then scan it
daily to allocate social capital to nodes behaving  in a good karmic
manner.  The graph is culled from 100 million tweets and has about 3
million nodes. First I wrote the simulation of the 35 days of data in
Clojure and then translated it into Haskell with great help from the
glorious #haskell folks.  I had to add -A5G -K5G to make it work.  It
does 10 days OK hovering at 57 GB of RAM; I include profiling of that
in sc10days.prof.

At first the Haskell executable goes faster than Clojure, not by an
order of magnitude, but by 2-3 times per day simulated.  (Clojure also
fits well in its 32 GB JVM with compressed references.)  However,
Haskell gets stuck after a while, and for good.  Clearly I'm not doing
Haskell optimally here, and would appreciate optimization advice.
Here's the code:

http://github.com/alexy/husky

The data and problem description is in

http://github.com/alexy/husky/blob/master/Haskell-vs-Clojure-Twitter.md

-- also referred from the main README.md.

The main is in sc.hs, and the algorithm is in SocRun.hs.  The original
Clojure is in socrun.clj.  This is a continuation of active Twitter
research and the results will be published, and I'd really like to
make Haskell work at this scale and beyond!  The seq's sprinkled
already did no good.  I ran under ghc 6.10 with -O2 with or without -
fvia-C, with no difference in stallling, and am working to bring 6.12
to bear now.

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

If you just want to optimize it and not compare exactly equal idiomatic code, 
you should stop using functional data structures and use a structure that fits 
your problem (the ST monad has been designed for that in Haskell), because 
compilers do not detect single-threaded usage and rewrite all your code to 
something mutable and thereby avoid O(log n) costs.


In practice it is probably easier to write the whole thing against the parallel 
Boost Graph Library (a C++ library), since that library provides the 
abstractions that you would want. If you go this path, it will probably end up 
being 10-100 times faster.


--

Best Regards,
Ron de Bruijn,

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


Re: [Haskell-cafe] Haskell Indonesia

2010-06-15 Thread leledumbo

I'm one of them :)
Nice to meet you...


vipex.id wrote:
 
 Hi, I'm new in Haskell  wondering is there Indonesian people using
 Haskell
 here.
 
 Nice meet* you all :)
 
 Regards,
 vipex
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 

-- 
View this message in context: 
http://old.nabble.com/Haskell-Indonesia-tp2215p28889986.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Re: Haddock Problem

2010-06-15 Thread David Waern
2010/6/15 Dominic Steinitz domi...@steinitz.org:
 David Waern david.waern at gmail.com writes:

 I think using --optghc=-package-conf is the correct way to point to
 another package DB, so I'll look into why it doesn't work.

 Perhaps another line of attack would be to see why haddock thinks I have
 an E: drive?

Right. However I suspect it's not a problem with Haddock but rather
something to do with the platform.

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


Re: [Haskell-cafe] Terminology

2010-06-15 Thread Bulat Ziganshin
Hello Emmanuel,

Tuesday, June 15, 2010, 2:10:09 AM, you wrote:

 [f(a),f(b),f(c)] = g([a,b,c])

it looks a bit like vectorisation transformation in compilers


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re: [Haskell-cafe] Re: Haddock Problem

2010-06-15 Thread David Waern
2010/6/15 David Waern david.wa...@gmail.com:
 2010/6/15 Dominic Steinitz domi...@steinitz.org:
 David Waern david.waern at gmail.com writes:

 I think using --optghc=-package-conf is the correct way to point to
 another package DB, so I'll look into why it doesn't work.

 Perhaps another line of attack would be to see why haddock thinks I have
 an E: drive?

 Right. However I suspect it's not a problem with Haddock but rather
 something to do with the platform.

Here's something similar:

http://trac.haskell.org/haskell-platform/ticket/119

I tried myself on windows, and haddock --print-ghc-libdir yields:

  E:\ghc\ghc-6.12.1\lib

and I don't have an E: either.

So Haddock seems to be more or less broken on windows in the current platform.

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


Re: [Haskell-cafe] Haddock Problem

2010-06-15 Thread malcolm.wallace
I haven't been following closely, but how did you install haddock? From a binary dist? Is it possible that one of the Windows binary dists has a "baked-in" location for something on the E: drive, which existed on the packager's machine but not on the final installed machine?Regards,
MalcolmOn 15 Jun, 2010,at 08:12 AM, Dominic Steinitz domi...@steinitz.org wrote:David Waern david.waern at gmail.com writes:

 I think using --optghc=-package-conf is the correct way to point to
 another package DB, so I'll look into why it doesn't work.

Perhaps another line of attack would be to see why haddock thinks I have 
an "E:" drive?



___
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] Haddock Problem

2010-06-15 Thread Stephen Tetley
Hello all

I don't know if this helps at all, but for a GHC 6.12.1 installed from
the ghc-installer rather than HP I get:

Cygwin prompt on WinXP...

$ ./haddock.exe --print-ghc-libdir
C:\ghc\ghc-6.12.1\bin\..\lib

There is actually no corresponding *lib* directory, but haddock still
works fine.

Best wishes

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


Re: [Haskell-cafe] Haddock Problem

2010-06-15 Thread Stephen Tetley
On 15 June 2010 15:13, Stephen Tetley stephen.tet...@gmail.com wrote:


 There is actually no corresponding *lib* directory, but haddock still
 works fine.

This is a mistake on my part - I do have a corresponding lib directory
which includes a package.conf.d directory - for GHC-6.12.1 (I was
looking at the directory tree for 6.10.1 when I wrote the last
message).

Apologies.

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


[Haskell-cafe] Different choice operations in a continuation monad

2010-06-15 Thread Sebastian Fischer

Dear Café,

`MonadPlus` instances are usually required to satisfy certain laws,  
among them the monad laws and monoid laws for `mzero` and `mplus`.  
Additionally one may require that  (=f)  is a monoid morphism, that  
is:


mzero = f  =  mzero
(a `mplus` b) = f  =  (a = f) `mplus` (b = f)

The list monad satisfies these additional laws, the `Maybe`-Monad does  
not satisfy the second, distributive, law:


ghci (return False `mplus` return True) = guard :: [()]
[()]
ghci (return False `mplus` return True) = guard :: Maybe ()
Nothing

Instead of the distributive law, the `Maybe` monad satisfies a  
different law:


return x `mplus` a  =  return x

that is, `return` annihilates the `Maybe`-Monad regarding `mplus`.  
This cancellation law is incompatible with the distributive law  
because (together with other laws) it implies that the result of the  
above example expression is `Nothing` whereas the distributive law  
implies that it is `Just ()`.


We can lift the `Maybe` type into a continuation monad:

  newtype CMaybe r a = CMaybe ((a - Maybe r) - Maybe r)
 
  instance Monad (CMaybe r) where
return x= CMaybe (\k - k x)
CMaybe ca = f = CMaybe (\k - ca (\x - let CMaybe cb = f x in  
cb k))

 
  instance MonadPlus (CMaybe r) where
mzero   = CMaybe (\_ - mzero)
CMaybe ca `mplus` CMaybe cb = CMaybe (\k - ca k `mplus` cb k)

Unlike the `Maybe`-monad, the `CMaybe`-monad satisfies the  
distributive law, not the cancellation law.


Can you define an associative operation

orElse :: CMaybe r a - CMaybe r a - CMaybe r a

with identity `mzero` that satisfies the cancellation law?

Cheers,
Sebastian



--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)



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


Re: [Haskell-cafe] Haskell Indonesia

2010-06-15 Thread Max Cantor
Its not indonesia, but the Singapore FP Users is pretty close by.  We aren't 
limited to just Haskell but there are several haskellers in the group.  If 
you'd like to join us, drop an email to: 
singapore-functional-programm...@googlegroups.com

Max
 
On Jun 15, 2010, at 7:11 PM, leledumbo wrote:

 
 I'm one of them :)
 Nice to meet you...
 
 
 vipex.id wrote:
 
 Hi, I'm new in Haskell  wondering is there Indonesian people using
 Haskell
 here.
 
 Nice meet* you all :)
 
 Regards,
 vipex
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
 
 -- 
 View this message in context: 
 http://old.nabble.com/Haskell-Indonesia-tp2215p28889986.html
 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

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


Re: [Haskell-cafe] Re: [Haskell-beginners] Accounting Engine in Haskell

2010-06-15 Thread Max Cantor
I think Haskell would be an excellent choice.  

Several reasons come to mind:

Given the arbitrary complexity of such projects, an EDSL describing book 
entries etc would be a very good fit for the project.  As people have said once 
or twice, Haskell is a great fit for EDSLs
 
If you want to get ambitious and scale this up to a multithreaded, multiuser 
environment, STM would be a very good concurrency model.  This pretty much just 
leaves Haskell or Clojure.

Finally, the type system of haskell is hugely useful to this project.  Jane 
Street Capital (ocaml users and damned good at it) has a programming motto: 
make illegal transactions unrepresentative.  The type systems of Haskell and 
OCaml let you structure this kind of project in a way to catch most of your 
bugs at compile time.

So, I think Haskell is the perfect intersection of EDSL support, Concurrency, 
and powerful, static typing for the project.

Good luck, keep us informed of your progress.

Max
 

On Jun 15, 2010, at 5:34 PM, Yitzchak Gale wrote:

 Hi Amir,
 
 Amiruddin Nagri wrote:
 My current project is about making an accounting engine...
 
 Take a look at the related but different project hledger.
 
 http://hackage.haskell.org/package/hledger
 http://hackage.haskell.org/package/hledger-lib
 
 consistency, handling large data(performance) and
 availability...
 I am interested in knowing if Haskell will be the right fit
 for my project.
 
 These things can certainly be achieved, and Haskell is
 a great platform for it. Reliability and assurance of correctness
 are very important for financial systems, and Haskell is
 especially good at providing them together with good
 performance.
 
 However, keep in mind that you are undertaking a very
 ambitious project. There are a lot of little design decisions
 to be made along the way which, if made without a lot of
 previous experience in whatever language you are using,
 could lead to serious problems later on in a large system
 like this.
 
 I recommend:
 
 o Start with a less ambitious version of the project -
  a simpler prototype with less requirements, or components
  that can be developed as a stand-alone and later integrated
  into your larger system.
 
 o Work closely with the community, on the #haskell
  IRC channel and the Haskell Cafe mailing list, to get
  guidance from experienced Haskellers. Share and discuss
  your code as you go along.
 
 (Or, if you select a different language that you are not
 very experienced in for developing large high-assurance
 commercial systems, do the same with that language's
 community.)
 
 Also there has been some concerns because of lazy evaluation
 in Haskell and memory leaks associated with it.
 
 The possibility for memory and performance leaks in large
 systems written in Haskell is no more or less than in any
 other mature programming language. As in any language,
 it takes experience and care to avoid them as your application
 scales up.
 
 Good luck,
 Yitz
 ___
 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] How to browse code written by others

2010-06-15 Thread Claus Reinke
 ..ghci is able to generate the tagsfiles for you. This allows you to 
jump to definitions of   identifiers.


If you go this route, I will shamelessly promote hothasktags instead
of ghci.  It generates proper tags for qualified imports.


What do you mean by proper here? GHCi has the information
needed to generate more detailed tags, but the tags file format
did not support much more detail last time I checked. 

Tags for explicitly qualified names could be generated (and 
probably should be), though that would interact with the default 
identification of Haskell identifiers in Vim. But if you want to 
resolve imports properly (or at least a bit better, such as adding

import qualified as support, or pointing unqualified uses to
the correct import), you need more support from the tags 
mechanism.


There is a tags file format proposal here:

   http://ctags.sourceforge.net/FORMAT

that does (among other scopes) suggest explicitly file-scoped 
local tags
   
   file:  Static (local) tag, with a scope of the specified file.  
  When the value is empty, {tagfile} is used.


but in Vim 7.2 the help file still says

   http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#tags-file-format

   The only other field currently recognized by Vim is file:
   (with an empty value).  It is used for a static tag.

If Vim somehow started supporting that extended file:scope
format without updating its docs, that would be good to know
(what version of Vim? where is this documented?).

Your suggested use-case for such a feature is interesting, but
we're getting into an area where live calls to a scope resolution 
tool might make more sense. If one is willing to depend on

Vim's Python-binding, one could keep a GHCi session live
in the background, track the current file/module, and use the 
:info -- Defined at output to find the correct definition. 


Btw, GHCi's :browse! gives information on where available
names come from, which can be useful for resolving unqualified
names (which map is that?) in unknown code.

Claus


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


Re: [Haskell-cafe] Different choice operations in a continuation monad

2010-06-15 Thread Holger Siegel
Hi Sebastian,

Am 15.06.2010 um 17:06 schrieb Sebastian Fischer:

 Dear Café,
 
 `MonadPlus` instances are usually required to satisfy certain laws, among 
 them the monad laws and monoid laws for `mzero` and `mplus`. Additionally one 
 may require that  (=f)  is a monoid morphism, that is:
 
mzero = f  =  mzero
(a `mplus` b) = f  =  (a = f) `mplus` (b = f)
 
 The list monad satisfies these additional laws, the `Maybe`-Monad does not 
 satisfy the second, distributive, law:
 
ghci (return False `mplus` return True) = guard :: [()]
[()]
ghci (return False `mplus` return True) = guard :: Maybe ()
Nothing
 
 Instead of the distributive law, the `Maybe` monad satisfies a different law:
 
return x `mplus` a  =  return x
 
 that is, `return` annihilates the `Maybe`-Monad regarding `mplus`. This 
 cancellation law is incompatible with the distributive law because 
 (together with other laws) it implies that the result of the above example 
 expression is `Nothing` whereas the distributive law implies that it is `Just 
 ()`.
 
 We can lift the `Maybe` type into a continuation monad:
 
  newtype CMaybe r a = CMaybe ((a - Maybe r) - Maybe r)
 
  instance Monad (CMaybe r) where
return x= CMaybe (\k - k x)
CMaybe ca = f = CMaybe (\k - ca (\x - let CMaybe cb = f x in cb k))
 
  instance MonadPlus (CMaybe r) where
mzero   = CMaybe (\_ - mzero)
CMaybe ca `mplus` CMaybe cb = CMaybe (\k - ca k `mplus` cb k)
 
 Unlike the `Maybe`-monad, the `CMaybe`-monad satisfies the distributive law, 
 not the cancellation law.
 
 Can you define an associative operation
 
orElse :: CMaybe r a - CMaybe r a - CMaybe r a
 
 with identity `mzero` that satisfies the cancellation law?

No, because that function would need to cancel values of type a, but the 
arguments of type (CMaybe r a) can
only compute values of type r. But you can define

orElse :: CMaybe a a - CMaybe a a - CMaybe r a
CMaybe ca `orElse` CMaybe cb = CMaybe (\k - (ca return `mplus` cb return) = 
k)

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


Re: [Haskell-cafe] Different choice operations in a continuation monad

2010-06-15 Thread Sebastian Fischer

Hello Holger,


Can you define an associative operation

  orElse :: CMaybe r a - CMaybe r a - CMaybe r a

with identity `mzero` that satisfies the cancellation law?


No, because that function would need to cancel values of type a, but  
the arguments of type (CMaybe r a) can only compute values of type r.


I'm afraid, I don't understand.


But you can define

orElse :: CMaybe a a - CMaybe a a - CMaybe r a
CMaybe ca `orElse` CMaybe cb = CMaybe (\k - (ca return `mplus` cb  
return) = k)


Good point.

But with this restricted type `orElse` is less useful. For example,  
one cannot compute


fromCMaybe ((return False `orElse` return True) = guard)

because there, the arguments of `orElse` are of type `CMaybe () Bool`.

Cheers,
Sebastian

P.S.

  fromCMaybe :: CMaybe a a - Maybe a
  fromCMaybe (CMaybe ca) = ca Just


--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)



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


Re: [Haskell-cafe] Different choice operations in a continuation monad

2010-06-15 Thread Sebastian Fischer


On Jun 15, 2010, at 6:11 PM, Sebastian Fischer wrote:


orElse :: CMaybe a a - CMaybe a a - CMaybe r a
CMaybe ca `orElse` CMaybe cb = CMaybe (\k - (ca return `mplus` cb  
return) = k)


Good point.

But with this restricted type `orElse` is less useful. For example,  
one cannot compute


   fromCMaybe ((return False `orElse` return True) = guard)

because there, the arguments of `orElse` are of type `CMaybe () Bool`.


Silly me! It's not the type of the *arguments* which is `CMaybe ()  
Bool` but the type of the *result* of `orElse`, which is perfectly  
possible with your implementation!


The type may be general enough. Interesting twist!

I still don't understand why it is impossible to provide `orElse` with  
the original type. I will think more about the reason you gave.


Sebastian



--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)



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


Re: [Haskell-cafe] Vague: Assembly line process

2010-06-15 Thread Martin Drautzburg
On Tuesday, 15. June 2010 01:40:03 Luke Palmer wrote:
 So hang on, what is the problem?  You have described something like a
 vague model, but what information are you trying to get?  Say,
 perhaps, a set of possible output lists from a given input list?

When I know my supplies I want to know what I can produce. When I know what I 
want to produce I want to know what supplies I need for that. Both kinds of 
questions should be answered by a singe Process thingy.

I want to be able to chain processes and the whole thing should still act like 
a Process.

 Luke

 On Mon, Jun 14, 2010 at 11:16 AM, Martin Drautzburg

 martin.drautzb...@web.de wrote:
  Hello all,
 
  this is a problem which has haunted me for some time. If this is simply
  hillarious, please tell me so. Or it may be some well known unsolvable
  problem...
 
  An assembly process takes inputs and produces outputs. I could say a
  Process is a function
 
  canProduce :: [Input]-[Output]-Bool
 
  which tells me if the outputs can be produced from the inputs
 
  There may be a similar function which tells me if the inputs are
  completely consumed to procude the output.
 
  The inputs do not determine the exact outputs. Think of a Process which
  combines a List of Ints into pairs, such that the input ints are consumed
  and each input Int occurs in only one position in the output. There are
  many ways to do this. Still for any set of input Ints and output pairs I
  could decide if the output can be produced from the input.
 
  Likewise the Input is not determined by the output. There may be lots of
  choices from what I could build my output (buy from different vendors).
 
  When I know more about the inputs and outputs my choices get more and
  more limited. I would like to to pass inputs and/or outputs to
  something and I would like to get a something which is more
  restricted, but still essentially a thing which tells me if the outputs
  can be produced from the inputs.
 
  I just cannot find a way to even THINK about this problem in a reasonable
  general way.
 
  --
  Martin
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe



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


Re: [Haskell-cafe] Vague: Assembly line process

2010-06-15 Thread Steve Schafer
On Tue, 15 Jun 2010 19:23:35 +0200, you wrote:

When I know my supplies I want to know what I can produce. When I know what I 
want to produce I want to know what supplies I need for that. Both kinds of 
questions should be answered by a singe Process thingy.

I want to be able to chain processes and the whole thing should still act like 
a Process.

This is a type of constraint network. If you have access to _Structure
and Interpretation of Computer Programs_, there is a section therein
devoted to constraint networks. See also:

 http://en.wikipedia.org/wiki/Constraint_programming

Note that you need to be able to handle two kinds of chaining:

 compoundContraint = constraint1 AND constraint2
   -- the compound constraint isn't satisfied unless you can satisfy
   -- both primary constraints

 compoundContraint = constraint1 OR constraint2
   -- the compound constraint is satisfied if either of the primary
   -- constraints is satisfied
 
-Steve
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-15 Thread braver
 If you just want to optimize it and not compare exactly equal idiomatic code,
 you should stop using functional data structures and use a structure that fits
 your problem (the ST monad has been designed for that in Haskell), because
 compilers do not detect single-threaded usage and rewrite all your code to
 something mutable and thereby avoid O(log n) costs.

 In practice it is probably easier to write the whole thing against the 
 parallel
 Boost Graph Library (a C++ library), since that library provides the
 abstractions that you would want. If you go this path, it will probably end up
 being 10-100 times faster.

Surely I can rewrite it in C++ or just C and gain speedup, but not
maintainability and ease of prototyping algorithms -- the main reasons
I switched to FP, with added reliability, conciseness, reasonable
syntax bonuses.  It turned out Clojure is quite capable of doing it
well, but has Null Pointer Exceptions and debug data shape by
running annoying to an ML programmer; trying Haskell for speedup is
worth it!  It proves less predictable than expected -- e.g. with OCaml
if it typechecks and runs, it usually runs fast.  The point of this
exercise is to identify typical performance bottlenecks in the domain
and see how they can be avoided.  The jury's still out on this one.

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


Re: [Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-15 Thread Don Stewart
deliverable:
  If you just want to optimize it and not compare exactly equal idiomatic 
  code,
  you should stop using functional data structures and use a structure that 
  fits
  your problem (the ST monad has been designed for that in Haskell), because
  compilers do not detect single-threaded usage and rewrite all your code to
  something mutable and thereby avoid O(log n) costs.
 
  In practice it is probably easier to write the whole thing against the 
  parallel
  Boost Graph Library (a C++ library), since that library provides the
  abstractions that you would want. If you go this path, it will probably end 
  up
  being 10-100 times faster.
 
 Surely I can rewrite it in C++ or just C and gain speedup, but not
 maintainability and ease of prototyping algorithms -- the main reasons
 I switched to FP, with added reliability, conciseness, reasonable
 syntax bonuses.  It turned out Clojure is quite capable of doing it
 well, but has Null Pointer Exceptions and debug data shape by
 running annoying to an ML programmer; trying Haskell for speedup is
 worth it!  It proves less predictable than expected -- e.g. with OCaml
 if it typechecks and runs, it usually runs fast.  The point of this
 exercise is to identify typical performance bottlenecks in the domain
 and see how they can be avoided.  The jury's still out on this one.

Following the algorithm for performance tuning in the previous email
should be enough. Have you obtained heap profiles yet?

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


Re: [Haskell-cafe] Vague: Assembly line process

2010-06-15 Thread Bas van Dijk
On Tue, Jun 15, 2010 at 7:23 PM, Martin Drautzburg
martin.drautzb...@web.de wrote:
 When I know my supplies I want to know what I can produce. When I know what I
 want to produce I want to know what supplies I need for that. Both kinds of
 questions should be answered by a singe Process thingy.

Your Process thingy reminds me of a natural isomorphism:

data Iso a b = Iso { ab :: a - b
   , ba :: b - a
   }

 I want to be able to chain processes and the whole thing should still act like
 a Process.

These isomorphisms can be chained together using the standard Category
method '.':

import qualified Control.Category as C

instance C.Category Iso where
   id = Iso id id
   Iso bc cb . Iso ab ba = Iso (bc . ab) (ba . cb)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-15 Thread braver
On Jun 15, 6:27 am, Simon Marlow marlo...@gmail.com wrote:
 On 15/06/2010 06:09, braver wrote:

  In fact, the tag cafe2, when run on the full dataset, gets stuck at 11
  days, with RAM slowly getting into 50 GB; a previous version caused
  ghc 6.12.1 to segfault around day 12 -- -debug showing an assert
  failure in Storage.c.  ghc 6.10 got stuck at 30 days for good, and
  when profiling crashed twice with  a strange closure or a stack
  overflow.  So allocation is a problem still.

 I'd be happy to help you track this down, but I don't have a machine big
 enough.  Do you have any runs that display a problem with a smaller heap
 ( 16GB)?

 If the program is apparently hung, try connecting to it with 'gdb
 --pid=pid' and doing 'info thread' and 'where'.  That might give me
 enough clues to find out where the problem is.

 Is this with -threaded, BTW?  With residency on that scale, I'd expect
 the parallel GC to help quite a lot.  But obviously getting it to not
 crash/hang is the first priority :)

Simon - thanks for the tips, this is what gdb says when it's stuck at
45 GB when limited with -A5G -M40G:

...
0x004c3c21 in free_mega_group ()
(gdb) info thread
* 1 Thread 0x2b21c1da4dc0 (LWP 10210)  0x004c3c21 in
free_mega_group ()
(gdb) where
#0  0x004c3c21 in free_mega_group ()
#1  0x004c3ff9 in freeChain ()
#2  0x004c5ab0 in GarbageCollect ()
#3  0x004bff96 in scheduleDoGC ()
#4  0x004c0b25 in scheduleWaitThread ()
#5  0x004bea09 in real_main ()
#6  0x004beb17 in hs_main ()
#7  0x0037d5a1d974 in __libc_start_main () from /lib64/libc.so.6
#8  0x00402ca9 in _start ()

I'll also supply heap profiles for small runs shortly.

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


Re: [Haskell-cafe] learning advanced haskell

2010-06-15 Thread Bas van Dijk
On Mon, Jun 14, 2010 at 7:42 AM, Aran Donohue aran.dono...@gmail.com wrote:
 Hints? Tips?

One thing that isn't mentioned yet is to read other peoples programs.

I'm subscribed to the Hackage RSS feed[1]. I tend to read (at least)
the package page of every package that gets uploaded to hackage.
Whenever an interesting package comes a long I dig a little deeper.
First I try to understand what problem the package is trying to solve.
Then I see how the package is structured into modules. Finally when I
notice some interesting module or function I read its documentation
(which unfortunately almost never exists) and source code and try to
understand how and why it is being implemented like it is.

Regards,

Bas

[1] http://hackage.haskell.org/packages/archive/recent.rss
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Different choice operations in a continuation monad

2010-06-15 Thread Heinrich Apfelmus
Sebastian Fischer wrote:
 Holger Siegel wrote: 

 orElse :: CMaybe a a - CMaybe a a - CMaybe r a
 CMaybe ca `orElse` CMaybe cb = CMaybe (\k - (ca return `mplus` cb
 return) = k)
 
 I still don't understand why it is impossible to provide `orElse` with
 the original type. I will think more about the reason you gave.

The reason is that you have chosen the wrong type for your
continuation monad; it should be

  newtype CMaybe a = CMaybe (forall r. (a - Maybe r) - Maybe r)


Personally, I recommend to stop thinking about continuations altogether
and instead use the approach I've outlined in The Operational Monad
Tutorial

  http://apfelmus.nfshost.com/articles/operational-monad.html

to define and think about monads. In particular, performing the
refunctionalization I mentioned in the subsection Connection with the
Continuation Monad shows that the right type should indeed contain a
 forall r .



Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com

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


Re: [Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-15 Thread wren ng thornton

braver wrote:

On Jun 14, 11:40 am, Don Stewart d...@galois.com wrote:

Oh, you'll want insertWith'.

You might also consider bytestring-trie for the Graph, and IntMap for
the AdJList ?


Yeah, I saw jsonb using Trie and thought there's a reason for it.  But
it's very API-poor compared with Map, e.g. there's not even a fold --
should one toListBy first?


I find that surprising. Have you looked in Data.Trie.Convenience? The 
API of Data.Map is rather bloated so I've pushed most of it out of the 
main module in order to clean things up. There are only a small number 
of functions in the Data.Map interface I haven't had a chance to 
implement yet.


For folding, the `foldMap`, `foldr`, and `foldl` functions are provided 
via the Data.Foldable interface. The Data.Traversable class is also 
implemented if you need to make changes to the trie along the way. These 
all give generic folding over the values stored in the trie. If you need 
access to the keys during folding you can use `foldrWithKey`, though it 
has to reconstruct the keys, which doesn't sound good for your use case. 
`toListBy` is a convenience wrapper around `foldrWithKey` which supports 
list fusion, so it has the same advantages and disadvantages compered to 
the Foldable/Traversable functions.


If there's a particular function you still need, let me know and I can 
add an implementation for it.




In terms of optimizing your code, one thing you'll surely want to do is 
to construct an intern table (Trie Int, IntMap ByteString) so that you 
only have to deal with Ints internally rather than ByteStrings. I 
haven't looked at your code yet to see how this would fit in, but it's 
almost always a requisite trick for handling large text corpora.


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


Re: [Haskell-cafe] Terminology

2010-06-15 Thread wren ng thornton

Emmanuel Castro wrote:

I am looking for the name of the property linking two functions f and g
when :
[f(a),f(b),f(c)] = g([a,b,c])

Is there a standard name?


Generally these sorts of things are called homomorphisms. It's a 
terribly general term, but that's the one I've always seen to describe 
that pattern.


It's also a bit like distributivity, though that probably doesn't 
highlight what you're interested in focusing on.


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


Re: [Haskell-cafe] Terminology

2010-06-15 Thread Alexander Solla


On Jun 15, 2010, at 1:42 PM, wren ng thornton wrote:

Generally these sorts of things are called homomorphisms. It's a  
terribly general term, but that's the one I've always seen to  
describe that pattern.


g is a list homomorphism, if you want to get specific.   
Equivalently, it is the list functor induced by f. (A functor is a  
morphism between categories.  Lists form a category, and g is a  
morphism from lists to lists, since it is a homomorphism).  I guess  
you can call the homomorphism characterization the list homomorphism  
induced by f


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


[Haskell-cafe] Announce: hs2dot 0.1.1 - generate graphviz code by analyzing Haskell source code files

2010-06-15 Thread Oscar Finnsson
Hi,

I've just released hs2dot on hackagedb.

It's a small tool that lets you automatically generate graphviz/dot
code that visualize the relations between data types, types and type
classes.

Example usage:

 hs2dot Hack.hs | dot -T pdf -o Hack.pdf

Multiple files can be analyzed together as in

 hs2dot Foo.hs Bar.hs | dot -T png -o FooBar.png

so their data types can point to each other.

Example diagrams generated using h2dot can be found at
http://github.com/finnsson/hs2graphviz/tree/master/Examples/

Examples of real code analyzed:
http://github.com/finnsson/hs2graphviz/raw/master/Examples/Control.pdf
(from hpage)
http://github.com/finnsson/hs2graphviz/raw/master/Examples/Hack.png (from Hack)

Example of mock code analyzed:
http://github.com/finnsson/hs2graphviz/raw/master/Examples/TestCode.pdf
(three files analyzed together)

The tool is still far from complete. Better handling of algebraic data
types and instance declarations are a must. GADTs, data families and
type synonym families are not yet implemented so they wont turn up.

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


[Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-15 Thread braver
Wren -- thanks for the clarification!  Someone said that Foldable on
Trie may not be very efficient -- is that true?

I use ByteString as a node type for the graph; these are Twitter user
names.  Surely it's useful to replace them with Int, which I'll try,
but Clojure works with Java String fine and it simplifies all kinds of
exploratory data mining and debugging to keep it as a String, so I'll
try to get the most mileage from other things before interning.

What's the exact relationship between Trie and Map and their
respective performance?
-- Alexy
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-15 Thread Don Stewart
deliverable:
 Wren -- thanks for the clarification!  Someone said that Foldable on
 Trie may not be very efficient -- is that true?
 
 I use ByteString as a node type for the graph; these are Twitter user
 names.  Surely it's useful to replace them with Int, which I'll try,
 but Clojure works with Java String fine and it simplifies all kinds of
 exploratory data mining and debugging to keep it as a String, so I'll
 try to get the most mileage from other things before interning.

bytestring seems appropriate.

 What's the exact relationship between Trie and Map and their
 respective performance?

Tries specialized to bytestring keys should outperform the generic Map.

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


Re: [Haskell-cafe] Re: Mining Twitter data in Haskell and Clojure

2010-06-15 Thread Daniel Fischer
On Tuesday 15 June 2010 23:26:10, Don Stewart wrote:
 deliverable:
  Wren -- thanks for the clarification!  Someone said that Foldable on
  Trie may not be very efficient -- is that true?
 
  I use ByteString as a node type for the graph; these are Twitter user
  names.  Surely it's useful to replace them with Int, which I'll try,
  but Clojure works with Java String fine and it simplifies all kinds of
  exploratory data mining and debugging to keep it as a String, so I'll
  try to get the most mileage from other things before interning.

 bytestring seems appropriate.

  What's the exact relationship between Trie and Map and their
  respective performance?

 Tries specialized to bytestring keys should outperform the generic Map.


That would be desirable.
I've done some profiling with the sample data, and found that - if we 
subtract the times for loading and saving the graphs - some 35-40% of the 
time is spent looking up ByteStrings in Maps. That's far too much for my 
liking. I'm not sure whether the lookup for e.g. an Int key would be much 
faster, but I suspect it would be.

I've also fiddled a bit with the strictness and removed a bit of 
unnecessary work, reduced the heap usage by ~20%, MUT times by ~15% and GC 
times by ~50% (all for the tests on my box with a measly 1GB RAM).
It's still a far cry from a racehorse, but at least I can now run the 
sample data for the entire 35 days without having my box thrashing madly :)

The result of my endeavours is attached.

Cheers,
Daniel

{-# LANGUAGE BangPatterns #-}


module SocRun (
  UserStats,
  DCaps,
  SGraph(..),
  SocRun(..), socRun, optSocRun
  )
-- TODO exports
where

import Graph
import Data.Ord (comparing)
import Data.List (groupBy,sortBy,foldl1')
import Data.Foldable (foldl')
import Data.Function (on)
import qualified Data.Map as M
import Data.Map ((!))
import Data.List (maximum)
import System.IO
import Debug.Trace
import Data.Maybe
import Control.Monad ((=))
--import Data.Nthable -- generalized fst
--import Prelude hiding (fst,snd)

-- errln x =
--   hPrint stderr x
--   hFlush stderr

type DCaps = M.Map User (M.Map Day Float)
type TalkBalance = M.Map User Int

emptyTalk :: TalkBalance
emptyTalk = M.empty

data UserStats = UserStats {
socUS  :: !Float,
dayUS  :: !Int,
insUS  :: TalkBalance,
outsUS :: TalkBalance,
totUS  :: TalkBalance,
balUS  :: TalkBalance}

newUserStats :: Float - Int - UserStats
newUserStats soc day = UserStats {socUS = soc, dayUS = day,
  insUS = emptyTalk, outsUS = emptyTalk, totUS = emptyTalk, balUS = emptyTalk}

type UStats = M.Map User UserStats
data SocRun = SocRun {alphaSR :: !Float, betaSR :: !Float, gammaSR :: !Float,
  socInitSR :: !Float, maxDaysSR :: Maybe Int}
optSocRun = SocRun 0.1 0.5 0.5 1.0 Nothing

data SGraph = SGraph {drepsSG :: !Graph, dmentsSG :: !Graph, dcapsSG :: !DCaps, ustatsSG :: !UStats}

paramSC (SocRun {alphaSR =a, betaSR =b, gammaSR =g}) = (a, b, g)

minMax1 (oldMin, oldMax) x =
  let !newMin = oldMin `min` x
  !newMax = oldMax `max` x in
  (newMin, newMax)

minMax2 (oldMin, oldMax) (x,y) =
  let !newMin = oldMin `min` x
  !newMax = oldMax `max` y in
  (newMin, newMax)

-- find the day range when each user exists in dreps
-- PRE: dreps must be sorted in adjacency lists by day!
-- (assert (reps-sorted1? dreps))

dayRanges :: Graph - M.Map User (Int, Int)
dayRanges dreps = M.map doDays dreps
  where
doDays days = case fst $ M.findMin days of
!f - case fst $ M.findMax days of
!l - (f, l)
--   let (!start, _) = M.elemAt 0 days -- i.e. any map entry
--   range@(!f,!l) = foldl' minMax1 (start, start) (M.keys days) in
--   range

-- merge two day-ranges results
-- mergeDayRanges dr1 dr2 = M.unionWith min_max dr1 dr2

-- socRun :: Graph - Graph - SocRun - IO ()
socRun dreps dments opts =
let
  params  = paramSC opts
  socInit = socInitSR opts
  dcaps   = M.empty -- TODO type
  ustats  = M.empty -- type
  sgraph  = SGraph dreps dments dcaps ustats
  presMap = M.unionWith minMax2 (dayRanges dreps) (dayRanges dments)
  !l0 = snd . snd $ M.findMax presMap
  (!lastDay0, !dstarts) = foldl' updt (l0, M.empty) (M.assocs presMap)
  updt (!ld, !m) (u,(f,l)) = (max ld l, M.insertWith' (++) f [u] m)
  !firstDay = fst $ M.findMin dstarts
  !lastDay  = let x' = maybe lastDay0 (\y - min lastDay0 (firstDay + y - 1)) (maxDaysSR opts)
  			  in
trace (doing days from  ++ (show firstDay) ++  to  ++ (show x'))
x'


  tick sgraph day =
  -- inject the users first appearing in this cycle
let
  nus   = newUserStats socInit day
  !ustats= ustatsSG sgraph
  newUsers  = let x = dstarts ! day in
trace (adding  ++ (show . length $ x) ++  new users on day  ++ (show day))
x
  !ustats' = foldl' insn 

Re: [Haskell-cafe] Announce: hs2dot 0.1.1 - generate graphviz code by analyzing Haskell source code files

2010-06-15 Thread Ivan Lazar Miljenovic
Oscar Finnsson oscar.finns...@gmail.com writes:

 Hi,

 I've just released hs2dot on hackagedb.

 It's a small tool that lets you automatically generate graphviz/dot
 code that visualize the relations between data types, types and type
 classes.

This sounds very familiar to my SourceGraph package that's already on
Hackage...

You, however, also add the type signatures to your graph; I have the
sneaking suspicion that this could get too noisy if you also try to
visualise functions in a large module.

 The tool is still far from complete. Better handling of algebraic data
 types and instance declarations are a must. GADTs, data families and
 type synonym families are not yet implemented so they wont turn up.

I, too, still haven't worked out how to deal with GADTs, etc. in my call
graphs.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell Indonesia

2010-06-15 Thread Ivan Lazar Miljenovic
Max Cantor mxcan...@gmail.com writes:

 Its not indonesia, but the Singapore FP Users is pretty close by.
 [snip]

Fine, if we're going to start promoting non-Indonesian Haskell
groups/events, I give you AusHack:
http://www.haskell.org/haskellwiki/AusHac2010

(It was about time for more promotion for this; it's starting in a
months time!!!)

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] What is Haskell unsuitable for?

2010-06-15 Thread aditya siram
Hi all,
Haskell is a great language and in a lot of ways it still hasn't found a
niche, but that's part of what is great about it.

But I wanted to ask people are more experienced with Haskell - what kinds of
problems is it unsuited for? Have you ever regretted using it for something?
Meaning if you could write the program over you would do it in another
language.

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


Re: [Haskell-cafe] What is Haskell unsuitable for?

2010-06-15 Thread Marc Weber
Hi Aditya Siram,

- maybe shell scripting: running ghci takes longer than starting bash.
  Compiling is not always an option because executables are bigger than
  shell scripts or C executables

Haskell could be the wrong choice if

- an existing solution exists which does the job and you know you're not
  going to patch the source ( eg OpenOffice or Linux kernel, or simple
  build scripts. There is already make etc )

- want to run your app on targets which are not supported by Haskell or
  not supported too well. This includes Client scripting on browsers.
  I also think selling web apps which should run everywhere. If people
  read PHP they know how to install it. If they read Haskell I doubt.
  So if you want to sell apps to average mainstream custsomers Haskell
  can be a bad choice.

- you want to collaborate with people who don't know the language

I think you should go the other way round: Pick a task and ask which is
the best tool to get the job done.

But I think those items are obvious. Of course this is my point of view.

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


[Haskell-cafe] Re: What is Haskell unsuitable for?

2010-06-15 Thread Maciej Piechotka
On Tue, 2010-06-15 at 19:47 -0400, aditya siram wrote:
 Hi all,
 Haskell is a great language and in a lot of ways it still hasn't found
 a niche, but that's part of what is great about it. 
 
 But I wanted to ask people are more experienced with Haskell - what
 kinds of problems is it unsuited for? Have you ever regretted using it
 for something? Meaning if you could write the program over you would
 do it in another language.
 
 thanks ...
 -deech
 

1. Glueing a few highier level, object-oriented libraries if it is just
glueing.

2. (Currently) AFAIK real-time applications although it is rather
property of GHC GC then the language itself

Regards


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is Haskell unsuitable for?

2010-06-15 Thread Roman Cheplyaka
* aditya siram aditya.si...@gmail.com [2010-06-15 19:47:37-0400]
 Hi all,
 Haskell is a great language and in a lot of ways it still hasn't found a
 niche, but that's part of what is great about it.
 
 But I wanted to ask people are more experienced with Haskell - what kinds of
 problems is it unsuited for? Have you ever regretted using it for something?
 Meaning if you could write the program over you would do it in another
 language.

This topic was already discussed on this list, you might want to search
the archives.

-- 
Roman I. Cheplyaka :: http://ro-che.info/
Don't let school get in the way of your education. - Mark Twain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is Haskell unsuitable for?

2010-06-15 Thread Ivan Miljenovic
On 16 June 2010 15:45, Roman Cheplyaka r...@ro-che.info wrote:
 * aditya siram aditya.si...@gmail.com [2010-06-15 19:47:37-0400]
 Hi all,
 Haskell is a great language and in a lot of ways it still hasn't found a
 niche, but that's part of what is great about it.

 But I wanted to ask people are more experienced with Haskell - what kinds of
 problems is it unsuited for? Have you ever regretted using it for something?
 Meaning if you could write the program over you would do it in another
 language.

 This topic was already discussed on this list, you might want to search
 the archives.

Spoilsport! :p

Next you'll say there's no need for anyone to ask whether they prefer
vi or emacs... ;-)

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe