News aggregator

[ANN] codex 0.1.0 - generate tags file fromdependencies

haskell-cafe - Sun, 07/06/2014 - 5:00pm
Hi, Just to let you know that I released a new version of `codex` (a tool which generate a tags[1] file for a given cabal project using the sources of all the dependencies of that project). This release include some bug fixes as well as two new features: - Support modules added using `cabal sandbox add-source` as workspace dependencies - Support `emacs` format by disabling sorting on merge of tags files Thanks to everyone who reported bugs or submitted patch! [1]Those tags file basically contain references to functions/types definition in source code and allow "jump to definition" like functionality in text editors. source: hackage:
Categories: Offsite Discussion

Roman Cheplyaka: How to run SQL actions in persistent

Planet Haskell - Sun, 07/06/2014 - 3:00pm

When I started writing an application that used persistent to interact with a MySQL database, I decided to put the whole application inside one big SqlPersistM action, and run it once inside main. (To make it clear, this is not a Yesod application; I simply use persistent as a standalone library.)

However, as I learned more about persistent and how it worked, it became clear that this was the wrong way to use persistent. Here’s why.

Problems of one big SqlPersistM action Finalizing transactions

persistent’s SQL layer treats an SqlPersistT action as a single transaction. Thus, until you run the action, the transaction is not committed. Obviously, this is an issue for any long-running server application.

You could work around this by calling transactionSave manually. Now you have a different but related problem…

Overlapping transactions

Normally a single SQL connection can participate in just one SQL transaction. (There are probably exceptions to this rule which I am not aware of, but this is how it happens unless you do something special.)

Thus, assuming your application is multithreaded, you’ll end up committing other threads’ transactions that are active at the same time.

(Besides, I am not sure whether executing multiple SQL statements over the same connection simultaneously is supported at all.)

Resource deallocation

persistent uses resourcet to ensure that resources (such as buffers that hold result sets) are released as soon as they are not needed.

resourcet works by handling these two scenarios:

  1. No exception is thrown; resources are deallocated by an explicit release call.
  2. An exception is thrown, preventing the release action from happening. However, once the exception escapes the enclosing ResourceT block, it triggers the exception handler inside runResourceT. The exception handler then performs deallocation.

When your application consists of one long-running SqlPersistM action, chances are you’re catching some exceptions inside the ResourceT block, by the means of monad-control. Doing that invalidates resourcet’s assumptions: an exception prevents the release action from happening, and yet it never makes it up to runResourceT, and so your long-running app leaks resources.

Do it right

It implies from the above considerations that the right way to use persistent with a SQL backend is:

  1. Make SqlPersistT correspond to logical transactions in your application.
  2. Make ResourceT computations as short-lived as possible. Ideally, don’t catch exceptions inside ResourceT; use finally instead.
  3. Use a connection pool.

I am not an expert in either persistent or SQL databases; I am in the process of figuring this out myself. Corrections (and confirmations) are welcome.

Categories: Offsite Blogs

Control.Exception.bracket is broken(?)

haskell-cafe - Sun, 07/06/2014 - 2:15pm
Hello, From docs: "If an exception is raised, then bracket will re-raise the exception (after performing the release)." But what if the release action will throw an exception? There are 3 options: 1) suppress the exception from release action and rethrow the original one 2) shutdown the program 3) suppress the original exception and throw the exception from release action. Current behavior is #3 -- suppress the original exception. I think it the worse choice. What other languages do: - java has try-with-resources statement which is the nearest equivalent of haskell's "bracket". It uses the option #1 (rethrow the original exception) - in c++ it is common to use RAII for resource management, so someone's destructor performs resource cleanup. But if destructor throws exception during stack unrolling, the program is terminated (option #2) I prefer #2 because suppressing exception is a really bad idea. What is your choice? And the related thing. Release action should not use any interruptible action.
Categories: Offsite Discussion

Newbie trying to install yesod

Haskell on Reddit - Sun, 07/06/2014 - 7:12am

Hi /r/haskell,

I'm very new to Haskell. I don't know if this is the right place to ask questions so bear with me. I'd like to install yesod (Ubuntu 12.04-64) via

cabal install yesod-platform yesod-bin --max-backjumps=-1 --reorder-goals (straight from yesod website)

