News aggregator

direct-fastcgi and logging

haskell-cafe - Thu, 06/26/2014 - 8:19am
Hi all! I write a FastCGI-server based on excellent package 'direct-fastcgi' ( It works perfectly, but I want to inject a logging facility into a handler of requests. For example: import Control.Concurrent (forkIO) import Network.FastCGI main :: IO () main = acceptLoop forkIO handleRequest handleRequest :: FastCGI () handleRequest = do -- >>> In this place I want to log a message <<< setResponseStatus 400 setResponseHeader HttpContentType "application/json" fPutStr "{ "my": "problem_description" }" Yes, I know about this function in 'Network.FastCGI': fLog :: MonadFastCGI m => String -> m () but it "logs a message using the web server's logging facility", and I want to log into _my_own_ file. So which solution I can use here? I'd be very grateful for any help. ---------- Sincerely, Denis Shevchenko haskell< at >
Categories: Offsite Discussion

HLPP 2014 - 7th Symposium on High-Level Parallel Programming and Applications

General haskell list - Thu, 06/26/2014 - 8:04am
============================================================================== FINAL CALL FOR PARTICIPATION HLPP 2014 7th International Symposium on High-level Parallel Programming and Applications Amsterdam, Netherlands July 3-4, 2014 ============================================================================== Keynote: Frank Schlimbach, Intel: Parallelism Through CnC (Concurrent Collections) - More Flexibility, Less Pain Abstract: The major goal of CnC (Concurrent Collections) is a productive path to efficient parallel execution. And yet a CnC program does not indicate what runs in parallel. Instead, it explicitly identifies what precludes parallel execution. There are exactly two reasons that computations cannot execute in parallel. If one computation produces data that the other one consumes, the producer
Categories: Incoming News

Tim Docker: Teenage Haskell

Planet Haskell - Thu, 06/26/2014 - 7:36am

I’ve been inspired by the efforts of others (Chris Smith, Manuel Chakravarty) to try teaching children haskell as a first experience of programming. Haskell has a reputation of being a "hard" language, but I suspect this stems from the challenges faced by software developers transitioning from an imperative programming paradigm to a functional one. There’s anecdotal evidence that, for first steps into programming, a functional programming language may be easier for many students, and allow a class to focus more quickly on interesting aspects of programming.

With any group of beginners, and especially children, simple tooling is really important. Being able to run examples in minutes of turning on the computer is really important. But running even the simplest of traditional toolchains requires at least a rudimentary understanding of:

  • a text editor
  • the file system
  • a command line
  • an interpreter/compiler

And there’s platform issues here also – even when the language is platform independent the other items will vary. It would be very easy to get bogged down in all this well before actually writing a program that does something interesting…

Hence I was excited several weeks ago when Chris announced the reimplementation of his codeworld environment. In a nutshell, it’s a web site where:

  1. you edit haskell code in your browser
  2. it gets compiled to java script on the remote server using ghcjs
  3. the javascript runs back in the browser

and it comes with a beginner-friendly prelude focussed on creating pictures, animations, and simple games (no monads required!).

This was just in time for school holidays here in Sydney – my own children to be my "guinea pig" students. Nick (aged 14) is in year 9 at school, whereas Sam (aged 12) is in year 7. At school they have covered simple algebra, number planes, and other math ripe to be used for something more fun than drill exercises! They have a younger brother Henry (aged 10), who has being observing with interest.

Our goal is to learn to draw pictures, then move on to animations, and, further down the track (if we get there) write some games. After a couple of 2 hour sessions, it has gone remarkably well.

So what have we done? Here’s a short outline of our two sessions so far:

Session 1 (2.5 hours):

We discussed the nature of computers, programming languages, compilers.

We launched the codeworld environment, and played with the demos. We tried changing them, mostly by adjusting various constants, and found they broke in often entertaining ways.

We typed in a trivial 2 line program to draw a circle, and made it work. We observed how problems were reported in the log window.

We talked about what a function is, and looked at a few of the builtin functions:

solidCircle :: Number -> Picture color :: Color -> Picture -> Picture (&) :: Picture -> Picture -> Picture

… and looked at how they can be composed using haskell syntax.

Then we played!

After this, we introduced some extra functions:

solidRectangle :: Number -> Number -> Picture translate :: Number -> Number -> Picture -> Picture rotate :: Number -> Picture -> Picture scale :: Number -> Number -> Picture -> Picture

which let us draw much more interesting stuff. The rest of this session was spent seeing what cool stuff we could draw with these 7 functions.

Nick programmed some abstract art:

Sam coded up a sheep:

That ended the session, though the boys found some unsupervised time on the computer the next day, when Nick built a castle:

and Sam did some virtual surfing:

Session 2 (2 hours):

In the second session, we started by talked about organising code for clarity and reuse.

The transformation functions introduced in the previous session caused some confusion when used in combination. We talked about how each primitive worked, and how they combined – the different between rotating and then translating versus translating then rotating was investigated.

The boys were keen to move on to animations. I thought we’d leave this for a few sessions, but their enthusiasm overruled. This required that we looked at how to write our own functions for the first time. (In codeworld an animation is a function from time to a picture). This is quite a big step, as we needed to get at least a basic idea of scoping also.

Nevertheless we battled on, and got some movement on the screen. It was soon discovered that rotations are the most interesting transform to animate, as you don’t lose you picture elements off the screen as time goes to infinity!

Nick and Sam needed more assistance here, but still managed to get some ideas working. I’ve only got single frames of their results. Sam produced his space race:

and Nick made a working clock (which tells the right time if you push the run button at 12 oclock!):

In the next session we are going to have to look at numerical functions in a bit more detail in order to produce more types of animations. Time for some graph paper perhaps…


For a beta (alpha?) piece of software, relying on some fairly advanced and new technology, Codeworld works remarkably well. And Chris has plans for it – there’s a long list of proposed enhancements in the github issue tracker, and a mailing list has just been created.

Right now the main issue is documentation. It works well with an already haskell-literate tutor. Others may want to wait for the documentation, course guides, etc to be written.

If you are a haskell enthusiast, Give it a try!

Categories: Offsite Blogs

What would you want out of a Cabal enhancement package?

Haskell on Reddit - Wed, 06/25/2014 - 10:48pm

Hi r/haskell! I'm an intern at Galois, Inc. this summer, and myself and a few colleagues were recently talking about things we'd like to see in a Cabal wrapper program with extra utilities. In particular, we would love to have the ability to split and merge packages with automatic management of the .cabal files involved, rename modules and adjust imports accordingly, and other things like that.

But before we go any further building something like this, we wanted to find out more about what other people would want out of a Cabal-augmentation package. What package/dependency/module-management tasks do you find frustrating, and what features would solve those problems for you?

submitted by kwef
[link] [43 comments]
Categories: Incoming News

Big changes coming to CodeWorld

Haskell on Reddit - Wed, 06/25/2014 - 10:30pm
Categories: Incoming News

wren gayle romano: Solving Chain Multiplication

Planet Haskell - Wed, 06/25/2014 - 6:05pm

This summer I've been working on optimizing compilation for a linear algebra DSL. This is an extension of Jeremy Siek's work on Built-to-Order BLAS functions. Often times it's more efficient to have a specialized function which fuses two or more BLAS functions. The idea behind BTO is that we'd like to specify these functions at a high level (i.e., with liner algebra expressions) and then automatically perform the optimizing transformations which have made BLAS such a central component of linear algebra computations.

The current/prior version of BTO already handles loop fusion, memory bandwidth constraints, and more. However, it is not currently aware any high-level algebraic laws such as the fact that matrix multiplication is associative, addition is associative and commutative, transposition reverse-distributes over multiplication, etc. My goal is to make it aware of these sort of things.

Along the way, one thing to do is solve the chain multiplication problem: given an expression like ∏[x1,x2...xN] figure out the most efficient associativity for implementing it via binary multiplication. The standard solution is to use a CKY-like dynamic programming algorithm to construct a tree covering the sequence [x1,x2...xN]. This is easy to implement, but it takes O(n^3) time and O(n^2) space.

I found a delicious alternative algorithm which solves the problem in O(n*log n) time and O(n) space! The key to this algorithm is to view the problem as determining a triangulation of convex polygons. That is, we can view [x0,x1,x2...xN] as the edges of a convex polygon, where x0 is the result of computing ∏[x1,x2...xN]. This amazing algorithm is described in the tech report by Hu and Shing (1981a), which includes a reference implementation in Pascal. Unfortunately the TR contains a number of typos and typesetting issues, but it's still pretty legible. A cleaner version of Part I is available here. And pay-walled presumably-cleaner versions of Part I and Part II are available from SIAM.

Hu and Shing (1981b) also have an algorithm which is simpler to implement and returns a heuristic answer in O(n) time, with the error ratio bounded by 15%. So if compile times are more important than running times, then you can use this version as well. A pay-walled version of the article is available from Elsevier.

Categories: Offsite Blogs

wren gayle romano: A problem with performativity

Planet Haskell - Wed, 06/25/2014 - 5:11pm

When it comes to explaining the social categorization of people, I've been an advocate for performative theories since long before they became popular/mainstream. To be clear, I find the current mainstream notions of performativity deeply problematic because they overemphasize social constructivism and fail to highlight what I see to be the actual insight behind the original formulation of performativity. But all the same, I've long been a fan of (my understanding of) performativity.

However, in the tail end of chapter 8 of Whipping Girl, Julia Serano raises a major complaint against performative theories of sex/gender in particular— a complaint I agree with wholeheartedly, and which is not easily reconciled. Before getting into the problem she raises, I should probably explain what performativity is and why I've been such an advocate for it.

The Question

What does it mean to be human, or a woman, or an atheist, or a scientist? For any specific categorization the exact details will vary, of course. The question I'm asking is, once we abstract over the particular category, what does it mean to say that some person does or does not belong to that category? Many social categories are uninteresting in this regard. I am an IU student in virtue of the fact that I am registered here, pay tuition, attend classes, etc; there's a clear definition, and that definition is wholly uninteresting and uncontroversial. However, for many categories things aren't so cut and dried.

Read more... )

