News aggregator

Loop School

del.icio.us/haskell - Fri, 03/20/2015 - 5:05pm
Categories: Offsite Blogs

Doctoral Teaching Assistantships in CS at Oxford

General haskell list - Fri, 03/20/2015 - 4:08pm
DOCTORAL TEACHING ASSISTANTSHIPS SOFTWARE ENGINEERING PROGRAMME DEPARTMENT OF COMPUTER SCIENCE, UNIVERSITY OF OXFORD The University of Oxford's Computer Science department is offering two DPhil (PhD) scholarships. The scholarships are for up to five years; they include teaching responsibilities on the department's Software Engineering Programme (SEP), which has been running for over twenty years, offering part-time professional Master's degrees in Software Engineering and in Software & Systems Security. Each scholarship provides a stipend (£14057 pa from October 2015, with small annual increases subsequently) plus full fees. The Department of Computer Science was established in 1957, making it one of the longest established in the country. It is one of the UK's leading computer science departments, ranked first in a number of international rankings. The latest Research Excellence Framework (REF 2014) resulted in the 74 members of the Department having 87% of their research activity ranked 4* ("world-leadi
Categories: Incoming News

Why isn't anyone talking about optimal lambda calculus implementations?

Haskell on Reddit - Fri, 03/20/2015 - 3:39pm

On 1990, John Lamping proposed an optimal algorithm for lambda calculus reduction as per Levy's notion. As far as my understanding goes, it works by translating lambda calculus terms to interaction nets, reducing them, and translating back. Interaction nets are a computational model based on graph rewriting with interesting properties such as computation being local and asynchronous (different from, say, automatas, which are local but synchronized). They are very interesting by themselves, having universal combinators akin to SKI, connections to linear logic, biology, etc. That's not the point, though: what most of this means for functional programming is that John's system is not only optimal on the sense that the minimal amount of duplication is guaranteed (making, i.e., lazy evaluation irrelevant) but is also very promising for the possibility of parallelization exploiting.

Yet, 25 years have passed and there is only one implementation of those ideas on Hackage, which is undocumented and, as far as my source-code-stalking goes, possibly incomplete, since I couldn't find a function to map from nets back to lambdas (it might be there, though).

Anyway, the question holds: why is there almost no interest in implementing those ideas and seeing how well they go in practice?

submitted by SrPeixinho
[link] [22 comments]
Categories: Incoming News

Strongly typed data / API specification librares

haskell-cafe - Fri, 03/20/2015 - 1:06pm
Hi cafe, Does anyone know of any libraries that allow one to describe data / interfaces (think IDLs), with emphasis on good support for modules, strong typing and extensibility? I am thinking in the lines of Thrift[1], Piqi[2], Swagger[3], but with the core data specification language as decoupled as possible from any kind of implementation related things (such as actual representation of data, or RPC / RESTful bindings). haskell-servant[4] and silk-rest[5] are kind of relevant, but they are very much oriented towards RESTful APIs. Sorry if this is slightly off-topic, but I couldn't think anywhere else to inquire about this. Thanks, Ignas [1]: https://thrift.apache.org/ [2]: http://piqi.org/ [3]: http://swagger.io/ [4]: http://haskell-servant.github.io/ [5]: http://silkapp.github.io/rest/
Categories: Offsite Discussion

Lens is unidiomatic Haskell

Haskell on Reddit - Fri, 03/20/2015 - 11:05am
Categories: Incoming News

Philip Wadler: Status Report 3

Planet Haskell - Fri, 03/20/2015 - 8:13am


I have a date for keyhole surgery to remove my kidney: Tuesday 17 March. This fits what I was told previously, so all is to schedule. Recovery time is likely to be four weeks. I expect to be in hospital until Monday 23 March: visitors most welcome! Please call the Western General, or Level 4 office has my contact details.

My liver biopsy took place on Thursday 19 February; the hardest part was to lie still for six hours after. I had meetings with my infectious disease doctor on Wednesday 25 February and with my cardiologist on Monday 2 March. My endocarditis is clear, but will need to be monitored once a year. The biopsy shows a deposit of amyloid protein; experts are being consulted, but it has no effect on my surgery. My thanks to all my doctors and the staff at the Western General, who have been excellent.


Related: Status report, Status report 2, A paean to the Western General, Status report 4.
Categories: Offsite Blogs

apt-get install haskell-platform fails on ubuntu14.04

haskell-cafe - Fri, 03/20/2015 - 7:10am
http://askubuntu.com/questions/597278/haskell-platform-unmet-dependencies I'm installing on a newly-built system. I looked at the haskell.org download instructions, and I couldn't find anything that made sense. apt-get install haskell-platform worked about a month ago. Does anyone know what happened? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Existentials for multi-parameter type classes?

haskell-cafe - Fri, 03/20/2015 - 6:11am
Hi folks, I know how to write existentially quantified data constructors for single-parameter type classes, but I'm having trouble doing it for multi-parameter type classes. Is it not possible, or am I just using the wrong syntax? I have this class: class Collidable a b where collideWith :: a -> b -> String And I tried to define an existentially quantified data constructor thusly: data Collision = forall a. (forall b. Collidable a b => Collision {collider1 :: a, collider2 :: b}) I get a parse error. So then I tried: data Collision = forall a. forall b. Collidable a b => Collision {collider1 :: a, collider2 :: b} I get a different parse error. Is there any way to make this work? Thanks, Lyle _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Proposal: parametrize tree stem container type in containers

libraries list - Thu, 03/19/2015 - 10:31pm
A few years ago I uploaded the package generic-tree to Hackage (before I knew the customary version scheme, sorry about that) which has trees parametrized over stem container type: data Tree v a = Node a (v (Tree v a)) As this is a functional superset of the containers tree, I think it appropriate to include in containers, which I hereby propose. Ultimately, if this is accepted, I would like to define the list-specialized tree in terms of this.
Categories: Offsite Discussion

First order pattern matching.

Haskell on Reddit - Thu, 03/19/2015 - 7:59pm

Title edit: not first order, first class*

Is there any language extension that enables first-class pattern matching? For example:

((a,b) => a+b) (1,2) == 3 (x:xs => xs) [1,2,3] == [2,3]

In general,

(pattern => match)

Equates to

(\ x -> let pattern = x in match) submitted by Hadkell
[link] [11 comments]
Categories: Incoming News

Staggered zip, or fold with 2 elements at a time

Haskell on Reddit - Thu, 03/19/2015 - 7:34pm

If there is a better location to post this question, please let me know.

Suppose given

1. A finite list x = [x^1, x^2 .. x^n] 2. A pure binary function h, and pure unary functions f and g.

It is pretty easy to apply the functions to every element of x, with higher-order functions instead of recursion:

aligned1 f g h x = (h <$> f <*> g) `map` x aligned2 f g h x = (\p -> h (f p) (g p)) `map` x

Here, x is traversed one element at a time and the fused functions are applied to produce an element of the result. Sequential evaluation is not needed because each element of the result only depends on one element of x. Also, the higher-order function takes care of the raw recursion.

Is there a way to achieve the same for the following?

y^1 = f x^1 y^(n+1) = g x^n y^i = h ( f x^i ) ( g x^(i-1) )

For example, if h = (+) and f,g :: a -> Int, the job would get done with:

staggered1 f g x = zipWith (+) ((map f x) ++ [0]) (0 : map g x)

This code zips the following two lists with addition (+):

[ f x^1 , f x^2 .. f x^n , 0 ] [ 0 , g x^1 .. g x^(n-1) , g x^n ]

Alternatively, one could map f and g on x, and then use raw recursion to zip the two lists:

staggered2 f g h x = y : inner ys zs where y:ys = map f x zs = map g x inner [] (q:qs) = q : inner [] qs inner (p:ps) (q:qs) = h p q : inner ps qs inner _ _ = []

Or, an accumulator variable could be used to store the previous x or (f x):

staggered3a f g h (x:xs) = (f x) : inner x xs where inner acc [] = g acc : [] inner acc (y:ys) = h (f y) (g acc) : inner y ys staggered3b f g h (x:xs) = f x : inner (g x) xs where inner acc [] = acc : [] inner acc (y:ys) = h (f y) acc : inner (g y) ys

More generally, this accumulator could even be a queue to store several consecutive elements at once...

Is there an elegant way to zip staggered maps on the same list, or fold consecutive elements at a time? The goal is to traverse x only once, avoid raw recursion with higher order functions, preserve the local dependence on consecutive elements of x, and avoid forcing sequential execution.

Are there existing libraries that do this? Maybe a generalization of this concept?

BONUS (pat on the back) for applicative style.

PS. In my context, (f xi ) is the remainder from applying (g xi ), and vice versa. So, in theory, they could be calculated at the same time. I haven't found a way to do this yet, but that's a whole other question :)