Whenever I run this command, I get the following message:

Resolving dependencies... Killed

and yesod doesn't get installed. What's happening? How can I solve this?

BTW, is yesod a good framework? What do you guys mostly prefer; snap or yesod or something else?


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

Most powerful high(est) level programming language?

Haskell on Reddit - Sun, 07/06/2014 - 3:39am

Here is an interesting article from 2001 on the 'power' of Lisp:

And a nice comparison article from 2009 on the 'power' of Haskell:

They are interesting to read as if written by the same programmer on a 20 year quest to find 'powerful' language(s).

It got me thinking about the breakdown of 'relative power' of the highest level languages in terms of criteria scored in these articles, like expressiveness, efficiency of code, ability to (easily) solve notoriously difficult or complex problems, etc. Is it fair to rank Haskell as the 'highest level power language' for 'high level' tasks, given that not all high level languages are equally powerful? Sorry for the vague circular logic here, but I'm just attempting to pass along the opinions of these articles with minimal interpretation.

I know that the answer depends on what you plan to do with the language. Let me remain vague by saying a general purpose language for 'very high level' tasks given modern environment and lessons learned.

submitted by RaymondWies
[link] [28 comments]
Categories: Incoming News

Signal Processing Library

haskell-cafe - Sat, 07/05/2014 - 11:03pm
Hi, There is also a signal processing package on Hackage [1] which performs auto_correlation. FFT is has been moved from hmatrix to hmatrix-gsl [2]. Hope this helps. Cheers, Vivian [1] <> [2] <> Date: Fri, 4 Jul 2014 10:19:51 -0700 _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

ghc, tls, gmp

glasgow-user - Sat, 07/05/2014 - 10:04pm
Hi, in Debian, we have the (well-known) problem of linking against libraries using libgmp, in this case haskell-curl, which links against libcurl, which links against gnutls, which uses libgmp since the latest release: Are there any viable solutions to this problem that I might not be aware of? Are there any solutions to be expected in the near future? (My best idea so far is to use libcurl linked against openssl, but this causes licensing issues.) Greetings, Joachim
Categories: Offsite Discussion

Checking minimum package bounds

haskell-cafe - Sat, 07/05/2014 - 8:37pm
Often a topic of discussion is making sure that the upper bounds on one's packages are up to date, or even whether upper bounds are a good idea at all. I don't see much discussion on lower bounds. Lower bounds that are needlessly restrictive can get in the way too. For instance, I could just slap "text >= 1.1 && < 1.2" on my package, but this makes things needlessly hard for someone trying to make my package work in conjunction with an older one, especially if all I use are basic functions like "pack" that have been around at least since, say. text-0.11. Does anyone have a best practice for testing and verifying lower bounds? Testing the lower bounds and the upper ones is a challenge. Does anybody bother? I have my sunlight package at but it is really a nasty hack. I am considering cleaning it up so it is less of a nasty hack but before I do that I wondered if anyone else has ever thought about this problem. Thanks. Omari ___________________________________
Categories: Offsite Discussion

On smart code-completion in Haskell, idris-mode style. (Advice needed)

Haskell on Reddit - Sat, 07/05/2014 - 6:43pm

tl;dr I'd like to hear your opinion about smart code completion in haskell, in the spirit of agda-mode or idris-mode, and propose two possible way to limit the information loss caused by having a weaker type-system.

I really like the completion mechanism for code in languages with full dependent types like Idris or Agda. I'd like similar (or better) code completion facilities for Haskell.

To see how this could be done, let's start with a idris example:

filter : (a -> Bool) -> List a -> List a filter f [] = [] filter f (x::xs) = ?what

Now, a type-correct (and minimal, in the sense of proof search) completion of ?what is xs, and is in fact the answer of idris-mode. This is of course not ok, so let's say you want a precise enough type to be able to generate the function automatically. You could encode additional invariants in your function, beginning with:

filter : {a : Type} -> {P : a -> Type} -> (decideP : (x : a) -> Dec (P x)) -> List a -> List (x : a ** P x)