Categories: Offsite Blogs

Real World Haskell - Outdated Parts?

Haskell on Reddit - Wed, 06/25/2014 - 2:37pm

I've been programming in haskell for over a year now, but still have yet to pick up Real World Haskell and read it all the way through. I finally decided that I would make the effort and read it all the way through, but because it came out 6 years ago I'm wondering if some parts of it might now be outdated and obsolete.

In the interest of not picking up bad practices, I come to you: are there any sections of Real World Haskell that may have outdated-enough content to warrant me not applying them to real projects?

Thank you!

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

Exciting new opportunity at CyLab/Carnegie Mellon University!

Haskell on Reddit - Wed, 06/25/2014 - 1:07pm

We're looking for talented hackers who are interested in security research. The projects involve exploitation, defense, and malware analysis. We are seeking someone with a strong background in reversing and writing exploits against program binaries. Compiler knowledge a big plus. We write our code in OCaml and C, but experience with any functional programming language such as Haskell, SML, Clojure is welcomed. This position focuses on improving our current infrastructure for automatic exploit generation and will help with the development of a fully automated system that plays in computer security tournaments such as “Capture the Flag”. The system will compete in real-time to find vulnerabilities, exploit adversaries, and generate and deploy security patches. Responsibilities include program analysis for x86 code in an OCaml infrastructure and development of new features through data-driven iterations.