submitted by newestHaskeller
[link] [20 comments]
Categories: Incoming News

Mark Jason Dominus: Rectangles with equal area and perimeter

Planet Haskell - Thu, 03/19/2015 - 6:00pm

Wednesday while my 10-year-old daughter Katara was doing her math homework, she observed with pleasure that a rectangle has a perimeter of 18 units and also an area of 18 square units. I mentioned that there was an infinite family of such rectangles, and, after a small amount of tinkering, that the only other such rectangle with integer sides is a square, so in a sense she had found the single interesting example. She was very interested in how I knew this, and I promised to show her how to figure it out once she finished her homework. She didn't finish before bedtime, so we came back to it the following evening.

This is just one of many examples of how she has way too much homework, and how it interferes with her education.

She had already remarked that she knew how to write an equation expressing the condition she wanted, so I asked her to do that; she wrote $$(L×W) = ([L+W]×2).$$ I remember being her age and using all different shapes of parentheses too. I suggested that she should solve the equation for , getting on one side and a bunch of stuff involving on the other, but she wasn't sure how to do it, so I offered suggestions while she moved the symbols around, eventually obtaining $$W = 2L\div (L-2).$$ I would have written it as a fraction, but getting the right answer is important, and using the same notation I would use is much less so, so I didn't say anything.

