News aggregator

ANN: patch-image

General haskell list - Mon, 09/15/2014 - 6:11pm
Right after the announcement of the latest version of Accelerate I like to announce an application build using that framework: "patch-image" assembles a big image from several overlapping parts. http://hackage.haskell.org/package/patch-image Now, let me extract the beginning of the docs: Compose a collage from overlapping image parts. In contrast to Hugin, this is not intended for creating panoramas from multiple photographies, but instead is specialised to creating highly accurate reconstructions of flat but big image sources, like record covers, posters or newspapers. It solves the problem that your scanner may be too small to capture a certain image as a whole. . This is the workflow: Scan parts of an image that considerably overlap. They must all be approximately oriented correctly. The program uses the overlapping areas for reconstruction of the layout of the parts. If all parts are in the directory < at >part< at > then in the best case you can simply run: .
Categories: Incoming News

[ANN] accelerate-0.15

haskell-cafe - Mon, 09/15/2014 - 3:04pm
Friends, I am pleased to announce the release of the Accelerate 0.15 family of packages. Accelerate defines an embedded language of array computations for high performance computing in Haskell. Computations on multi-dimensional, regular arrays are expressed in the form of parameterised collective operations, such as maps, reductions, and permutations. These computations may then be online compiled and executed on a range of architectures, such as GPUs. This release brings mainly bug fixes and performance improvements. The following packages are available on Hackage: accelerateThe language definition and reference implementation accelerate-cudaA high performance parallel backend targeting NVIDIA GPUs accelerate-ioFast conversion between Accelerate arrays and other formats, including ‘vector’ and ‘repa’. accelerate-fftDiscrete Fourier transforms, backed by CUFFT where available accelerate-examplesComputational kernels and applications showcasing Accelerate The code can be found on G
Categories: Offsite Discussion

I liked "Object Oriented Programming versus Abstract Data Types", what to read next?

Haskell on Reddit - Mon, 09/15/2014 - 2:47pm

I liked the paper in the title a lot, and would like to follow up and read something that built on top of those ideas. What would you suggest? Cheers

submitted by liberalogica
[link] [4 comments]
Categories: Incoming News

Netwire 5 - Pong and Experiences

Haskell on Reddit - Mon, 09/15/2014 - 2:25pm

Some of you might remember my first post regarding Netwire on the subject. I finished writing my second blog post on the subject. This time about my experiences writing Pong using Netwire.

Here's the blog post, and as per usual it's all on GitHub.

Any sort of constructive comments / suggestions / criticisms are more than welcome!

submitted by crockeo
[link] [8 comments]
Categories: Incoming News

Using cabal repl with tests

haskell-cafe - Mon, 09/15/2014 - 2:08pm
Hello, I have a classical project with cabal file split between a library, an executable and a test-suite. When I run `cabal repl` I got all modules from the library loaded, which is somewhat logical. I would like to launch a repl with test modules loaded, how can I achieve this? Adding `--enable-tests` does not help for the repl... Thanks, -- Arnaud Bailly FoldLabs Associate: http://foldlabs.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Robert Harper: Scotland: Vote No

Planet Haskell - Mon, 09/15/2014 - 10:05am

So far I’ve ignored the back and forth on the Scottish referendum on secession from the United Kingdom, but this weekend I decided that it was past time for me to sort it out.  For those of you who don’t know me, I’ll mention that I lived for 3.5 years in Scotland quite some time ago, so I am not completely ignorant of the cultural and political issues that underly the debate.  As a rule my political views are very much in line with those of the average Scot, solidly Labour Party back in the day when people like Derek Hatton and Ken Livingston and Roy Hattersley and Tony Benn defined what that meant.  Despite Tony Blair’s slimy “third way” nonsense, and his toadying up to Dick “Dick” Cheney’s sock puppet to help lie us into the Iraq war, Scotland in national politics remains solidly Labour; practically every Scottish seat is a Labour seat.

Although I used to be a so up on British politics that I could read and enjoy Private Eye, it’s been a long while since I’ve paid more than scant attention to what’s been going on there, apart from noting that The Scotsman was one of the few sources of truth about the Iraq War back when it really mattered.  The Scots have spines.

I’m no historian, but I do have basic understanding of Scottish history, particularly as regards the English, and am very familiar with the Scottish concept of valor in glorious defeat.  I understand full well that practically every Scotsman harbors some resentment towards the English for centuries of injustices, including the highland clearances, and, more recently, the appropriation of the oil in Scottish territory for the scant benefit of the Scots themselves.  And I am well aware of the bravery and sacrifice that so many Scots made fighting against the Axis during World War II.

