News aggregator

SHA sums of cabal-install binaries

libraries list - Wed, 06/17/2015 - 9:03pm
Hi, are the SHA sums of cabal-install binaries available somewhere? GHC provides them on the download pages, but I couldn't find them anywhere for cabal-install. If not, would it be possible to provide them? Thanks, Petr _______________________________________________ Libraries mailing list Libraries< at >
Categories: Offsite Discussion

Trying to remember the name of a fold fusion paper

Haskell on Reddit - Wed, 06/17/2015 - 7:53pm

I'm trying to remember the name of a haskell paper I read. The motivating example was the old "calculate the mean of a list in a single traversal" saw.

I think the construction they ended up with was something like

{-# LANGUAGE ExistentialQuantification #-} module Fold where import Control.Applicative import Prelude hiding (sum, length, foldr) import Data.Foldable hiding (sum) import Data.Profunctor data Fold a b = forall x. Fold { init :: x, step :: a -> x -> x, final :: x -> b } runFold :: Foldable t => Fold a b -> t a -> b runFold (Fold i s f) = f . foldr s i instance Functor (Fold a) where fmap g (Fold i s f) = Fold i s (g . f) instance Profunctor Fold where lmap g (Fold i s f) = Fold i (s . g) f rmap = fmap dimap g h (Fold i s f) = Fold i (s . g) (h . f) instance Applicative (Fold a) where Fold i s f <*> Fold j t g = Fold (i,j) (\a (i,j) -> (s a i, t a j)) (\(i,j) -> f i (g j)) pure = Fold () (flip const) . const instance Num b => Num (Fold a b) where (+) = liftA2 (+) (*) = liftA2 (*) (-) = liftA2 (-) negate = fmap negate abs = fmap abs signum = fmap signum fromInteger = pure . fromInteger instance Fractional b => Fractional (Fold a b) where (/) = liftA2 (/) recip = fmap recip fromRational = pure . fromRational length :: Num b => Fold a b length = Fold 0 (const (+1)) id sum :: Num a => Fold a a sum = Fold 0 (+) id

So you could just define mean as

mean :: Fractional a => Fold a a mean = sum / length

Is this jogging anyone else's memory?

submitted by rampion
[link] [5 comments]
Categories: Incoming News

Robin KAY: Fast and Slow Sticky Notes in Haskell and Qt

Planet Haskell - Wed, 06/17/2015 - 5:09pm
Last year I gave a talk for the London Haskell User Group on building a Sticky Notes application using Haskell, Qt, and the HsQML binding between them. The video has been out for a while now and made the rounds elsewhere, but I've thus far neglected to post it on my own blog! Slides are here. See below for an update on the example program and an answer to the most commonly asked question after the fact.

<iframe allowfullscreen="" frameborder="0" height="270" src="" width="480"></iframe>
Fast and Slow? An update!For the sakes of simplicity, the original version of the sticky notes program shown in the talk uses an SQLite database to serve the view directly with no in-memory model or caching. This is at least the cause of some sluggishness and at worst pathological performance depending on your machine.

As alluded to in the talk, there is a better albeit more complicated way. This involves moving the slow database accesses onto a separate thread and keeping a fast in-memory model to support the user interface. Changes made by user are now queued up and then flushed to disk asynchronously.

I've now released an updated version ( of the hsqml-demo-notes package which includes a new faster version of the program illustrating exactly this technique. This hsqml-notes executable is now built using the new code and, for reference, the original code is built into the hsqml-notes-slow executable.

The fast variant uses three MVars to communicate between the UI and database threads. An MVar is kind of synchronisation primitive offered by Haskell akin to a box which may either contain a data value or be empty. Operations on MVars take out or put in values to the box and will block if the MVar is not in the appropriate state to accept or produce a value. Hence, a variety of different constructs such as locks and semaphores can built out of MVars.

The first MVar in the new notes code, modelVar, contains a Map from note IDs to the data associated with each note. This is the in-memory model. It includes all the fields held in the database table plus an additional field which indicates whether there are any pending changes which need flushing to the database (whether the record is "dirty"). The MVar semantics here act as a lock to prevent more than one thread trying to manipulate the model at the same time.

A second MVar, cmdVar, is used as a shallow channel for the UI thread to signal the database thread when there is work to do. The database thread normally waits blocked on this MVar until a new command value is placed in it, at which point it takes out and acts upon it. The first command given to the database thread when the program starts is to populate the model with the data stored on disk. Thereafter, whenever a user makes a change to the model, the dirty bit is set on the altered record and a command issued to the database thread to write those dirty records to the database.

Finally, the third possible type of command causes the database thread to close the SQLite file and cleanly exit. In that case, the third MVar, finVar, is used as a semaphore to signal back to the UI thread once it has shut down cleanly. This is necessary because the Haskell runtime will normally exit once the main thread has finished, and the MVar provides something for it block on so that the database thread has time to finish cleaning up first.

What is the FactoryPool actually for?QML objects require a relatively explicit degree of handling by Haskell standards because the idea that data values can have distinct identities to one another even if they are otherwise equal is somewhat at odds with Haskell's embrace of referential transparency. This sense of identity is important to the semantics of QML and can't be swept under the rug too easily. Crucially, using signals to pass events from Haskell to QML requires that both the Haskell and QML code are holding on to exactly the same object.

One way to accomplish this is to carefully keep track of the QML objects you create in your own code. The factory-pool is an attempt to provide a convenience layer atop object creation which saves the programmer from having to do this. It is essentially an interning table which enforces the invariant that there is no more than one QML object for each distinct value (according to the Ord type-class) of the Haskell type used to back it. If you query the pool twice with two equal values then it will give you the same object back both times. Importantly, it uses weak references so that objects which are no longer in use are cleared from the intern table and it doesn't grow in size indefinitely.

One of the difficulties people have had with understanding the factory-pool from the notes example is that it's not generally necessary to make it work. Aside from the initial loading of the database, all the activity is driven from the front-end and so displaying a single view isn't strictly reliant on the signals firing correctly. If you replace the code to retrieve an object from the pool with a plain object instantiation, the default QML front-end for the demo would still work the same, albeit more wastefully.

To see the pool doing something useful, try the "notes-dual" front-end (by specifying it on the command line), which I've come to think of as the most interesting of the demos. It displays two front-ends simultaneously backed by the same data model. Changes in one are immediately reflected in the other. This works because when each front-end retrieves the list of notes they both obtains the same ObjRef from the pool for each Note as each other. Hence, when a change is made in one front-end, and a change signal is fired, both the front-ends receive it and remain in sync.

Without the pool, the onus would be on the application code to keep track of the objects in some other fashion. For example, if each read of the notes property created a new set of objects every time it was accessed then many more objects would need to have signals fired on them in order to ensure that every piece of active QML had received notice of the event. Each front-end would still be backed by the same data, methods and properties would still have access to the same set of Note values, but their objects would be distinct from the perspective of signalling and, unless special care was taken, the front-ends wouldn't update correctly.
Categories: Offsite Blogs

More instances for Identity?

haskell-cafe - Wed, 06/17/2015 - 4:37pm
Hi, I just noticed that Data.Functor.Identity [1] lacks many useful instances like Eq, Ord, Show ... etc. Is there a reason for this? Otherwise, shouldn't we make a proposal for it? In my opinion, if the seven-tuple has an instance, then Identity deserves it as well. Niklas [1]:
Categories: Offsite Discussion

Implementing a YCombinator in Haskell

Haskell on Reddit - Wed, 06/17/2015 - 1:51pm

I was messing with ghci when I tried to implement a YCombinator as following

λ: \f -> (\x -> f(x x)) (\x -> f(x x)) Occurs check: cannot construct the infinite type: t1 = t1 -> t0

I am not sure why it isn't working? Is it because Haskell is a kind of strongly normalized typed lambda calculi and thus self-application is forbidden (but general r?!)

If anyone can elaborate on what is the issue here, it would be greatly welcomed.

Also, bonus points for implementing a correct Y combinator in Haskell! :)

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

