News aggregator

Default implementation for <*>

Haskell on Reddit - Tue, 08/11/2015 - 1:42pm

Hello all

I was wondering why Applicative doesn't have a default implementation for (<*>). The following should be correct for any possible Applicative (since an Applicative is a Functor):

a <*> b = fmap (flip fmap b) a

Is there any reason this isn't done that I'm not thinking of? This should give close to the same code one would write by hand anyway, and you can always override for your class if you care to.

submitted by nicheComicsProject
[link] [1 comment]
Categories: Incoming News

Mark Jason Dominus: Reordering git commits with git-commit-tree

Planet Haskell - Tue, 08/11/2015 - 11:44am

I know, you want to say “Why didn't you just use git-rebase?” Because git-rebase wouldn't work here, that's why. Let me back up.

Say I have commit A, in which feature X does not exist yet. Then in commit C, I implement feature X.

But I realize what I really wanted was to have A, then B, in which feature X was implemented but disabled, and then C in which feature X was enabled. The C I want is just like the C that I have, but I don't have the intervening B.

I have:

no X X on A --------------- C

I want:

no X X off X on A ------ B ------ C

One way to do this is to use git-rebase in edit mode to split C into B and C. To do this I would pause while rebasing C, edit C to disable feature X, commit the result, which is B, then undo the previous edits to re-enable X, and continue the rebase, creating C. That's two sets of edits. I could backup the files before the first edit and then copy them back for the second edit, but that's the SVN way, so I'm not going to do that.

Now someone wants me to use git-rebase to “reorder the commits”. Their idea is: I have C. Edit C to disable feature X and commit the result as B':

no X X on X off A ------ C ------ B'

Now use interactive git-rebase to reorder B and C. But this will not work. git-rebase will construct a patch for turning C into B' and will try to apply it to A. This will fail completely, because a patch for turning C into B' is a patch for turning off feature X once it is implemented. Feature X is not in A and you can't turn something off that isn't there. So the rebase will fail to apply the patch.

What I did instead was rather bizarre, using a plumbing command, but worked well. I wrote the code to disable X, and committed it as B, obtaining this:

no X X on X off A ------ C ------ B

Now B and C have the files I want in them, but their parents are wrong. That is, the history is in the wrong order, but if the parent of C was B and the parent of B was A, eveything would be perfect.

But we can't just change the parents; we have to create a new commit, say B', which has the same files as B but whose parent is A instead of C, and we have to create a new commit C' which has the same files as C but whose parent is B' instead of A.

This is what git-commit-tree does. You give it a tree object containing the files you want, a list of parents, and a commit message, and it creates the commit you asked for and prints its SHA1.

When we use git-commit, it first turns the index into a tree, with git-write-tree, then creates the commit, with git-commit-tree, and then moves the current head ref up to the new commit. Here we will use git-commit-tree directly.

So I did:

% git checkout -b XX A Switched to a new branch 'XX' % git commit-tree -p HEAD B^{tree} 10ddf433039fd3cbc5bec0c64970a45add15482e % git reset --hard 10ddf433039fd3cbc5bec0c64970a45add15482e % git commit-tree -p HEAD C^{tree} ce46beb90d4aa4e2c9fe0e2e3d22eea256edceac % git reset --hard ce46beb90d4aa4e2c9fe0e2e3d22eea256edceac

The first git-commit-tree

% git commit-tree -p HEAD B^{tree}

says to make a commit whose tree is the same as B's, and whose parent is the current HEAD, which is A. (B^{tree} is a special notation that means to get the tree from commit B.) Git pauses here to read the commit message from standard input (not shown), and prints the SHA of the new commit on the terminal. I then use git-reset to move the current head ref, XX, up to the new commit. Normally git-commit would do this for us, but we're not using git-commit today.

Then I do the same thing with C:

% git commit-tree -p HEAD C^{tree}

makes a new commit whose tree is the same as C's, and whose parent is the current head, which looks just like B. Again it reads a commit message from standard input, and prints the SHA of the new commit on the terminal, and again I use git-reset to move XX up to the new commit.

Now I have what I want and I only had to edit the files once. To complete the task I just reset the head of my working branch to wherever XX is now, discarding the old A-C-B branch in favor of the new A-B-C branch. If there's an easier way to do this, I don't know it.

It seems to me that there have been a number of times in the past when I wanted to do something like reordering commits, and git-rebase did not do what I wanted because it reorders patches and not commits. I should keep my eyes open, and see if this comes up again, and if it is worth automating.

[ Thanks to Jeremy Leader for suggesting I write this up and to Jeremy Leader and Rik Signes for advance editing. ]

[ Adendum 20150813: a followup article ]

Categories: Offsite Blogs

Is there any higher resolution images of Haskell Curry?

Haskell on Reddit - Tue, 08/11/2015 - 9:43am

