News aggregator

I/O is pure

Haskell on Reddit - Sat, 02/09/2013 - 10:39am
Categories: Incoming News

CoArbitrary

haskell-cafe - Sat, 02/09/2013 - 9:07am
Hello, In the QuickCheck library, there is a type-class called CoArbitrary. It is defined like so: class CoArbitrary a where coarbitrary :: a -> Gen b -> Gen b -- Gen is a monad Its purpose is to allow generation of functions. In other words, for taking Gen x -> Gen (a -> x), which could be done rather degenerately (fmap const) but QuickCheck constrains with (CoArbitrary a) to perturb the resulting value instead of ignoring (const) it. It has always puzzled me in the general sense of thinking about the scenario: f x -> f (a -> x) and whether the CoArbitrary is a good/general solution, perhaps for the specific case of f=Gen or maybe even more generally.
Categories: Offsite Discussion

More stable basic libraries?

Haskell on Reddit - Sat, 02/09/2013 - 9:03am

I would like to see a companion to http://hackage.haskell.org/package/haskell2010 that does a similar thing with package imports to pull in all the parts of base which are not covered by the haskell2010 module. (Actually, I would like to see base split into multiple packages, but that's more radical.) This would allow coding primarily against the stable haskel2010 API for the really important modules, without losing access to operations defined in the many other modules in base which would allow for more stability across GHC releases (since the API in haskell2010 does not get broken).

submitted by singpolyma
[link] [1 comment]
Categories: Incoming News

Can anyone provide a little direction for a Graph API?

Haskell on Reddit - Sat, 02/09/2013 - 1:45am

Hello everyone,

I'm in my third year of computer science at university, and I realized that I do not know how to implement and manipulate graphs as well as I should, so I decided to remedy that by writing my own little graph library and implementing some common graph algorithms.

I have found that designing a nice API for graphs is harder than I thought. I'd love if someone could either point me to a common API or provide guidance as to which functions I need to define.

I've decided to start by defining my own graph type:

data Graph v w = Graph { vertices :: [v], edges :: [(v, v, w)] }

Where v is the type of the vertices (is there a difference between vertex and node by the way?) and w is the type of the weight on the edges. For now, I'm not super concerned about efficiency, I'll get to alternative representations later. Here are some of my questions about the API:

  • When inserting an already existing vertex into the graph, would it be better to signal it by either returning Maybe (Graph v w) or by raising an exception, or should I just return the graph as is?
  • Same question for edges; if there is already an edge from a to b with a weight w, should adding an edge from a to b with a weight u raise an error, replace the weight, or do I just ignore that new edge?
  • What if I insert an edge from a to b, but either of those vertices are not in the vertices list? Do I add them and add the edge or raise an error?

Thanks for the help.

submitted by gnuvince
[link] [12 comments]
Categories: Incoming News

xml conduit

haskell-cafe - Sat, 02/09/2013 - 1:31am
Hi, Is there a nice way to update xml. I want to be able to use xml-conduit to find a location in the xml and then add/update that node. eg xpath from //d/e/f and then change the content at 'f' or add a new node <a> ... <d> <e> <f>some data to change </f> </e> </d> ... </a> Thanks for any help, Grant
Categories: Offsite Discussion

Hello

Haskell on Reddit - Sat, 02/09/2013 - 12:35am

I am just introducing myself here and just want to say hi. I am hobbyist and what not......cheers

submitted by tertl3
[link] [1 comment]
Categories: Incoming News

performance question

haskell-cafe - Fri, 02/08/2013 - 9:26pm
Hi list, I wrote a script that reads matrix elements from standard input, parses the input using a regular expression, and then bins the matrix elements by magnitude. I wrote the same script in python (just to be sure :) ) and find that the python version vastly outperforms the Haskell script. To be concrete: $ time ./createMatrixDump.py -N 128 | ./printMatrixDecay real 0m2.655s user 0m2.677s sys 0m0.095s $ time ./createMatrixDump.py -N 128 | ./printMatrixDecay.py - real 0m0.445s user 0m0.615s sys 0m0.032s The Haskell script was compiled with "ghc --make printMatrixDecay.hs". Could you have a look at the script and give me some pointers as to where I could improve it, both in terms of performance and also generally, as I am very new to Haskell. Thanks already, nick _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

ICFP 2013: Call for papers