I asked her to plug in and observe that popped right out, and then similarly that yields , and then I asked her to try the other example she knew. Then I suggested that she see what did: it gives , This was new, so she checked it by calculating the area and the perimeter, both . She was very excited by this time. As I have mentioned earlier, algebra is magical in its ability to mechanically yield answers to all sorts of questions. Even after thirty years I find it astonishing and delightful. You set up the equations, push the symbols around, and all sorts of stuff pops out like magic. Calculus is somehow much less astonishing; the machinery is all explicit. But how does algebra work? I've been thinking about this on and off for a long time and I'm still not sure.

At that point I took over because I didn't think I would be able to guide her through the next part of the problem without a demonstration; I wanted to graph the function and she does not have much experience with that. She put in the five points we already knew, which already lie on a nice little curve, and then she asked an incisive question: does it level off, or does it keep going down, or what? We discussed what happens when gets close to 2; then shoots up to infinity. And when gets big, say a million, you can see from the algebra that is a hair more than 2. So I drew in the asymptotes on the hyperbola.

Katara is not yet familiar with hyperbolas. (She has known about parabolas since she was tiny. I have a very fond memory of visiting Portland with her when she was almost two, and we entered Holladay park, which has fountains that squirt out of the ground. Seeing the water arching up before her, she cried delightedly “parabolas!”)


Once you know how the graph behaves, it is a simple matter to see that there are no integer solutions other than and . We know that does not work. For the value of is always strictly between and . For there is no value of that works at all. For the formula says that is negative, on the other branch of the hyperbola, which is a perfectly good numerical solution (for example, ) but makes no sense as the width of a rectangle. So it was a good lesson about how mathematical modeling sometimes introduces solutions that are wrong, and how you have to translate the solutions back to the original problem to see if they make sense.

[ Addendum 20150330: Thanks to Steve Hastings for his plot of the hyperbola, which is in the public domain. ]

Categories: Offsite Blogs

ANN: Magic Cookies! Android board game in Haskell

haskell-cafe - Thu, 03/19/2015 - 4:11pm
Dear Café This is a just a quick announcement: we have just released Magic Cookies, an Android board game written in Haskell. It is now available on Google Play [1]. The game uses the Functional Reactive Programming library Yampa and SDL2 for multimedia. If you like the game, please share the link on facebook/twitter/etc and let all of your friends know. We have gone through dozens of iterations during beta testing, but we cannot guarantee that the game works 100% perfectly on all devices. If you find a bug, or anything else you don't like, please do not rate low. Instead, open an issue [2] or send us an email (support< at >keera.co.uk). Suggestions are also welcome. We will continue working to make the game lighter, faster, and more fun. See [3] for more details, and to sign up as a beta-tester for other games we are already working on. We certainly enjoyed making it, and we hope you all enjoy playing it. All the best Ivan, Fass & Jorge [1] https://play.google.com/store/apps/details?id=uk.co.keera.game
Categories: Offsite Discussion

Noam Lewis: A simple bash script for monitoring the output of a running process

Planet Haskell - Thu, 03/19/2015 - 2:21pm

I got tired of my screen getting flooded with text when all I wanted was to see the last output line at any given time. What I really want is to just see one output line and have it replaced with some newer text when it’s available. So I wrote a script (in, ahem, bash) that lets your do exactly this. Call it “tailor.sh” or whatever you want:

(If the code below is screwed up, see it here on gist)

#!/bin/bash -eu LOG_FILE=$1 SB="stdbuf -i0 -oL" shift tput sc $@ 2>&1 \ | $SB tee $LOG_FILE \ | $SB cut -c-$(tput cols) \ | $SB sed -u 's/\(.\)/\\\1/g' \ | $SB xargs -0 -d'\n' -iyosi -n1 bash -c 'tput rc;tput el; printf "\r%s" yosi' EXIT_CODE=${PIPESTATUS[0]} tput rc;tput el;printf "\r" # Delete the last printed line exit $EXIT_CODE

I use it in a test env bringup script to run some builds. Instead of having to lose all the context of the wrapping script, I now see just a single output line of the invoked builds at any given time.


Categories: Offsite Blogs