or the code in this paste. (thanks to ziman and {AS} for the conversation in #idris and the examples). At the end of the spectrum, you could encode all your invariants in the type.

On the flip side, I don't see a general, easy way to balance specification vs. code, and I fear the proliferation of many functions essesntially on the same object but with different specifications. Moreover, I'd like to take advantage of the rich ecosystem and the wonderful compiler we have in haskell.

So, how could we alleviate the loss of dependent types? The answer I'm thinking of is a mixture of heuristics and code generation via examples.

Heuristics: One could argue that in the second definition of filter, the answer

filter f (x::xs) = xs

fails to recognise the role f and x could have in the equation. In a sense, this expression scores low on the heuristic "argument usage". Another heuristics may me the number of function applications in your code (lower is better), which could rule out the obvious pitfalls of a naive theorem prover (solutions like x : [], x : x : [], x : x : x : [] etc). One could also guide the program towards the intended implementation writing "hints", functions that we imagine would be used in the final implementation (heuristic: hint-usage).

Other heuristics could be found among the standard ones used in automated theorem proving. The point here is that it seems to me that there are sufficient good heuristics avaiable to guide the writing of our code.

Code generation via examples: The second point I'd like to make is related to interface: even using all heuristics we are able to come up with, the answer could still typecheck without being what we had in mind:

if f x then xs else x : xs if f x then xs else [x]

So here the program could take simple arguments (or even generate them via quickCheck), like odd :: Integral a => a -> Bool, and [1,2,3,4,5], and output various possible answers for filter odd [1,2,3,4,5], based on the different implementations it can come up with. Hopefully choosing the expected answer could guide the program towards a unique correct implementation.

On a final note, I have "tested" this approach with some (simple, but not too simple) programs (imagining the heuristics that would be used, and the examples that would guide the generation). The results seemed nice to me, and having those automated would be a great speedup for my coding.

So, I'd like to hear your thoughts here, expecially on:

  • What flaws/problems/shortcomings may this approach have, in your opinion? Please provide some example.

  • Could you name programs/tools that I should probably use in this project, and why?

  • Do you know some papers/theory I should definitely read to refine my approach?

  • If you're a person interested in giving occasional hints and guidance on the overall architecture, be sure to write it below.

  • Extra advices are always appreciated, even if they don't belong to previous categories.

submitted by meditans
[link] [9 comments]
Categories: Incoming News

withFile variant which takes a ByteString?

haskell-cafe - Sat, 07/05/2014 - 4:52pm
Hi all, Is there a variant of withFile which takes a ByteString? (I'm aware that I could use the lower-level System.Posix FD-based functions, but if someone already has a package out there, I'd rather not.) Regards,
Categories: Offsite Discussion

Looking for a Haskell teacher in the NYC area

Haskell on Reddit - Sat, 07/05/2014 - 4:05pm

I'd like to find a tutor to help me get up to speed in Haskell. Willing to pay for a few lessons. If you can help, please PM me. If you know of other places where I should ask this question, that would also be appreciated.

submitted by NeedToLearnMore1
[link] [14 comments]
Categories: Incoming News

Is there a relation between the operational monad and the free monad?

Haskell on Reddit - Sat, 07/05/2014 - 1:10pm

Some time ago I learned about the operational semantics for monads in a blog post by /u/apfelmus. It seemed like a nice way to build a monadic DSL.

More recently I saw lots of internet discussion about the Free Monad, which is also a pattern that can be used to create monadic DSLs.

Is there a deeper algebraic relationship between those two patterns?

submitted by calsaverini
[link] [11 comments]
Categories: Incoming News

Lambdaheads: functional programming group in Vienna

Haskell on Reddit - Sat, 07/05/2014 - 8:23am

Dear Friends of functional Programming!

The next meeting of the Lambdaheads( will take place on Wed. July 9th 19:30 in the Metalab( library, everyone interested in programming languages especially functional ones is welcome to join.

Topic of the meeting will be "monads", a topic most often misunderstood and declared too abstract for the common programmer. I will try to present on this topic in a comprehensible way and want to explain why any programming language profits in having monads, be it only to get rid of the nullpointer-problem.

Looking forward to meeting all of you cheers Martin

submitted by epsilonhalbe
[link] [2 comments]
Categories: Incoming News

Why does this leak memory?

Haskell on Reddit - Sat, 07/05/2014 - 3:53am
import Control.Monad main = forM (map show [0..(2^64)]) putStrLn

Why does this leak memory like a sieve? Why is [x..y] not the equivalent of python 3's range function or more accurately, not the equivalent of a python generator?

Isn't the point of lazy evaluation in haskell not allocating gobs of memory for things we don't need until we need them and then throwing them away when they are no longer needed? I've only just started haskell and haven't got into monads yet (I've got a rough idea of what they are about) but having such a simple program leak memory made me question my sanity.

submitted by dardyfella
[link] [9 comments]
Categories: Incoming News

Emacs haskell-mode : how to send PART of file to repl ?

Haskell on Reddit - Sat, 07/05/2014 - 3:19am

In many emacs language modes, there are commands for interacting with a repl/interpreter for that language.

Often there are commands for sending just specific parts of the file (like single expressions or subexpressions or regoins) to the repl.

For example (among, no doubt, numerous others)

  • In ocaml, with tuareg C-c C-e (tuareg-eval-phrase)

  • In clojure, with cider (M-x cider-jack-in) C-c C-e (cider-eval-last-sexp)

  • In ruby, with ruby-mode C-x C-e (ruby-send-last-sexp)

I'm trying to do this in haskell-mode. I can type stuff in the repl within emacs and it seems to work. And while editing a buffer containing a .hs file, I can load the WHOLE file into the repl with:

C-c C-l (haskell-process-load-file)

BUT I'm not sure how to send to the repl:

1) only a portion of the file

2) "naked expressions" I tried a file with just a single expression and it gave an error. This is no big deal if you have to evaluate the whole file anyway. But if a "portion" were possible (point 1) then being able to send an expression or subexpression to the repl is sometimes useful.

I'm just having a little look at haskell, and am just trying to get a nice interactive setup.

Any suggestions on how to send portions of a haskell file to the repl would be much appreciated.

I'm hoping there's just some configuration technique that I'm not aware of.

I guess it might be possible to write an emacs mode or modify haskell-mode to do this. But as just a basic emacs user, that's probably not a good option. And also, if it is not possible in the existing haskell-mode (written by someone who knows a lot more haskell and emacs than I do) then maybe there's some technical difficulty with doing it. (Considering it's a fairly obvious thing to do and is done for many other languages)

Note: Previously asked on r/haskellquestions.
But no response. So asking again here where the traffic is greater by an order of magnitude or two.
(And people seem to be asking quite a few questions anyway.)

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

How do you work around the lack of "cabal upgrade"?

Haskell on Reddit - Sat, 07/05/2014 - 2:47am

How do you keep your globally installed Haskell tools (e.g. pandoc, hlint, etc.) up to date?

The whole situation currently seems pretty messy to me. With cabal sandboxes, the user package database seems really redundant to me. All I still install to it are Haskell tools like pandoc, where I am not interested in the modules and packages, but only in the frontend programs, and I'd like to keep these up to date, like any other program I use.

Currently, I'm keeping a list of programs I use, and do cabal install --upgrade-dependencies foo for each of them occasionally, which is pretty tedious, and occasionally fails due to version conflicts.

Ideally, I'd build each program in a separate sandbox, and only install the statically linked binaries and data files (as in cabal copy). Is there any tool for this?

submitted by lunaryorn
[link] [24 comments]
Categories: Incoming News

CFP: PRDC2014 Call for Fast Abstracts / Industry Track Papers / Posters

General haskell list - Sat, 07/05/2014 - 2:44am
PRDC2014 Call for Fast Abstracts / Industry Track Papers / Posters Singapore Nov.18-21,2014 --------------------------------- Call for Fast Abstracts --------------------------------- Fast Abstracts at PRDC are short oral presentations, either on new ideas or work in progress, or opinion pieces that can address any issue relevant to dependable systems and networks. Because they are brief and have a later deadline, Fast Abstracts enable their authors to: .Summarise work that is not yet complete .Put forward novel or challenging ideas .State positions on controversial issues .Suggest new approaches to the solution of open problems Thus, they provide an excellent opportunity to introduce new work, or present radical opinions, and receive early feedback from the community. Contributions are particularly solicited from industrial practitioners and academics that may not have been able to prepare full papers du
Categories: Incoming News