Me and my student group are currently in the process of redecorating our student facilities in our university. Of course, we have to have a hall of fame with our heroes such as Turing, Dijkstra, Lovelace and Haskell Curry. Unfortunately, we're having a hard time finding an image of Haskell Curry with decent resolution, is this something r/haskell can help us with? All we can find is basically this image, which would be perfect if it just were a bit larger.

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

Is there any higher resolution images of Haskell Curry?

Haskell on Reddit - Tue, 08/11/2015 - 9:43am

Me and my student group are currently in the process of redecorating our student facilities in our university. Of course, we have to have a hall of fame with our heroes such as Turing, Dijkstra, Lovelace and Haskell Curry. Unfortunately, we're having a hard time finding an image of Haskell Curry with decent resolution, is this something r/haskell can help us with? All we can find is basically this image, which would be perfect if it just were a bit larger.

submitted by nyson
[link] [19 comments]
Categories: Incoming News

How to download a set of packages and documentation from Hackage for use off-line?

Haskell on Reddit - Tue, 08/11/2015 - 9:28am

(Oops I'm meant Stackage in the title if that's significant ...)

I'm going to offline for a couple of weeks in a short while but since I'm still learning Haskell I'd like to keep it up. I can guess at which packages off of Stackage (I use stack now) I'd like to use. Is there a way for me to download a selected set of packages and their documentation so that I can use it when I have no Internet access?

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

Dimitri Sabadie: Luminance – what was that alignment stuff already?

Planet Haskell - Tue, 08/11/2015 - 7:56am

Yesterday, I released a new article about how I implement vertex arrays in luminance. In that article, I told you that the memory was packed with alignment set to 1.

Well, I’ve changed my mind. Some people pointed out that the good thing to do for most GPU is to align on 32-bit. That is, 4 bytes. The alignment should be 4 bytes, then, not 1.

There might be an issue with that. If you store a structure with attributes which sizes are not a multiple of 4 bytes, it’s likely you need to add padding.

However, I just reviewed my code, and found this:

instance (GPU a,KnownNat n,Storable a) => Vertex (V n a) where
instance (Vertex a,Vertex b) => Vertex (a :. b) where

Those are the single instances for Vertex. That means you can only use V and (:.) to build up vertices. Look at the V instance. You’ll find a GPU typeclass constraint. Let’s look at its definition and instances:

class GPU a where
glType :: Proxy a -> GLenum

instance GPU Float where
glType _ = GL_FLOAT

instance GPU Int32 where
glType _ = GL_INT

instance GPU Word32 where

Woah. How did I forget that?! Let me translate those information to you. That means we can only have 32-bit vertex component! So the memory inside vertex buffers will always be aligned on 4 bytes! No need to worry about padding then!

The first implication is the fact you won’t be able to use Word16, for instance. You’ll need to stick to the three types that have a GPU instance.

Note: that doesn’t prevent us from adding Double later on, because a Double is a 64-bit type, which is a multiple of 4 bytes!

That’s all I have for today. I’m working on something very exciting linked to render batching. I’ll talk about that when it’s cooked. ;)

Keep the vibe; keep building awesome things, and as always, thank you for reading me!

Categories: Offsite Blogs

New Functional Programming Job Opportunities

haskell-cafe - Mon, 08/10/2015 - 5:00pm
Here are some functional programming job opportunities that were posted recently: Software Engineer / Researcher at Galois Inc. Cheers, Sean Murphy
Categories: Offsite Discussion

Neil Mitchell: Upcoming talk to the Cambridge UK Meetup, Thursday 13 Aug (Shake 'n' Bake)

Planet Haskell - Mon, 08/10/2015 - 2:13pm
I'll be talking at the Cambridge NonDysFunctional Programmers Meetup this coming Thursday (13 Aug 2015). Doors open at 7:00pm with talk 7:30-8:30pm, followed by beer/food. I'll be talking about Shake 'n' Bake. The abstract is:

Shake is a Haskell build system, an alternative to Make, but with more powerful and accurate dependencies. I'll cover how to build things with Shake, and why I laugh at non-Monadic build systems (which covers most things that aren't Shake). Shake is an industrial quality library, with a website at

Bake is a Haskell continuous integration system, an alternative to Travis/Jenkins, but designed for large semi-trusted teams. Bake guarantees that all code arriving in your master branch passes all tests on all platforms, while using as few resources as possible, allowing you to have hours of tests, 100's of commits a day and one a few lonely test servers. Bake is held together with duct tape.

I look forward to seeing people there.
Categories: Offsite Blogs

Unregisterised builds