My home institution, Carnegie Mellon University, was founded by a Scotsman from Kirkaldy, just across the spectacular Forth Bridge from Edinburgh.  Carnegie was born into penury and died as the wealthiest man on earth, far wealthier relative to GDP than Gates by a wide margin.  Carnegie was extraordinary, but the Scots in general punch far above their weight class in all things, especially industrious self-reliance.

In short, I love Scotland, and consider it to be a second home.  (OK, the weather is appalling, but we’ll set that aside for the time being.)

Emotionally, I am deeply sympathetic to the Scottish independence movement.  I know full well how poorly the U.K. treats Scotland and its interests.  Politics in the UK revolves around the “home counties” in the south of England; the terminology tells you all you need to know.  One time while watching the weather report on the BBC, the national broadcasting network, the announcer said that there was some horrendous weather coming our way, but that “it’ll mostly be up in Scotland, though”.  Though.  Though.

But I urge all my Scottish friends to vote NO on the independence proposal.  It makes no sense whatsoever in its present form, and represents to me a huge scam being perpetrated by the SNP to seize power and impose policies that nearly every Scot, judging from their voting record over decades and decades, would oppose.  The whole movement seems driven by the powerful urge to finally stick it to the English and get their country back, and Salmond is exploiting that to the hilt.  Back when I lived in Scotland I looked into the SNP, because even then I had separatist sympathies, but when I did, it was obvious why they had so few backers.  They’re just Tories without the class structure, more akin to our Tea Party lunatics than to the British Conservatives, and steadfastly opposed to policies, such as well-funded public education, that nearly all Scots support, and determined to follow the post-cold war Slovakian model of slashing taxes on the wealthy in the hope of attracting business to the country.  Having not followed Scottish politics for so long, it is astonishing to me that the SNP has managed to gain a majority in the Scottish Parliament, while the voting pattern at the national level has not changed at all.  How did this happen?  From my position of ignorance of the last decade or so of politics in Scotland, it looks as though Salmond is a slick operator who has pulled off a colossal con by exploiting the nationalist tendencies that lie within every Scot.

But never mind Salmond, the main reason that Scots must vote NO on the referendum is that it proposes to keep the English pound as Scotland’s national currency!  This is such a preposterous idea that I can only suspect dishonesty and deceit, because no sane political leader of honest intent could ever voluntarily place his or her country’s economic future in the hands of another.  The Bank of England will, particularly after separation, have no interest whatsoever in the economic conditions in Scotland when determining its policies on the pound.  And the Bank of Scotland will have no ability to control its own currency, the prime means of maintaining economic balance between labor and capital.  The Scots will, in effect, be putting themselves on a gold standard, the stupidest possible monetary system, so that, in a crisis, they will have to buy or borrow pounds, at interest, in emergency conditions, to deal with, say, the failure of the Royal Bank of Scotland (but don’t worry, that sort of thing can never happen again).  And the Bank of Scotland will have no means of stimulating the economy in a demand slump other than borrowing pounds from somewhere outside the country, rendering themselves in debt beyond their means.  And this will become an excuse for dismantling the social system that has been so important to elevating the Scots from poverty to a decent standard of living within one or two generations.  Just look at the poor PIGS in the Euro-zone being pushed around by Germany, especially, to satisfy the conveniences of the German bankers, and to hell with the living, breathing souls in Greece or Spain or Ireland or Portugal, to name the canonical victims.

A country that does not control its own currency is not independent and cannot be independent.  It’s an illusion.  Just what are Salmond’s true intentions are not entirely clear to me, but on the basis of his monetary policies alone, I implore my Scottish friends to suppress the natural wish to make a statement of pride, and instead do the sensible thing.  The proposal to be voted on this week is not a spittle on the  Heart of Midlothian, it is an irrevocable decision to place Scotland in an even worse position with respect to England than it already is in.

Listen to reason.  Vote NO on independence.


Filed under: Research Tagged: Scottish referendum
Categories: Offsite Blogs

What's the right way to name packages and modules?

Haskell on Reddit - Mon, 09/15/2014 - 8:52am

I have a package of database functionality called library which was developed internally at corporation. The current package name is corporation-library and the module hierarchy starts at Corporation.Library.

