News aggregator

Guide/Tutorial for Template Haskell?

Haskell on Reddit - Tue, 08/11/2015 - 8:41pm

Type level programming and Template Haskell seem like the magickal realms of Haskell. Type level programming is starting to get more and more blog posts and tutorials for, but I haven't really seen anything that details how to use Template Haskell or when it's a great idea to use. Could anyone point to some guides, tutorials, or other learning resources for this?

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

ANN: stack-0.1.3.0

Haskell on Reddit - Tue, 08/11/2015 - 8:16pm
Categories: Incoming News

ANN: stack-0.1.3.0

Haskell on Reddit - Tue, 08/11/2015 - 8:16pm
Categories: Incoming News

What Math topics I must know to understand the inner workings of Haskell?

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

I really want to understand the mathematical underpinnings of Haskell and functional programming in general. I am basically a developer and I have coded in many other languages before coming to Haskell. With regards to Haskell, I consider myself an advanced beginner because I do understand Functors, Monads, Applicatives and some advanced Haskell concepts, but from a programmer's perspective.

I do not have a formal CS or Math background. I learned first order predicate logic by myself. Where should I go from here? What topics from CS theory should I study? What topics from Maths should I study?

submitted by wbaig
[link] [10 comments]
Categories: Incoming News

Brent Yorgey: Catsters guide is complete!

Planet Haskell - Tue, 08/11/2015 - 3:03pm

About a year and a half ago I announced that I had started creating a guide to the excellent series of category theory YouTube videos by the Catsters (aka Eugenia Cheng and Simon Willerton). I am happy to report that as of today, the guide is finally complete!

As far as possible, I have tried to arrange the order so that each video only depends on concepts from earlier ones. (If you have any suggestions for improving the ordering, I would love to hear them!) Along with each video you can also find my cryptic notes; I make no guarantee that they will be useful to anyone (even me!), but hopefully they will at least give you an idea of what is in each video.

If and when they post any new videos (pretty please?) I will try to keep it updated.


Categories: Offsite Blogs

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
glType _ = GL_UNSIGNED_INT

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. http://functionaljobs.com/jobs/8856-software-engineer-researcher-at-galois-inc Cheers, Sean Murphy FunctionalJobs.com
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 http://shakebuild.com.

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