haskell-cafe - Fri, 02/08/2013 - 9:01pm
===================================================================== 18th ACM SIGPLAN International Conference on Functional Programming ICFP 2013 Boston, MA, USA, 25-27 September 2013 http://www.icfpconference.org/icfp2013 ===================================================================== Important Dates ~~~~~~~~~~~~~~~ Submissions due: Thursday, 28 March 2013 23:59 UTC-11 (Pago Pago, American Samoa, time) Author response: Wednesday, 22 May 0:00 UTC-11 Friday, 24 May 2013 23:59 UTC-11 Notification: Friday, 7 June 2013 Final copy due: Friday, 5 July 2013 Scope ~~~~~ ICFP 2013 seeks original papers on the art and science of functional programming. Submissions are invited on all topics from principles to practice, from foundations to features, and from abstraction to application. The scope includes all languages that encourage functional programming, including both purely applicative and imperative languages,
Categories: Offsite Discussion

ICFP 2013: Call for papers

General haskell list - Fri, 02/08/2013 - 9:01pm
===================================================================== 18th ACM SIGPLAN International Conference on Functional Programming ICFP 2013 Boston, MA, USA, 25-27 September 2013 http://www.icfpconference.org/icfp2013 ===================================================================== Important Dates ~~~~~~~~~~~~~~~ Submissions due: Thursday, 28 March 2013 23:59 UTC-11 (Pago Pago, American Samoa, time) Author response: Wednesday, 22 May 0:00 UTC-11 Friday, 24 May 2013 23:59 UTC-11 Notification: Friday, 7 June 2013 Final copy due: Friday, 5 July 2013 Scope ~~~~~ ICFP 2013 seeks original papers on the art and science of functional programming. Submissions are invited on all topics from principles to practice, from foundations to features, and from abstraction to application. The scope includes all languages that encourage functional programming, including both purely applicative and imperative languages,
Categories: Incoming News

cabal-dev add-source

haskell-cafe - Fri, 02/08/2013 - 4:21pm
Hello, I'm trying to understand cabal-dev, and I seem to be missing some basic point, because I can't get dependencies between projects working properly. I have two projects, let's call them P1 and P2. P2 depends on P1, as indicated by its cabal file build-depends field. I run cabal-dev add-source ..\P1 inside P2 then cabal-dev install Everything works fine, and my project compiles, with modules in P2 calling functions from P1. Then I add a new function if an exposed module of P1. I rerun the cabal-dev add-source and cabal-dev install commands to tell P2 of the change, as per the cabal-dev documentation. I change a file in P2 to use the new function, the compilation fails. If I check into the cabal-dev folder, I see the .hi file for my changed module has not been updated (old date). What am I missing? Thanks
Categories: Offsite Discussion

language-puppet: The hsfacter package

Planet Haskell - Fri, 02/08/2013 - 3:23pm

This blog post is not about language-puppet, but might be of interest to my fellow sysadmins with an interest in Haskell. I recently worked with Logstash in a way that might not be typical, as all my messages are emitted by services that are Logstash-aware: they directly write JSON messages to the TCP input of the Logstash server. This means that most of the features (and some would say, the whole point) of Logstash were of no use to me.

I stuck with my grand mission of rewriting the handful of useful Ruby programs, and wrote a new package. I based almost everything around the excellent conduit abstraction. It has the following features:

  • Haskell types for representing Logstash messages, along with the type-classes necessary for converting them from and to JSON
  • An ElasticSearch conduit, using the bulk insert API
  • A Redis source using the pipelining features of the hedis package, and a simple Redis sink
  • A Logstash listener, based on the TCP listener from network-conduit, able to accept latin1 and UTF-8 messages at the same time
  • A pair of “retrying” sinks, one using a Socket and the other establishing TCP connections. They are used for garanteed delivery of a whole ByteString segment, retrying to connect until it is sent (this is obviously useful for JSON messages)
  • A few functions for handling bulk APIs in Conduits
  • And finally, the coolest part, a few helper functions that will let you route between conduits !

The last part was made after a little discussion on the Haskell-Cafe mailing list. It is built with with stm-conduit, which already has a helper function for merging sources. This package introduces the other useful functionnality: the ability to “route” items coming from a source to several sinks. The main function, branchConduits, works by taking a Source, a routing function, and a Sink list. The routing function associates a (possibly empty) list of integers to every item coming from the Source. These integers directly map to the corresponding Sink, letting you define the routing policy.

The package includes a few examples of common tasks, all of them with acceptable runtime performance, such as :

  • Moving messages from a TCP server to Redis
  • Moving messages from Redis to Elasticsearch
  • Routing messages between conduits

So if you need more control, or much better performance, than what you would get from Logstash, and you are not afraid to write (a lot of) code, please use this package and let me know what is missing and/or buggy!

Categories: Offsite Blogs