At some point this will be released on Hackage, and I am wondering what to do about naming. Personally I like the namespacing effect and the credit-giving effect of keeping corporation in the name of the package and modules, but I realise this may seem a bit odd to the community.

The other alternative is

  • rename the package to just library (this doesn't clash this any existing Haskell package or indeed any package from any programming language)
  • rename the module hierarchy to Library or Database.Library

Thoughts?

submitted by tomejaguar
[link] [13 comments]
Categories: Incoming News

The GHC Team: GHC Weekly News - 2014/09/15

Planet Haskell - Mon, 09/15/2014 - 7:47am

Hi *,

Here's a new thing: Blog posts! That's right. A while back, we started a new set of emails on the developers list containing weekly updates, from GHC HQ. But we eventually decided it should be more broad and encompass the work GHC sees as a project - including all the things our contributors do.

So now it's the weekly GHC news - and we (or, well, I) have decided to blogify the weekly emails!

So without further adieu, here's the current recap. The original mailing list copy is available ​here.

  • As Gabor mentioned on the list earlier today, I (Austin) accidentally broke the Windows build. Sorry. :( We really need to get Phab building Windows too ASAP... I'm working on a fix this morning.
  • I sent out the HCAR draft this morning. Please edit it! I think we have a few weeks of lead time however, so we're not in a rush like last time. But I will send reminders. :)
  • The server migration for ghc.haskell.org seems to have gone pretty smoothly in the past week. It's had plenty of traffic so far. The full migration is still ongoing and I want to complete it this week.
  • I've finished reorganizing some of the Git and Repository pages after some discussion. We now have the Repositories[1] page, linked to on the left side, which details some notes on the repositories we use, and links to other various pages. I'm thinking of replacing this side-bar "root" with a link to the main Git[2] page, perhaps.
  • Miscellaneous: ghc.haskell.org and phabricator.haskell.org now sets the Strict-Transport-Security header. This just means you always use SSL now when you visit those pages (so you can't be connection-hijacked via a 503 redirect).
  • GHC works on Wine apparently for all you Linux users - thanks Mikolaj![3]
  • Jan had some questions about infrastructure which I just followed up on this morning. In particular: does anyone feel strongly about his first question?[4]
  • Herbert committed the first part of the Traversable/Foldable changes, by moving the typeclasses to Prelude. This is part of an ongoing series of patches. Things like adding Bifunctor will finally come after this.[5]

Also, added bonus: we'll start including some of the tickets we closed this week.

Closed tickets for the past week include: #9585, #9545, #9581, #6086, #9558, and #3658.

Please let me know if you have any questions.

[1] ​https://ghc.haskell.org/trac/ghc/wiki/Repositories
[2] ​https://ghc.haskell.org/trac/ghc/wiki/WorkingConventions/Git
[3] ​https://www.haskell.org/pipermail/ghc-devs/2014-September/006283.html
[4] ​https://www.haskell.org/pipermail/ghc-devs/2014-September/006275.html
[5] ​https://phabricator.haskell.org/D209

Categories: Offsite Blogs

How should I go about making a function more elegant?

Haskell on Reddit - Mon, 09/15/2014 - 2:38am

Say I have this idea which seems pretty simple in my head. But then when implementing it in a function, I realize this is needed, and that is needed, and now when I'm done, the function works, but it is really ugly. Too ugly for what is really a simple thing.

Anybody had this problem before? Any advice on how you would go about fixing the code smell?

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

Simulating trade system with FRP (or pipes or conduit)

Haskell on Reddit - Sun, 09/14/2014 - 11:54pm

I would like to simulate a system of the following nature:

The system receives "ticks" at an unpredictable interval (depends on volume, etc.). Ticks serve two main purposes: the first is that ticks will be converted to "candles" [1]. There would be candles at various frequencies: at least 1,5,15,30 minute, 1,4,8 hour, 1 day, 1 week and 1 month. There would be signal generators that look at one or more of these candles to produce trading signals. The second purpose of the ticks would be when a signal is generated and the system issues an order, the "fill" price would come from a tick received after those used to generate the signal (e.g. if tick 1,000 caused ticks to be produced for 1,5,15 and 30 minute candles, and some of those candles triggered trading signals, when the buy/sell order comes the "fill" will be from a tick >1,000).

In thinking about how to implement such a system, it seemed to me that it might be a fit for FRP. Ticks would just be a normal "event" (not sure if my terminology will be correct), 1 minute candle would listen to this event, collect the seen high/low values and record the first value seen and the last of its timeframe before generating a 1 minute candle event. The 5 minute event would listen to the 1 minute event and generate its own event after 5 received minute candles, etc. This way we only need to hang onto enough ticks to generate a single minute event.

With such a design, the "order fill" part of the code could theoretically listen to the tick event (so minute and order fill are listening to that event) but in that case would it be guaranteed that by the time a trade signal was generated and order created that the tick seen by the order fill system will be one that came after the ones seen by the candles?

Also, I would be interested if people believe such a system would be better modelled in Pipes or Conduit and why.

[1] Candle being a high/low/open/close measurement over the frequency specified. For example 1m { 10/2/8/4 } would be a one minute candle where the first tick seen had a value of 8, the last seen was 4, the highest seen was 10 and the lowest 2.

submitted by nicheComicsProject
[link] [18 comments]
Categories: Incoming News

Control.Monad.Error deprecated?

haskell-cafe - Sun, 09/14/2014 - 8:40pm
Hello everyone, I just discovered that Control.Monad.Error [1] has recently become deprecated in favor of Control.Monad.Except [2], and I am curious about what motivated the change. Can anyone explain? Thanks, Karl 1: http://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Error.html 2: http://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Except.html
Categories: Offsite Discussion

Mike Izbicki: Comparing AVL Trees in C++ and Haskell

Planet Haskell - Sun, 09/14/2014 - 6:00pm
Comparing AVL Trees in C++ and Haskell posted on 2014-09-15 by Dat Do

This post compares the runtimes of AVL tree operations in C++ vs Haskell. In particular, we insert 713,000 strings from a file into an AVL Tree. This is a \(O(n \log n)\) operation. But we want to investigate what the constant factor looks like in different situations.

Experimental setup: All the code for these tests is available in the github repository. The C++ AVL tree was created in a data structures course that I took recently and the Haskell AVL tree is from the Haskell library Data.Tree.AVL. Additionally, the Haskell code stores the strings as ByteStrings because they are much more efficient than the notoriously slow String. To see how the runtime is affected by files of different sizes, the file was first partitioned into 10 segments. The first segment has 71,300 words, the second 71,300 * 2 words, and so on. Both the C++ and Haskell programs were compiled with the -O2 flag for optimization. The test on each segment is the average runtime of three separate runs.

Here’s the results:

C++vHaskell

C++ is a bit faster than Haskell on the last partition for this test.

I guess this is because Haskell operates on immutable data. Every time a new element is to be inserted into the Haskell AVL tree, new parent nodes must be created because the old parent nodes cannot be changed. This creates quite a bit of overhead. C++ on the other hand, does have mutable data and can simply change the node that a parent node is pointing to. This is faster than making a whole new copy like the Haskell code does.

Is there an easy way to speed up our Haskell code?

There is a Haskell library called parallel that makes parallel computations really convenient. We’ll try to speed up our program with this library.

You might think that it is unfair to compare multithreaded Haskell against C++ that is not multithreaded. And you’re absolutely right! But let’s be honest, manually working with pthreads in C++ is quite the headache, but parallism in Haskell is super easy.

Before we look at the results, let’s look at the parallelized code. What we do is create four trees each with a portion of the set of strings. Then, we call par on the trees so that the code is parallelized. Afterwards, we union the trees to make them a single tree. Finally, we call deepseq so that the code is evaluated.

{-# LANGUAGE TemplateHaskell #-} import Control.DeepSeq.TH import Control.Concurrent import Data.Tree.AVL as A import Data.COrdering import System.CPUTime import qualified Data.ByteString.Char8 as B import Control.DeepSeq import Data.List.Split import System.Environment import Control.Parallel $(deriveNFData ''AVL) -- Inserts elements from list into AVL tree load :: AVL B.ByteString -> [B.ByteString] -> AVL B.ByteString load t [] = t load t (x:xs) = A.push (fstCC x) x (load t xs) main = do args <- getArgs contents <- fmap B.lines $ B.readFile $ args !! 0 let l = splitEvery (length contents `div` 4) contents deepseq contents $ deepseq l $ return () start <- getCPUTime -- Loading the tree with the subpartitions let t1 = load empty $ l !! 0 let t2 = load empty $ l !! 1 let t3 = load empty $ l !! 2 let t4 = load empty $ l !! 3 let p = par t1 $ par t2 $ par t3 t4 -- Calling union to combine the trees let b = union fstCC t1 t2 let t = union fstCC t3 t4 let bt = union fstCC b t let bt' = par b $ par t bt deepseq p $ deepseq bt' $ return () end <- getCPUTime n <- getNumCapabilities let diff = ((fromIntegral (end-start)) / (10^12) / fromIntegral n) putStrLn $ show diff

Great, so now that the Haskell code has been parallelized, we can compile and run the program again to see the difference. To compile for parallelism, we must use some special flags.

ghc –O2 filename -rtsopts –threaded

And to run the program (-N4 refers to the number of cores).

./filename +RTS –N4

C++vHaskell4

Haskell now gets better runtimes than C++.

Now that we know Haskell is capable of increasing its speeds through parallelism, it would be interesting to see how the runtime is affected by the degree of parallelism.

According to Amdahl’s law, a program that is 100% parallelized will see a proportional speed up based on the number of threads of execution. For example, if a program that is 100% parallelized takes 2 seconds to run on 1 thread, then it should take 1 second to run using 2 threads. The code used for our test, however, is not 100% parallelized since there a union operation performed at the end to combine the trees created by the separate threads. The union of the trees is a \(O(n)\) operation while the insertion of the strings into the AVL tree is a \(O\left(\frac{n \log n }{p}\right)\) operation, where \(p\) is the number of threads. Therefore, the runtime for our test should be

\[O\left(\frac{n\log{n}}{p} + n\right)\]

Here is a graph showing the runtime of the operation on the largest set (713,000 strings) across increasing levels of parallelism.

HaskellParallelization

Taking a look at the results, we can see that the improvement in runtime does not fit the 100% parallelized theoretical model, but does follow it to some extent. Rather than the 2 core runtime being 50% of the 1 core runtime, the 2 core runtime is 56% of the 1 core runtime, with decreasing efficiency as the number of cores increases. Though, it is clear that there are significant improvements in speed through the use of more processor cores and that parallelism is an easy way to get better runtime speeds with little effort.

Categories: Offsite Blogs

Philip Wadler: The British Biased Corporation

Planet Haskell - Sun, 09/14/2014 - 4:01pm
Scandalous! Nick Robinson asks Alex Salmond a question, and Salmond takes seven minutes to answer in detail.

<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/rHmLb-RIbrM" width="560"></iframe>

On the evening news, Nick Robinson summarises Salmond's answer in a few seconds as 'He didn't answer'.

<iframe allowfullscreen="" frameborder="0" height="259" src="http://www.youtube.com/embed/enrdDaf3uss" width="460"></iframe>
(Above spotted via Arc of Prosperity.)

And today, this.
I used to be a supporter of the BBC, but it's getting harder and harder to justify.
Categories: Offsite Blogs

Type union

haskell-cafe - Sun, 09/14/2014 - 3:32pm
Hello! I am trying to create type safe boolean formula representation. Main operation is substion of particular value, to get another formula, and function that accept formula to calculate it's value. So target is: a = Conjunction (Var X) (Var Y) is 2 variable formula value (apply (X, True) . apply (Y, True) $ a) -- True and neither value a apply (X, True) . apply (X, False) $ a typechecks. How can I archive it? class Union a b c instance (a ~ b) => Union a b b instance Union a b (a, b) data P = P deriving Show data Q = Q deriving Show class (Show a) => Variable a instance Variable P instance Variable Q data Formula t where Prop :: (Variable b) => b -> Formula b Conjunction :: (Union t1 t2 t3) => Formula t1 -> Formula t2 -> Formula t3 deriving instance Show (Formula t) main = print (Conjunction (Prop P) (Prop Q) :: Int) This complains on ambitious t3. Attempt by typefamilies fails, since type family Union t1 t2 :: * data Void type instance Union a a = a type instance Uni
Categories: Offsite Discussion

Question on Parsing Haskell Subset

Haskell on Reddit - Sun, 09/14/2014 - 2:34pm

I was curious if someone could explain or point me at the relevant code to understand how GHC handles parsing for custom operator (i.e. infixl 1 >>=) declarations. I'm interested in parsing a small Haskell subset using Happy ( ignore haskell-src-exts for the moment ) and I find I can't unambiguously parse operators without statefully holding a context of the user-defined symbols and their precedences as I parse through a module.

Is there some trick to doing this with Happy and/or does GHC rewrite and shift expressions after it parses everything and has all the information available.

submitted by hmltyp
[link] [6 comments]
Categories: Incoming News