I'm reading Hitchhiker's guide to Haskell, and chanced upon this list comprehensionlet solve x = [ y | x <- [0..], y<-[0..], y == x * x ]
I tried running this on ghci and it doesn't evaluated, neither doestake 10 $ solve 16
My understanding is that they <- [0..]
does not ever end, hence the expression isn't evaluated
my second confusion is that below the list comprehension the author mentions
Yes, I know that finding a square root does not require list traversals,
which seem to suggest that the list comprehension above is used to find square root, but to me it looks like it wants to find the squares instead of the square root. Is that right?submitted by ngzhian
[link] [8 comments]
Just a small update. I took 15 mins and updated the haskell-mode printer a bit so that everything is indented by default, and lists are expanded as [1,2,…] rather than 1:(2:…).
Andrew Gibiansky contacted me about getting a front-end added for IHaskell, which would be lovely! I designed the present package specifically aimed at working on Emacs or the browser or wherever. So I sent him back an excessively long email about how to integrate it.
It might also be worth adding to tryhaskell, too. It’d be rather easy and helpful to newbies.
Also, update to the loeb example:λ> :present loeb (map (\i l -> Node i (map (fmap (+1)) l)) [1..3]) [Node 1 [Tree Integer ,Node 3 [Node 3 [Tree Integer ,Tree Integer ,Node 6 [Node 5 [Node 6 [Tree Integer ,[Tree Integer]] ,[Tree Integer]] ,[Tree Integer]]] ,[Tree Integer]] ,Tree Integer] ,Tree Integer ,Tree Integer]
You can really drill down into those structures!
Is it possible to do a parser of OWL (Web Ontology Language) from the XMLSchema: http://www.w3.org/2007/OWL/wiki/OWL_XML_Schema ? And in the end of the parsing we have a structure in haskell that can be fetched. Using HXT or HaXML?submitted by naoyrib
[link] [8 comments]
I'm an undergrad (a junior) and I'm looking for something to do over the summer. I love programming in Haskell. Does anyone know of any internships for programming in Haskell or companies which may be interested in hiring such an intern?
Thanks!submitted by the_tractatus
[link] [9 comments]
I'm a dabbler in Haskell. A few months ago, I made another attempt at it, but ran into the constrained monad problem in my first toy project (dice probabilities, monad over map needs ord).
Now that I know the phrases "constrained monad" and "restricted monad", I can read up on it. I can find Oleg talking about it. I can find the ICFP paper by Sculthorpe, et al. What I can't find, though, is the recommended solution for beginners who run into the problem.
- Should I just avoid it? I can't re-use the monadic machinery, but I can define my own functions easily.
- Is there a ghc extension that I could use, that's reasonably well-accepted, that will make the problem go away?
- Should I just buckle down and try one of the proposed work-arounds? If so, which one?
- Is there a solution in the works?
Basically, is there a consensus recommendation for what to do?submitted by oddthink
[link] [10 comments]
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?
Jamessubmitted by jamesl22
[link] [7 comments]
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.
(The diagram was produced with Haskell Diagrams)
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.
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?
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.
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.
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.
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)
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.
Our manager asked: "But what are we doing for learning our users' preferences in the application?"
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?"
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."
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.
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.
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.