The position is at Carnegie Mellon University in CyLab with Prof. David Brumley. You'd also be working with PhD students and undergrads. For more information on these security projects, visit If interested, please click here

This full time staff position at Carnegie Mellon University comes with excellent benefits such as free tuition benefits, numerous medical & dental plans, free public transportation, 8% contribution to a retirement account, generous paid time off (PTO), and a great work environment. You can get more information here

Carnegie Mellon University is an EEO/Affirmative Action Employer – M/F/Disability/Veteran

submitted by cmu-recruiting
[link] [comment]
Categories: Incoming News

[learn] Reasoning about time and space complexity

Haskell on Reddit - Wed, 06/25/2014 - 12:03pm

I'm trying to figure out what can be said mathematically about the time and space complexity of lazy programs. Here's what I know so far:

  • If we look at whole programs, then the time complexity of lazy evaluation is asymptotically at least as good as eager evaluation, but space complexity might be worse.

  • If we look at individual functions in a lazy language, things are less clear. Some functions, like quicksort, seem to have a well-defined time and space complexity, which is roughly "how much time and space this function would use if both the arguments and the result were fully evaluated", assuming that both are finite. But that definition is not enough to analyze some uses of these functions, like implementing quickselect in terms of quicksort. And it doesn't seem to work for functions that are intended to deal with infinite data structures, like repeat. Time is just as problematic as space in this regard.

  • Okasaki's book has a nice approach to analyzing some lazy data structures, though it doesn't seem to generalize to everything you can write in a lazy language.