zlib-0.6.1 bug?

libraries list - Wed, 06/17/2015 - 1:00pm
Agda sees some segmentation faults when compiled with zlib-0.6.1.x, but not with zlib- You might want to constrain zlib < 0.6 for now. (I reported the issue to the maintainer a couple of weeks ago, but have not gotten any response yet.) Cheers, Andreas
Categories: Offsite Discussion

How stack lowers the barrier to open source contributions

Haskell on Reddit - Wed, 06/17/2015 - 11:34am

Stack remembers things for you so that you don't have to. Here's an example.

I had a trivial change that I wanted to try out adding to http-client. Here are the steps I went through:

  • git pull
  • stack test # yep, project builds and passes test suites
  • <<make change>>
  • stack test # yep, it still builds and passes test suites
  • git add <<my changes>>
  • git commit -m <<explain my changes>>
  • git push forked-origin
  • <<submit PR on github>>

Notice the things I didn't have to remember to do:

  • create a sandbox
  • install dependencies
  • test the other packages in the repo against my changes to http-client

Stack lowers the barrier to open source contributions. If your open source project comes with a stack.yaml, then it is easy for contributors to jump right in and get the real work done, rather than fiddling with package management. Just instruct contributors to download stack and stack test.

Something which is perhaps less obvious at first is how to get ghci to work with your stack-ified project. It's quite simple once you know:

$ stack ghci Configuring GHCi with the following projects: http-client-openssl, http-client-tls, http-client, http-conduit GHCi, version 7.8.4: ... Prelude> :load Network.HTTP.Client Network.HTTP.Client> submitted by drb226
[link] [102 comments]
Categories: Incoming News

About my commitment to my passions,Haskell and the world

haskell-cafe - Wed, 06/17/2015 - 2:49am
Hi everybody, I have a very important announcement. I’ve decided to dedicate the next big part of my life to improve the world through Haskell. And you can help! (I’m not asking for money…) I plan to go to live at a “poor” village where my grandparents live. Poor because it is very hard to get a higher education. My grandfather founded some time ago some schools nearby the village, but if people wanted to have a bright future, they had to leave the village. My father moved to the nearest capital city. The story repeated. My father and my mother (together with other people) founded a school at the city where I was born. I left this city to get an even higher education at one of the best universities of my continent. At college, I got the opportunity to study a year as an exchange student at one of the best CS universities in the world. Knowing that probably I would never be able to study at such a good university again, I took the hardest subjects I could. The first semester, I took 2 undergrad
Categories: Offsite Discussion

Postdoc position in parallel/distributed functionalprogramming

General haskell list - Tue, 06/16/2015 - 5:37pm
Indiana University invites applications for a postdoctoral position in the programming languages research cluster ( with a possible dual affiliation with the Center for Research on Extreme Scale Technologies (CREST, The position is in Prof. Newton's research group and will emphasize parallel functional programming. Our group works on all aspects of parallel programming libraries and languages. One theme is extending and improving guaranteed-deterministic programming environments. Typical research projects include either (1) improvements to the GHC Haskell compiler, runtime, and library ecosystem or (2) work on domain-specific languages and compilers, frequently embedded in Haskell, and targeting backends like CUDA, LLVM, or OpenCL. Experience with any of the following would be a positive: Haskell development, GHC internals, compiler construction, FRP or stream processing, parallel programming and performance tuning, and purely functional parallelism.
Categories: Incoming News

Math in Haddock

libraries list - Sun, 06/14/2015 - 10:06pm
I thought folks might be interested in a little example of what is now possible in Haddock (assuming my PR is accepted): Anyone wanting to live on the edge can build their own haddock and upload their haddocks manually to hackage: Dominic Steinitz dominic< at >
Categories: Offsite Discussion

Math in Haddock

libraries list - Sun, 06/14/2015 - 10:01pm
I thought folks might be interested in a little example of what is now possible in Haddock (assuming my PR is accepted): <> Anyone wanting to live on the edge can build their own haddock and upload their haddocks manually to hackage: Dominic Steinitz dominic< at > _______________________________________________ Libraries mailing list Libraries< at >
Categories: Offsite Discussion

New gtk2hs 0.12.4 release

gtk2hs - Wed, 11/21/2012 - 12:56pm

Thanks to John Lato and Duncan Coutts for the latest bugfix release! The latest packages should be buildable on GHC 7.6, and the cairo package should behave a bit nicer in ghci on Windows. Thanks to all!


Categories: Incoming News