haskell-cafe - Mon, 08/10/2015 - 2:06pm
Good day all, I am still having issues with (the output from) the cross compiler I have built for PowerPC (e500 family). It seems the runtime is vaguely sane in that it's purposefully whirring round schedule() but for some reason for a "Hello World" allocates stack then heap (after ^C) then runs out then locks up but does not exit. I don't (yet) understand the runtime enough to find the boundary between behaving and not. /tmp # ./helloworld +RTS -Ds created capset 0 of type 2 created capset 1 of type 3 cap 0: initialised assigned cap 0 to capset 0 assigned cap 0 to capset 1 new task (taskCount: 1) cap 0: created thread 1 new bound thread (1) cap 0: schedule() cap 0: running thread 1 (ThreadRunGHC) cap 0: thread 1 stopped (yielding) cap 0: running thread 1 (ThreadRunGHC) cap 0: thread 1 stopped (yielding) cap 0: running thread 1 (ThreadRunGHC) cap 0: thread 1 stopped (yielding) cap 0: running thread 1 (ThreadRunGHC) cap 0: thread 1 stopped (stack overflow) cap 0: allocating new stack chunk of size 32768 byt
Categories: Offsite Discussion

How to install `network` with MinGHC 7.10.2?

Haskell on Reddit - Mon, 08/10/2015 - 12:49pm

According to the README MinGHC bundles MSYS "so packages with configure scripts (notably network) compile.". However, after a fresh install of I get told that MSYS seems to be missing. What am I doing wrong?

C:\Users\Harold\sandbox>cabal install network Resolving dependencies... Configuring network- cabal: The package has a './configure' script. This requires a Unix compatibility toolchain such as MinGW+MSYS or Cygwin. Failed to install network- cabal: Error: some packages failed to install: network- failed during the configure step. The exception was: ExitFailure 1 submitted by fpnoob
[link] [26 comments]
Categories: Incoming News

Working around rate limiting API using ``http-conduit``

Haskell on Reddit - Mon, 08/10/2015 - 12:15pm

I need to know if this is an okay way to do it, how I could improve it, and if there are any standard practices for working with a nginx-based service which returns http503 to implement rate limiting.

Consider the following git commit:

In particular, the following code:

rateLimit :: IO (Either NetCon.HttpException c) -> (Either NetCon.HttpException c -> IO d) -> IO d rateLimit act1 act2 = go 500000 where go del = do resp <- act1 if isRateLimited resp then if del > maxLimit then act2 resp else do threadDelay del go (incDelay del) else act2 resp maxLimit = (30 * 1000 * 1000) -- 30 seconds probably means something else is wrong... incDelay = round . (* (1.5 :: Double)) . fromIntegral isRateLimited :: Either NetCon.HttpException a -> Bool isRateLimited (Left (NetCon.StatusCodeException st _ _)) = st == status503 isRateLimited _ = False

I am basically checking rate limiting by looking for a 530 status, and then redoing the request after a delay (which increases at every failed attempt), and quiting if the delay reaches 30 seconds.

What is the standard way to deal with rate limiting? Is my solution lacking in some way?

The API in question is this one:

Non-authenticated API calls are rate limited to 10 per minute. Authenticated API calls are rate limited to 60 per minute. API call rate limits allow bursts up to 5 consequitive calls. Exceeding the limit causes error 503 to be returned.

You will notice that I completely ignored the numbers and just sucked 500 milliseconds, 1.5, and 30 seconds out of my thumb.

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

Having trouble constructing curried functions in LYAH, and some general questions.

Haskell on Reddit - Mon, 08/10/2015 - 11:42am

Hey everyone, I'm currently going through LYAH and I'm a little confused about what I can and can't do. The function below is a function that was given as an example in LYAH. divideByTen :: (Floating a) => a -> a
divideByTen = (/10)

What's the significance of doing Floating a at the start?

Also what is the significance of the "=>"

Why don't we just declare it to be an Int or a Float ?

Inspired by this and from experience I'm trying to play around and make my own curried functions to get a better understanding of how this works. isEven :: (Ord a, Num a) => a -> a isEven = ((mod 2) == 0)

It's giving me an error though. I think that the following sentence which was mentioned is helpful but I'm not sure in what way " To section an infix function, simply surround it with parentheses and only supply a parameter on one side"

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

[PADL 2016] First call for papers

General haskell list - Mon, 08/10/2015 - 10:45am
Call for Papers =============== 18th International Symposium on Practical Aspects of Declarative Languages (PADL 2016) St. Petersburg, Florida, United States Mon 18 - Tue 19 January 2016 Co-located with ACM POPL 2016 Conference Description ====================== Declarative languages build on sound theoretical bases to provide attractive frameworks for application development. These languages have been successfully applied to many different real-world situations, ranging from data base management to active networks to software engineering to decision support systems. New developments in theory and implementation have opened up new application areas. At the same time, applications of declarative languages to novel problems raise numerous interesting research issues. Well-known questions include designing for s
Categories: Incoming News