The question is, where should I look next? How do people analyze the time and space complexity of functions in a lazy language, both in theory and in practice?

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

accessing a ByteArray from FFI

haskell-cafe - Wed, 06/25/2014 - 11:58am
Hello, I want to access the contents of a Data.Vector.Primitive from FFI. I came up with the following so far: {-# LANGUAGE ForeignFunctionInterface #-} module FFIExample (exampleFn) where import Control.Monad.Primitive (touch) import Control.Monad.ST (runST) import Data.Primitive.Addr (Addr(..)) import Data.Primitive.ByteArray (mutableByteArrayContents) import qualified Data.Vector.Primitive as P import qualified Data.Vector.Primitive.Mutable as PM import GHC.Ptr (Ptr(..), plusPtr) import Data.Word (Word64) foreign import ccall unsafe "my_external_fn" myExternalFn :: Ptr Word64 -> Int -> Int exampleFn :: P.Vector Word64 -> Int exampleFn v = runST $ do   PM.MVector off len mba <- P.unsafeThaw v   let ptr = case mutableByteArrayContents mba of         Addr addr -> Ptr addr `plusPtr` off       result = myExternalFn ptr len   result `seq` touch mba   return result This seems to work, but I have questions that I haven't been able to find the answers to on my own: 1. Is this actually OK to do?
Categories: Offsite Discussion

Quantification in Instance Contexts

haskell-cafe - Wed, 06/25/2014 - 10:46am
Hi Cafe, I'm playing around with simple logic-programming at the type level. For instance, encoding trees: Now the following obviously doesn't work (never mind for now that 'Path' needs a recursive definition, and that this is really just 'Grandchild'): Because 'b' is ambiguous. Fair enough. But I can't directly use a fundep, because 'b' *is* in fact ambiguous. What I want to tell the compiler is that it's really okay, since the RHS side (and any possible 'where' expressions) doesn't depend on what is instantiated for 'b'. I know I could switch to a class 'Children a bs bool' and encode all children of as a type-level list, and then have a fundep between 'a' and 'bs'. That's not a *bad* solution: it does give a good sense of the intention. But it's not very extensible; really I'd rather be using something like 'forall' - something, I would guess, along the lines of: That, however, fails with: Malformed instance head: (forall b. (Child a b TrueT, Child b c
Categories: Offsite Discussion

Algorithm critique requested

Haskell on Reddit - Wed, 06/25/2014 - 10:16am

A while back I had a job interview where I had to write a function that would test if a string was a palindrome. I was able to pick whichever language I wanted (from a list).

I started thinking about how it would be easy to express this algorithm in haskell, so this morning I decided to try it out.

I've been learning about haskell off and on for about a year, but haven't really implemented anything too significant, so I wanted to get some input on this, if anyone is interested in taking a look.

palindrome :: Eq a => [a] -> Bool palindrome [] = True palindrome (x:[]) = True palindrome (x:_:y:[]) = x == y palindrome xs | head xs /= last xs = False | head xs == last xs = palindrome $ stripFirstAndLast xs where stripFirstAndLast ys = tail $ reverse $ tail $ reverse ys

If you want syntax highlighting:

submitted by zexperiment
[link] [7 comments]
Categories: Incoming News

Monad laws

haskell-cafe - Wed, 06/25/2014 - 4:54am
Hello, You guys have been great taking my questions. Thank you. Now I have another one :) What can go wrong if I make an Monad instance but don't follow Monad rules (identity and associativity)? Sure it would be misleading for someone using the non-conforming class. They may make code that assume those laws, although they don't hold. However, could it make the compiler generate bad code or some standard functions to behave badly or even break? []'s Rafael _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion