News aggregator

Problem installing dependencies

Haskell on Reddit - Tue, 04/29/2014 - 10:19am

I am trying to install the dependencies for a project but I am running into this error:

Failed to install base-unicode-symbols-0.2.2.4 cabal: Error: some packages failed to install: base-unicode-symbols-0.2.2.4 failed during the final install step. The exception was: /tmp/pkgConf-base-unicode-symbols-0.2.25614.4: hGetContents: invalid argument (invalid byte sequence)

How do I fix it?

Thanks,

James

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

Chris Reade: Red-Black Neighbourhood Stencil Diagrams

Planet Haskell - Tue, 04/29/2014 - 10:05am
Red-Black Neighbourhood Stencil Diagrams (for Laplace)

In a previous blog Repa Laplace and SOR, I used Repa to implement a Laplace solver using the Red-Black scheme. The explanation of alternating stencils probably needed a diagram, so here it is.

This diagram illustrates the shapes of the stencils for adding neighbours of red and black cells. It shows that two different stencils are needed (for odd and even rows) and these are swapped over for red and black.

Red-Black Neighbour Stencils

(The diagram was produced with Haskell Diagrams)


Categories: Offsite Blogs

Douglas M. Auclair (geophf): 'Y' is for Y-Combinator

Planet Haskell - Tue, 04/29/2014 - 9:45am

