## Functional Programming

### Fucking Microsoft, fucking Windows

Planet Haskell - Sun, 11/23/2014 - 07:00
I have a new Lenovo laptop, which dual-boots Windows and Linux. (Huge thanks to the author of [these detailed instructions](https://askubuntu.com/questions/221835/installing-ubuntu-on-a-pre-installed-windows-8-64-bit-system-uefi-supported/228069#228069) and [this tool](http://sourceforge.net/projects/boot-repair/) that magically fixes whatever is messed up.) So I'm using Windows now for the first time in several years, and remembering why I stopped. I had forgotten, for a long time, what this was like. You hear a lot of propaganda about how a Linux user has to solve a lot of problems that the free development process didn't solve, they have to understand system administration, and when things go wrong you have to depend on free suppprt, the implication being that the free support is sketchy and incomplete. In the intervening years I had forgotten what a load of bullshit this is. When my Linux system was broken, or when the free support was sketch and incomplete, I would wonder if I wouldn't be better off using something else. A few months of dealing with Windows have reminded me that no, I would not be better off. When I first got the laptop, I had Windows booted, and I tried plugging in a VGA monitor for the first time. This is a universal, core function of the laptop, so one might expect them to have gotten it right a long time ago. Or maybe Lenovo tried it thirty minutes after the first laptop came from the factory, and discovered something wrong, and then worked with Microsoft to make sure the problem was fixed. Anyway one would expect to plug in the monitor, and have it just work; whereas under Linux you might expect to have to fiddle with Xorg.conf, or download xrandr and puzzle out ists man page or something like that. But no, it was just the opposite. When I plugged in the monitor under Linux, everything just worked instantly. When I plugged in the monitor under Windows, Windows recognized the external monitor, but the integrated monitor went black. I tried all the monitor and display settings; the integrated display was still black. So I called Lenovo support. What a mistake that was. The guy on the other end had me try to same set of display settings I had just tried, tried disabling and reinstalling some of the dvice drivers, and then threw up his hand and said I had a bad motherboard and I should return the laptop for replacement. I said I was sure he was mistaken. I knew the motherboard was fine because the VGA monitor worked fine under Linux. (I didn't say this on the phone, because in sometimes the word “Linux” is been like waving a red cape in front of a bull: oh, you use Linux, that must be the cause of your problem.) Then at the end of the call: “Are you satisfied with the results of your call today.” Uh, what? You didn't solve my problem and your suggested solution is obvious nonsense, so, um, no, I'm not satisfied with the results of my call today. Anyway, that's the last time I'll make that mistake. I did some web searching and found a page that suggested some incantation in the boot settings that fixed the problem. So much for paid support; it was worse than useless. More recently, I took the laptop to Los Angeles, and when I arrived, the AC power adapter wasn't working; I would plug in the laptop and it wouldn't charge. Bot Linux and Windows reported "not plugged in". (Lenovo got rid of the LED that announces when AC power is connected, so you have to boot the machine to find out whether it thinks it is plugged in.) This had worked a few hours before, when I had it plugged in at the airport. I tested with a spare line cord and guessed that the power brick was faulty. Then I limped along for two days on reserve battery and a borrowed power brick until a replacement arrived. The replacement worked for a few hours in the office, but when I got back to the hotel, it failed in the same way. Over the next couple of hours I discovered that if I powered the machine down, pulled out and replaced the battery, and then booted it up, the AC power would work indefinitely under Linux, and would even work under Windows _until I logged in_, when it would stop working after a few seconds. Once it stopped working the only way to get it to work again was to power the machine down and pull the battery. So the problem was evidently a Windows software problem. And eventually I made the problem go away by booting with AC power and no battery, uninstalling the Windows battery device driver (yes, the battery as a device driver), shutting down, and booting with battery but no AC power. It has continued to work since. The original power brick, the one I thought had failed, is fine. I wouldn't have imagined that a Windows device driver problem could cause a failure of the AC charging, but it seems so. Had this kind of nonsense happened under Linux, I would have been annoyed but taken it in stride; Linux is written and maintained by volunteers, so you take what you can get. Microsoft has no such excuse. We paid Microsoft a hundred billion dollars for this shoddy shitware.

### Within this instrument, resides the Universe

Planet Haskell - Sun, 11/23/2014 - 07:00
When opportunity permits, I have been trying to teach my ten-year-old daughter rudiments of algebra and group theory. Last night I posed this problem: Mary and Sue are sisters. Today, Mary is three times as old as Sue; in two years, she will be twice as old as Sue. How old are they now? I have tried to teach Ms. 10 that these problems have several phases. In the first phase you translate the problem into algebra, and then in the second phase you manipulate the symbols, almost mechanically, until the answer pops out as if by magic. There is a third phase, which is pedagogically and practically essential. This is to check that the solution is correct by translating the results back to the context of the original problem. It's surprising how often teachers neglect this step; it is as if a magician who had made a rabbit vanish from behind a screen then forgot to take away the screen to show the audience that the rabbit had vanished. Ms. 10 set up the equations, not as I would have done, but using four unknowns, to represent the two ages today and the two ages in the future: \begin{align} MT & = 3ST \\ MY & = 2SY \\ \end{align} ( here is the name of a single variable, not a product of and ; the others should be understood similarly.) “Good so far,” I said, “but you have four unknowns and only two equations. You need to find two more relationships between the unknowns.” She thought a bit and then wrote down the other two relations: \begin{align} MY & = MT + 2 \\ SY & = ST + 2 \end{align} I would have written two equations in two unknowns: \begin{align} M_T & = 3S_T\\ M_T+2 & = 2(S_T + 2) \end{align} but one of the best things about mathematics is that there are many ways to solve each problem, and no method is privileged above any other except perhaps for reasons of practicality. Ms. 10's translation is different from what I would have done, and it requires more work in phase 2, but it is correct, and I am not going to tell her to do it my way. The method works both ways; this is one of its best features. If the problem can be solved by thinking of it as a problem in two unknowns, then it can also be solved by thinking of it as a problem in four or in eleven unknowns. You need to find more relationships, but they must exist and they can be found. Ms. 10 may eventually want to learn a technically easier way to do it, but to teach that right now would be what programmers call a premature optimization. If her formulation of the problem requires more symbol manipulation than what I would have done, that is all right; she needs practice manipulating the symbols anyway. She went ahead with the manipulations, reducing the system of four equations to three, then two and then one, solving the one equation to find the value of the single remaining unknown, and then substituting that value back to find the other unknowns. One nice thing about these simple problems is that when the solution is correct you can see it at a glance: Mary is six years old and Sue is two, and in two years they will be eight and four. Ms. 10 loves picking values for the unknowns ahead of time, writing down a random set of relations among those values, and then working the method and seeing the correct answer pop out. I remember being endlessly delighted by almost the same thing when I was a little older than her. In The Dying Earth Jack Vance writes of a wizard who travels to an alternate universe to learn from the master “the secret of renewed youth, many spells of the ancients, and a strange abstract lore that Pandelume termed ‘Mathematics.’” “I find herein a wonderful beauty,” he told Pandelume. “This is no science, this is art, where equations fall away to elements like resolving chords, and where always prevails a symmetry either explicit or multiplex, but always of a crystalline serenity.” After Ms. 10 had solved this problem, I asked if she was game for something a little weird, and she said she was, so I asked her: Mary and Sue are sisters. Today, Mary is three times as old as Sue; in two years, they will be the same age. How old are they now? “WHAAAAAT?” she said. She has a good number sense, and immediately saw that this was a strange set of conditions. (If they aren't the same age now, how can they be the same age in two years?) She asked me what would happen. I said (truthfully) that I wasn't sure, and suggested she work through it to find out. So she set up the equations as before and worked out the solution, which is obvious once you see it: Both girls are zero years old today, and zero is three times as old as zero. Ms. 10 was thrilled and delighted, and shared her discovery with her mother and her aunt. There are some powerful lessons here. One is that the method works even when the conditions seem to make no sense; often the results pop out just the same, and can sometimes make sense of problems that seem ill-posed or impossible. Once you have set up the equations, you can just push the symbols around and the answer will emerge, like a familiar building as you approach it through a fog. But another lesson, only hinted at so far, is that mathematics has its own way of understanding things, and this is not always the way that humans understand them. Goethe famously said that whatever you say to mathematicians, they immediately translate it into their own language and then it is something different; I think this is exactly what he meant. In this case it is not too much of a stretch to agree that Mary is three times as old as Sue when they are both zero years old. But in the future I plan to give Ms. 10 a problem that requires Mary and Sue to have negative ages—say that Mary is twice as old as Sue today, but in three years Sue will be twice as old—to demonstrate that the answer that pops out may not be a reasonable one, or that the original translation into mathematics can lose essential features of the original problem. The solution that says that is mathematically irreproachable, and if the original problem had been posed as “Find two numbers such that…” it would be perfectly correct. But translated back to the original context of a problem that asks about the ages of two sisters, the solution is unacceptable. This is the point of the joke about the spherical cow.

### GHC Weekly News - 2014/11/21

Planet Haskell - Sun, 11/23/2014 - 07:00

### Bidirectional Type Checkers for λ→ and λΠ

Planet Haskell - Sun, 11/23/2014 - 07:00

### GHC Weekly News 2014/11/18

Planet Haskell - Sun, 11/23/2014 - 07:00

### Darcs News #107

Planet Haskell - Sun, 11/23/2014 - 07:00
News and discussionsDarcs has received two grants from the Google Summer of Code program, as part of the umbrella organization Haskell.org. Alejandro Gadea will work on history reordering: http://alegdarcs.blogspot.com.ar/2014/05/google-summer-of-code-2014-darcs.htmlMarcio Diaz will work on the cache system: http://marcioodiaz.blogspot.com.ar/2014/04/gsoc-project-accepted.htmlhttp://marcioodiaz.blogspot.com.ar/2014/04/gsoc-progress-report-1-complete.htmlRepository cloning to remote ssh hosts has been present for years as darcs put. This feature has now a more efficient implementation: http://hub.darcs.net/darcs/darcs-reviewed/patch/20140425060647-5ef8fIssues resolved (11)issue851 Dan Frumininteractive mode for whatsnewhttp://bugs.darcs.net/issue851issue1066 Guillaume Hoffmannclone to ssh URL by locally cloning then copying by scphttp://bugs.darcs.net/issue1066issue1268 Guillaume Hoffmannenable to write darcs init xhttp://bugs.darcs.net/issue1268issue1416 Ale Gadeaput log files in tempdir instead of in working dir.http://bugs.darcs.net/issue1416issue1987 Marcio DiazGarbage collection for inventories and patches.http://bugs.darcs.net/issue1987issue2263 Ale GadeaOption --set-scripts-executable is not properly documentedhttp://bugs.darcs.net/issue2263issue2345 Dan Fruminsolution using cabal's checkForeignDepshttp://bugs.darcs.net/issue2345issue2357 Dan Fruminswitching to regex-compat-tdfa for unicode supporthttp://bugs.darcs.net/issue2357issue2365 Guillaume Hoffmanncorrectly copy pristine in no-working-dir cloneshttp://bugs.darcs.net/issue2365issue2367 Guillaume Hoffmannrename amend-record to amend, make --unrecord more visiblehttp://bugs.darcs.net/issue2367issue2379 Guillaume Hoffmannonly use packs to copy pristine when up-to-datehttp://bugs.darcs.net/issue2379Patches applied (41)See darcs wiki entry for details.

### Darcs News #109

Planet Haskell - Sun, 11/23/2014 - 07:00
News and discussionsWe are in the feature freeze period of darcs 2.10:http://lists.osuosl.org/pipermail/darcs-users/2014-November/027056.htmlOur two Summer of Code projects ended up two months ago. Marcio and Ale's code will be part of the upcoming new stable version of darcs. In case you missed them, here are the latest posts of Marcio for his project:http://marcioodiaz.blogspot.com.ar/2014/07/gsoc-progress-report-3-bucketed-global_23.htmlhttp://marcioodiaz.blogspot.com.ar/2014/07/gsoc-progress-report-4-garbage.htmlhttp://marcioodiaz.blogspot.com.ar/2014/07/gsoc-progress-report-5-starting.htmlAle's posts:http://alegdarcs.blogspot.com.ar/2014/07/month-of-june.htmlhttp://alegdarcs.blogspot.com.ar/2014/07/some-week-14-19-july.htmlhttp://alegdarcs.blogspot.com.ar/2014/07/other-week-21-26-july.htmlhttp://alegdarcs.blogspot.com.ar/2014/08/last-few-weeks.htmlIssues resolved (7)issue1514 Guillaume Hoffmannsend --minimize-context flag for sendhttp://bugs.darcs.net/issue1514issue1624 Marcio Diazbucketed cache.http://bugs.darcs.net/issue1624issue2153 Andreas Brandtallow skipping backwards through depended-upon patcheshttp://bugs.darcs.net/issue2153issue2249 Mateusz LenikRename isFile to isValidLocalPath and WorkRepoURL to WorkRepoPossibleURLhttp://bugs.darcs.net/issue2249issue2380 Owen Stephensallow darcs mv into known, but deleted in working, filehttp://bugs.darcs.net/issue2380issue2403 Ganesh Sittampalamneed to avoid moving the rebase patch to the endhttp://bugs.darcs.net/issue2403issue2409 Ganesh Sittampalamimplement darcs rebase applyhttp://bugs.darcs.net/issue2409Patches applied (118)See darcs wiki entry for details.

### Installing application dependencies using Stackage, sandboxes, and freezing

Planet Haskell - Sun, 11/23/2014 - 07:00