# News aggregator

### direct-fastcgi and logging

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

### Tim Docker: Teenage Haskell

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:

- you edit haskell code in your browser
- it gets compiled to java script on the remote server using ghcjs
- 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 -> Picturewhich 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…

SummaryFor 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!

### Tutorial: Profiling Cabal projects

### What would you want out of a Cabal enhancement package?

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]

### wren gayle romano: Solving Chain Multiplication

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.

comments

### wren gayle romano: A problem with performativity

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.

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... )**

comments

### Real World Haskell - Outdated Parts?

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]

### Boston Hackathon is Coming! August 1-3!

### Exciting new opportunity at CyLab/Carnegie Mellon University!

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 http://security.ece.cmu.edu. 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]

### [learn] Reasoning about time and space complexity

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]

### accessing a ByteArray from FFI

### Quantification in Instance Contexts

### Algorithm critique requested

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 ysIf you want syntax highlighting: https://gist.github.com/z3roshot/b0fba486ecaec9917d04

submitted by zexperiment[link] [7 comments]