So, the Y-combinator is from the lambda calculus. It is of the form:
Y = λ f → f (Y f)
Wow. The thing about the Y-combinator, also called the fixpoint function, is that it's a big mess, type-wise, because sometimes you'll get no value out of it (as it does not terminate for many cases of functions) or sometimes you'll get multiple values out of it.
But what is it supposed to do? It's supposed to find the 'fixed' point of a function, the point of the function where it is 'fixed,' or comes to rest.
This is usually the case of a function with multiple cases, a case 'at rest' and an inductive case, like our good old friend, factorial:
factorial x = if (x = 0) then 1 else x * factorial (x -1)
for any natural number x.
The fixed point of this factorial function is one:
factorial x (where x = 1) = x
If you put this into the Y-combinator, you get:
Y factorial = factorial (Y factorial)
and when apply the natural number 1 you get
Y factorial 1 = factorial (Y factorial) 1
which comes to rest at 1 = 1
for any other number, this doesn't come to rest.
So, the Y-combinator is a very simple thing to define (as you saw above) and there's nothing in that definition about recursion (explicitly), but in computer science the Y-combinator is often used to model and to study recursion because of both its restful and (infinitely) inductive properties.
Okay, that's Y-combinator, the combinator from combinatory logic.
So, there's another Y-Combinator, and that's the name of a startup company headed up by Paul Graham (the Paul Graham, who wrote On Lisp).  I had the pleasure of meeting Paul at the Little Languages conferences at MIT back in 2008/2009 time-frame. He had just started Y-Combinator after selling Yahoo!-store to Yahoo! for 40 million dollars.
Yeah.
Nice, personable guy.
At that same conference I met Joe Armstrong, the Joe Armstrong, who invented Erlang (another name from mathematics, c.f. Markov chains and Queuing theory used telephony) after having sold his Erlang company for 40 million dollars.
Nice, soft-spoken guy. Some pretty 'weird' ideas about Concurrent-oriented programming ('weird' is a direct quote from wikipedia when describing the properties of the Y-combinator).
What do these guys have in common ... besides working really hard on something everybody else told them didn't work and would never work. That, and 40 million dollars, each.
I mean, Paul Graham wrote web services (before 'web services' existed as a term) in Lisp, of all things. He was afraid to tell others about using Lisp, for if they found out, they'd start to copy him and program in Lisp, too.
Nobody programs in Lisp, by the way. Just stupid students going to comp.lang.lisp asking "How do I reverse a list in Lisp? Please answer right away; homework due tomorrow morning."
Paul was worried somebody would find out, until his partner, Robert Morris, laughed at him: "Nobody cares! Everybody's programming in Java and has an Oracle back-end. They're following 'best practices;' they'd never use Lisp. That's why they're going to fail, and why we're going to succeed!"
Paul chilled after that pep-talk.
And Joe Armstrong? Ericsson told him: write us a concurrent language.
So he did.
It didn't look like Java, and it was untyped (just like Paul Graham's Lisp), so Ericsson fired him (actually, they didn't fire him, they just mandated that Erlang was not to be used at all in Ericsson anymore, so he left. Yeah. They fired him). He asked if he could keep Erlang. They said. "Erlang? Whatever. Sure. Take it and go."
He took it and went.
Erlang supports 60,000 concurrent nodes, at the same time. Joe showed it by connecting to his Erlang web server.
Netscape webserver crashed after 1,000 connections. It's a Unix thing. So, you know, Java ...? Same problems.
Joe showed his stuff around. Somebody bit. Cell phones? You need to support a lot of concurrency. A lot. He made a lot of money until Ericsson bought him back. Seems they needed his technology, after all.
What's weird about these guys?
Nothing.
Paul Graham's Y-combinator has started up scribd, Dropbox, and reddit.
His startups, in total, are valued at over $13.7 billion dollars. The startups had their original ideas and did all the work, all Paul Graham, and his family and partners did was open the door, give them a tiny little bit of money, and listen to them.
Joe. All he did was go against convention of 'everything has to be typed' and 'shared memory' and what threads are, and he kept at it until he got something working and he made it work with stunning results. And still he was rejected.
These are two men who believed in what they were doing, regardless of what everybody else was telling them was so, and they kept at it through success and disappointment.
And they are both generous with their time and are soft-spoken. Yes, they believe what they believe, and stand up for it, but they don't start confrontations, they don't even finish them. They just walk away and get to work, and make it work.
I see it all the time. That is: very rarely. This one guy, Brian Kernighan, at work, he wasn't given resources and told the acquisition process would take forever, or long after the due delivery date for the project.
So he bought dedicated hardware, set up a web server, and ran the application from his house.
This was for a big, big, really big cable company. Really big.
He was a water-walker. Why? Because he did what he needed to do, regardless of what everybody told him what couldn't be done.
You. Me. Every day we're told 'no' or 'later' or 'that can't be done' or 'you can't do it.'
You. Me. Everybody. We can choose to listen to what we're told, and to believe it, or we can go ahead and do what we see needs to be done, but nobody's doing it, because everybody says it can't be done.
The Y-combinator as a mathematical function that does what math functions aren't suppose to do: it doesn't give an answer, or it can give multiple answers. A function just returns one answer, that's all.  The Y-combinator doesn't. And it's modeled within mathematics using straight-up math.
It can't be done. But it's doing it.
You. You're told every day, 'it can't be done.' You can listen, and be like everybody else.
Or you can do it. And be what nobody else can be: you.
'Y' is for Y-combinator. 'Y' is for you.
Categories: Offsite Blogs

Fifty Years of BASIC, the Programming Language That Made Computers Personal

Lambda the Ultimate - Tue, 04/29/2014 - 8:20am

Fifty Years of BASIC, the Programming Language That Made Computers Personal

A very comprehensive history of BASIC from Time magazine.

Invented by John G. Kemeny and Thomas E. Kurtz of Dartmouth College in Hanover, New Hampshire, BASIC was first successfully used to run programs on the school’s General Electric computer system 50 years ago this week–at 4 a.m. on May 1, 1964, to be precise.

Edit: Dartmouth is celebrating Basic at 50.

Categories: Offsite Discussion

Philip Wadler: Scottish Independence, by the numbers

Planet Haskell - Tue, 04/29/2014 - 8:02am
Slides from my lab lunch are here.
To encourage discussion in preparation for 18 September, this talk will cover some of the relevant figures and list useful sources of information. I won't make a secret of my own view on the issue, but the goal is to cover relevant information, not to argue for one side or the other.
Categories: Offsite Blogs

Douglas M. Auclair (geophf): I've been 'X'-marks-the-spot'ed! Oh, noes!

Planet Haskell - Tue, 04/29/2014 - 5:07am

So, 'X' is for 'X' marks the Spot. It could have been for X-multiplication for division by fractions ...
1/2 ÷ 1/3 = (cross-multiplying gives you 1 * 3  ÷ 2 * 1 as Mr. Milardo, my math teacher in high school would chant: "Criss-cross; Applesause!" as we did fractional division)  3/2 or 1 1/2
But that would be that post and there it is and there you have it.
Where's the adventure and drama in that? Math is exciting and original, so why would I retreat boring, rote stuff like that, which everybody knows math isn't!
(Uh, wait, geophf: most people think math is boring and rote)
(Oh.)
But that's not what this post is about. This post is about what happened at 5 pm at work in a meeting yesterday ...
... and why do these things always have to happen at 5 pm at the meeting at work, that you could've  just skipped out on, saying you had to catch your bus, but did you do that, no, and see what it gets you? Trouble, and more Trouble, that's why!
Trouble with a capital-'T'
('T' is for big Trouble)
('Hey, big Trouble.' 'Hey, little trouble.' Ah, the story of Siegfried and Brünnhilde, as retold by Quentin Tarantino)
So, yesterday at work, at 5 pm, we were having an innocuous little meeting about the layout of a chooser-window, allowing our users to select which columns to include, which not to, and which order they want to see them in.
With 600 columns, this isn't a trivial concern. Or it is trivial, but it's also a major time-sink for our users, having to deal with stuff that isn't a business concern.
Anyway, innocuous little meeting. I was bored out of my mind.
But THEN!
Our manager asked: "But what are we doing for learning our users' preferences in the application?"
Me: "Nothing."
Everybody else, all excited: "Well, we could do this and that and this and that!"
The Boss: "But what are we doing now for this?"
Me: "Nothing."
Then the boss goes on this five-minute tirade about how everywhere on the internet, it just knows what you want and how you want it, and how? And we're building applications straight out of 1993 and our users have to deal with this (euphemistic word for excrement), and what are we going to do about this? Who is going to add intelligence to our application?
And he glared right at me.
Somebody read my resume. Nobody reads resumes. Nobody reads emails. Nobody reviews code. I was totally and completely safe here being a 'senior Java developer,' slinging code and recommending 'best practices.'
Somebody read my resume.
I sighed. "I'll take this on."
Boss: "Good."
He got up and left. Meeting adjourned.
I've been played. My strengths have been played to.
My company is 'utilizing my full potential,' as it were.
I checked my shirt and my back. I didn't see a big-ole 'X' targeting me.
But it was there.
Okay, new day, but now I get to think about Markov chains and Google Analytics and neural classifiers ... at work ... and they're paying me to do this research.
Yeah. New day.
Tomorrow we'll look at the letter Y, the combinator and the company.
Categories: Offsite Blogs

Philip Wadler: I Shall Vote Yes

Planet Haskell - Tue, 04/29/2014 - 2:15am
From Bella Caledonia, a follow up to "I Shall Vote No".
My favourite line: "I shall vote Yes because that ‘early day of a better nation’ stuff gets to me, actually." Me too. The original line is "Work as if you live in the early days of a better nation", from a poem by Dennis Lee, popularised by Alasdair Gray.The last in the series of referendum poems by A.R. Frith. Read his sonnet for the Undecided here and his I Shall Vote No here.

I Shall Vote Yes

I shall vote Yes because
I just think that, in a divided world, we shouldn’t be building barriers
against immigrants and asylum seekers.

I shall vote Yes because
Labour say they believe in One Nation,
and that’s how fascism starts.

I shall vote Yes because I am fed up
with silly articles illustrated by stills from Braveheart, in newspapers that should know better.

I shall vote Yes, because the thought of having a written constitution
thrills me inexpressibly.

I shall vote Yes because until Independence we're stuck with Alex Salmond.

I shall vote Yes, because it is seven hundred years since the Battle of Bannockburn,
and yet some condescending gits imagine it is an issue for us now.

I shall vote Yes
to spare the blushes of foreign diplomats who have told their governments I will.

I shall vote Yes,
but No to Nato, if anyone asks me (though nobody ever has, come to think of it).

I shall vote Yes because Nicola Sturgeon is fantastic.

AND

I shall vote Yes because I have no wish whatever
to be loved by Eddie Izzard.

I shall vote Yes, because I am striving to be Green.

I shall vote Yes because I have always liked Sean Connery,
even in Marnie and The Longest Day.

I shall vote Yes because it will kill the Nats stone dead.

I shall vote Yes, so that Scotland may take its rightful place
in the Eurovision Song Contest.

I shall vote Yes because to me as a Quaker it seems the right thing to do.

I shall vote Yes because
that ‘early day of a better nation’ stuff gets to me, actually.

I shall vote Yes because the Proclaimers will vote Yes.

I shall vote Yes because my MSP is a Unitarian
and it will boost his morale if someone agrees with him about something.

I shall vote Yes because, although ‘no-brainer’ is an unpleasing word,
I can’t think what else to call it.

I shall vote Yes, in the fervent hope that certain people will indeed up sticks and leave
(though I shan’t be holding my breath).

I shall vote Yes because James Kelman will vote Yes,
and he won the Booker Prize for using the f-word four thousand times in a novel.

I shall vote Yes, because I am persuaded
that the precedent of how Norwegian independence affected Sweden
shows that England will benefit almost as much as we will.

I shall vote Yes, because the experience of the Czech Republic and Slovakia
was that both countries were more prosperous after their velvet divorce.

I shall vote Yes, just to spite George Osborne.

I shall vote Yes out of curiosity
as to which unionist politician will be the first one to claim Independence
was what they really wanted all along, and is plainly a Good Thing.

I shall vote Yes because, despite what some people say,
I am, and always will be, British, thank God,
and so it is my duty.
Categories: Offsite Blogs

How to run a tree transformer on the GPU?

Haskell on Reddit - Tue, 04/29/2014 - 1:16am

Suppose I have a simple recursive binary-tree like:

data T = Add T T | Mul T T | Sub T T | Div T T | Num Int

Now say I define a recursive function on that datatype:

eval :: T -> T eval (Add a b) = (eval a) + (eval b) eval (Mul a b) = (eval a) * (eval b) eval (Div a b) = (eval a) / (eval b) eval (Sub a b) = (eval a) - (eval b) eval (Num a) = a

If I am not wrong, algorithms like this one, that fold over trees without context, are embarrassingly parallel.

eval (Add (Add 1 2) (Mul 3 4))

Here, (Add 1 2) and (Mul 3 4) could be executed in parallel. My question, is: is there a way to take similar functions, and make them run in parallel, on the GPU?

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

Christopher Done: The Identity monad trick

Planet Haskell - Mon, 04/28/2014 - 6:00pm

Update: Got the link! The Trivial Monad. Thanks, John. Naturally, all interesting Haskell things eventually lead back to Dan Piponi.

I heard about this from John Wiegley a while ago, but every time I recall it, I can’t remember how it goes, so I thought I’d write it down for myself. I think there’s a paper about it, but I can’t find it. Hopefully I’m recalling it correctly.

The Identity monad trick: Let’s say I want to expose an API that lets you work with a data structure. I want you to be able to keep hold of that data structure and pass it back into my library, and I’ll give it back to you later and we can go back and forth.

But I don’t want you to actually give you the data structure freely so you can go and give it to your friends. So instead I force you into the Identity monad, via a newtype wrapper that only I can unpack.

newtype Secret a = Secret { unSecret :: Identity a } deriving (Monad,Functor,Applicative)

And I have some function exposing it like:

getSecret :: Foo -> Secret Text

Here, use that. What can you do with it? You can’t extract the value out, you can only compose it with more functor or monad stuff:

fmap (map T.toUpper) (getSecret foo)

Or:

do text <- getSecret foo if all T.isUpper text then return (T.reverse text) else return text

Note that the whole type of this expression is Secret Text. You still don’t have the secret, you’ve got a computation over it.

You’ve used the value, but it never escaped1 the actual Identity monad. It’s like I’m giving you the value, but I’m also not giving you the value.

  1. As always, there’s a difference between “secure against your own stupidity” and “secure against attackers.” For the former, this is satisfied.

    For the latter, bottom complicates it, so you should force it in the IO monad and catch any exceptions e.g.

    extract :: Secret a -> IO (Maybe a)

    This prevents people from using

    (v >>= \a -> error ("The value is " ++ show a))

    To try to get around it.

    unsafePerformIO and other non-standard Haskell can get around it, but if you’re defending against developers, you probably have control over the environment, so you can just white-list the imports and extensions and there’s nothing they can do. This is what tryhaskell (via mueval) does.

Categories: Offsite Blogs

When will hackage.haskell.org be upgraded to cabal 1.20?

Haskell on Reddit - Mon, 04/28/2014 - 4:19pm

With cabal 1.20 being available now--does anyone know when hackage.haskell.org will be upgraded?

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

[n00b]A General Question on Program Architecture: How do I Manipulate and Preserve Data Structures?

Haskell on Reddit - Mon, 04/28/2014 - 2:16pm

I'm a 2nd year computer science student and I've been studying Haskell for about 2 months. I'd say I have a good handle on how the language works and what it is capable of. I would definitely like to continue to work in Haskell after my studies have concluded.

I have encountered a mental roadblock though. How do I write programs that work in the real world, and not just in the limited GHCi sandbox? More specifically, when using a data structure like a tree or a table, how do I manipulate said structure while still preserving a consistent reference to it?

Here's an example of a tree I wrote to help illustrate my problem:

-- leaf-labelled trees of arbitrary data type -- a tree is either empty or is a node with an element and two sub-trees data BinTree a = Empty | Node a (BinTree a) (BinTree a) -- inductive case deriving (Eq, Ord, Show) --make a new tree newTree :: BinTree Int newTree = Empty --check if node is leaf isLeaf :: (Eq a) => BinTree a -> Bool isLeaf (Node _ c b) = if c == Empty && b == Empty then True else False isLeaf Empty = False --create a new leaf leaf :: a -> BinTree a leaf x = Node x Empty Empty --insert an element insert :: (Ord a) => a -> BinTree a -> BinTree a insert x Empty = leaf x insert x (Node v c1 c2) | x >= v = Node v c1 newc2 |otherwise = Node v newc1 c2 where newc2 = insert x c2 newc1 = insert x c1

With this code I can make an empty tree, add element to it, and with minimal work I could write code to traverse the tree as well. However, when actually running my code, how do I preserve changes to the tree?

For example, in GHCi:

let tree = newtree --make new tree Empty --result insert 5 tree -- add 5 to the tree Node 5 Empty Empty -- awesome, a tree with a non empty node is returned

Now here's my hangup. The only way I see to preserve the changes I've made to the tree would be to "save" the return value to a new "variable" (since function names cannot be reassigned). The original tree that I made can never be altered. If I cannot save my changes, how on earth do I move forward and write programs in haskell?

The only potential solutions I see here are:

  • Use IO to constantly read and write to a text file, thus preserving changes to data.
  • Monads? Do monads help here somehow? I actually have yet to use these, not clear on what's going on here.

Any feedback here would be great. I've read a lot into haskell, and a lot of high level topics are often covered in great detail, but none of the material I've read really seems to explicitly cover software engineering topics in functional programming. Am I missing something here?

submitted by Joel_gh719
[link] [11 comments]
Categories: Incoming News