News aggregator

Philip Wadler: Dinna fash yersel — Scotland will dae juist fine!

Planet Haskell - Sun, 09/14/2014 - 12:13pm
One relentless lie behind 'No' is that Scotland is too wee to make it on its own, counterexamples such as Denmark, Sweden, Singapore, and Hong Kong being conveniently ignored. May this post from Thomas Widmann, a Dane residing in Scotland, help to dispel the disinformation. 
Pick a random person from somewhere on this planet. Ask them to name an alcoholic drink from Scotland, and it’s very likely they’ll reply “Whisky”. Ask them to name one from Denmark, and they’ll probably be tongue-tied. (They could answer “Gammel Dansk” or “Akvavit”, but they’re just not nearly as famous as whisky.)

Now repeat the exercise, but ask about a food item. Again, it’s likely they’ll have heard of haggis but that they’ll be struggling to name anything from Denmark.

Now try a musical instrument. Bagpipes and … sorry, cannot think of a Danish one.

A sport? Scotland has golf, of course. Denmark can perhaps claim ownership of handball, but it’s not associated with Denmark in the way that golf makes everybody think of Scotland.

A piece of clothing? Everybody knows the kilt, but I’d be very surprised if anybody can name one from Denmark.

A monster? Everybody knows what’s lurking in Loch Ness, but is there anything scary in Denmark?

The only category where Denmark perhaps wins is toys, where Lego surely is more famous than anything from Scotland (but many people don’t know Lego is from Denmark).

Denmark is also well-known for butter and bacon, of course, but these aren’t Danish in origin or strongly associated with Denmark in people’s minds.

Several famous writers and philosophers were Danish (e.g., Hans Christian Andersen and Søren Kierkegaard), but Scotland can arguably list more names of the same calibre, and the Scottish ones wrote in English, which makes them much more accessible to the outside world.

Scottish universities are also ranked better than the Danish ones in recent World rankings.

Finally, Scotland has lots of oil and wind, water and waves. Denmark has some, but not nearly as much, and most other countries have less than Denmark.

Because of all of this, I don’t worry about the details when it comes to Scottish independence. If Denmark can be one of the richest countries on the planet, of course Scotland can be one too.

Yes, there might be a few tough years while the rUK are in a huff and before everything has been sorted out. And of course there will be occasional crises in the future, like in any other country.

However, unless you subscribe to the school that Denmark and other small countries like Norway and Switzerland are complete failures because they don’t have nuclear weapons and a permanent seat on the UN’s Security Council, there’s simply no reason to assume Scotland won’t do exceptionally well as an independent country in the longer term.

So I’m not worried. Of course there are many details to sort out, but at the end of the day everything will be fine. Scotland will be a hugely successful independent country. Dinna fash yersel!
Categories: Offsite Blogs

Inferring Algebraic Effects

Haskell on Reddit - Sun, 09/14/2014 - 10:12am
Categories: Incoming News

Did hackage stop building packages?

Haskell on Reddit - Sun, 09/14/2014 - 5:31am

It seems as if the last package with haddock documentation is effect-monad-0.6. (Thu Sep 11 15:40:06 UTC 2014). Everything uploaded since then has not been built apparently. Is this a temporary condition?

submitted by 45g
[link] [10 comments]
Categories: Incoming News

Bind (>>=) in haskell, why is it the same as SelectMany in Linq (C#) ?

Haskell on Reddit - Sun, 09/14/2014 - 4:35am

Hi everyone, when I first learned about Monads in Haskell, I was told that the bind operator is the same as SelectMany in Linq, but I still can't wrap my mind around it ? Why is it not simply equivalent to Select ?

Thank you.

submitted by binge_learner
[link] [13 comments]
Categories: Incoming News

An operational and axiomatic semantics for non-determinism and sequence points in C

Lambda the Ultimate - Sun, 09/14/2014 - 3:36am

In a recent LtU discussion, naasking comments that "I always thought languages that don't specify evaluation order should classify possibly effectful expressions that assume an evaluation order to be errors". Recent work on the C language has provided reasonable formal tools to reason about evaluation order for C, which has very complex evaluation-order rules.

An operational and axiomatic semantics for non-determinism and sequence points in C
Robbert Krebbers

The C11 standard of the C programming language does not specify the execution order of expressions. Besides, to make more effective optimizations possible (e.g. delaying of side-effects and interleav- ing), it gives compilers in certain cases the freedom to use even more behaviors than just those of all execution orders.

Widely used C compilers actually exploit this freedom given by the C standard for optimizations, so it should be taken seriously in formal verification. This paper presents an operational and ax- iomatic semantics (based on separation logic) for non-determinism and sequence points in C. We prove soundness of our axiomatic se- mantics with respect to our operational semantics. This proof has been fully formalized using the Coq proof assistant.

One aspect of this work that I find particularly interesting is that it provides a program (separation) logic: there is a set of inference rules for a judgment of the form \(\Delta; J; R \vdash \{P\} s \{Q\}\), where \(s\) is a C statement and \(P, Q\) are logical pre,post-conditions such that if it holds, then the statement \(s\) has no undefined behavior related to expression evaluation order. This opens the door to practical verification that existing C program are safe in a very strong way (this is all validated in the Coq theorem prover).

Categories: Offsite Discussion

Should OO classes have laws?

Haskell on Reddit - Sun, 09/14/2014 - 1:03am

Please forgive me for being a bit of topic, but I am at this point interested in the oppinions of fellow Haskell programmers about the following.

Many seem to hold the view that type classes should be accompanied by laws (this is my view also). The laws (together with the signatures) are what give the type class its meaning and makes it possible to reason about the code even in the presense of ad hoc overloading.

Do you hold this view about classes in object orientation? (That OO classes should provide laws.) I would like to add that I cannot recall ever to have seen any stated law in OO code.

If you do not think OO classes must have laws, then how should one be able to understand OO code (in the face of inheritance and overloading)? And what then are the classes?


These questions came from a general growing sense I have that object orientation is overused and not really suitable for many of its current applications. (I know others share this.)

I find OO code often complex and difficult to understand and classes almost never accompanied by stated laws.

One problem with OO seem to be that classes are used for (at least) three very different things:

  • To define data structures
  • To encapsulate data with operations
  • To define main control flow

In the first case they serve as a substitute for specialized algebraic datatypes. Take the following java example encoding a type to hold some result of some search computation:

final class Result { final int searchDepth; final int retries; final int visitedNodes; public Result(...) { ... } }

This is a class without laws, because it only serves as a data container. A three-tuple would have been adequate (modulo the nice field names).

In the second case they serve as modules to encapsulate data, for example a map implementation. In this case laws are necessary to understand the class.

In the third case the class is just a container for a set of "toplevel" procedures, like main, to drive the application. Class laws are not really relevant in this case.

submitted by togrof
[link] [15 comments]
Categories: Incoming News

ANN: haskell-src-exts-1.16.0

haskell-cafe - Sat, 09/13/2014 - 11:09pm
I am pleased to announce the release of haskell-src-exts-1.16.0! Hackage: GitHub: This release brings many bugfixes, as well as the following language features: * DoRec * Closed type families * GADT records * ExplicitNamespaces * Type equality constraints * PolyKinds * DataKinds * Default associated types * Instance signatures * OVERLAP pragma * Parallel arrays * MINIMAL pragma * Default signatures * Safe Haskell * Binary literals * Qualified record puns * Type splices The full changelog is available at This release is brought to you by: Alan Zimmerman Erik de Castro Lopo klapaucius Lars Corbijn Leonid Onokhov Peter A. Jonsson phischu Roman Cheplyaka Stefan Wehr Stijn van Drongelen yuriy0 Special thanks to Peter Jonsson who has done an incredible job for this release and fixed many of the longstanding issues in haskel
Categories: Offsite Discussion

I found a way to implement a (very unsafe) 'law of the excluded middle' function in haskell. Just how unsafe is this?

Haskell on Reddit - Sat, 09/13/2014 - 4:22pm

I know this serves no purpose outside of a dependently typed programming language but I thought it would be an interesting challenge to myself.

The code uses pretty much every hack and unsafe function that I know of, but is it actually possible to segfault this function without using unsafeCoerce?

{-# LANGUAGE ExistentialQuantification, DeriveDataTypeable #-} module Lem where import Control.Exception import Data.Typeable import System.IO.Unsafe import Unsafe.Coerce data Void absurd :: Void -> a absurd a = a `seq` error "Value of type void. Something has gone wrong in the type system." type Not a = a -> Void intrNotNot :: a -> Not (Not a) intrNotNot a x = x a data LEMException = forall a. LEMException a deriving (Typeable) instance Show LEMException where show (LEMException _) = "Something has gone wrong with `lem`. You should not see this." instance Exception LEMException doubleNegElim:: Not (Not a) -> a doubleNegElimnna = unsafePerformIO $ catch (willCrash `seq` (return $ absurd willCrash)) handle where willCrash = nna (throw . LEMException) handle :: LEMException -> IO a handle (LEMException a) = return (unsafeCoerce a)

The function seems remarkably resilient to everything I've thrown at it:

*Lem> doubleNegElim (intrNotNot "hello world") "hello world" *Lem> doubleNegElim (error "should see this") *** Exception: should see this *Lem> doubleNegElim (\t -> error "should see this") *** Exception: should see this

Can this function really be safe for external code to use?

EDIT: Apparently this isn't actually exactly equivalent to LEM. I'm still curious in how unsafe this module is though.

submitted by sebzim4500
[link] [17 comments]
Categories: Incoming News

Topics to cover in an 'Introduction to Functional Programming with Haskell' talk for school club?

Haskell on Reddit - Sat, 09/13/2014 - 1:33pm

The computer science club at my college hosts quite a few talks and workshops and invites any members of the club to participate and give presentations about interesting topics. My school places heavy emphasis on OOP and most people have never heard of functional programming, so I thought giving a talk would be a good way to introduce people to the concept through Haskell. My question is, what topics should I cover? What are the most important concepts in functional programming and/or Haskell to show people who have never heard of the language or paradigm before?

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

N00b questions

Haskell on Reddit - Sat, 09/13/2014 - 1:04pm

Just started, I am on Ubuntu, I can get code I type into ghc to run ("hello world") but I don't know how to make the into a "program" so I can type ./hello and have it print.

It's all that typed into the ghc or in gedit or emacs? It's likethere is an obvious step in missing

submitted by dragon_fiesta
[link] [18 comments]
Categories: Incoming News

Philip Wadler: Krugman vs Stiglitz

Planet Haskell - Sat, 09/13/2014 - 12:18pm

Some of my colleagues have commented on Paul Krugman's financial diatribe, Scots, what the heck. My colleague Nigel Goddard penned a response.
While I have a lot of respect for Paul Krugman, his blanket warning against currency unions is misplaced, at least according to Joe Stiglitz, another Nobel prize winning economist (two economists; three opinions). Stiglitz said (at the book festival) that all three proposed models (currency union, use of currency without union, separate currency) can work depending on the characteristics of the economies and, most particularly, the quality of the institutions running the currency (or currencies). For a union to work the economies must be similar in various important ways (level of investment, competitive advantage, etc). rUK and Scotland are similar at present so it can easily work. Over the longer term it may be that Scotland breaks out of the low-investment, low-skill rUK model and goes for a more northern European high-investment, high-skill model (let's hope!). In that case a currency union would over time come under strain and eventually break up (i.e., into separate currencies). But in that case I know which economy I'd rather be in.In the current situation, if the UK's central bank takes a decision contrary to Scotland's interest there is nothing we can do about it. An independent Scotland using UK currency could, if need be, move to its own currency. Krugman's piece says not a word on this option.

RBS, Lloyds, and TSB cannot afford to keep their headquarters in Scotland without the backing of the larger UK, though they may well keep much of their operations here. This is touted by Darling as a reason to vote No, but for me it's a reason to vote Yes. Banks too big to fail are an appalling idea; getting rid of them is an enormous benefit of an independent Scotland. I only hope Westminster keeps its promise not to agree a fiscal union!

Categories: Offsite Blogs

policy for new packages

haskell-cafe - Sat, 09/13/2014 - 11:41am
Hi guys, In my software I developped some piece of code that I think are sufficiently generic to be useful for others (some datatypes and typeclasses). Should I put them in a separate package and annonce them? What is the best pratice here? Namely it's a datatype called Data.Todo allowing to keep track of actions left to do to complete a computation, and the other is a typeclass called Control.Shortcut designed for computations that can be run in parralel and shortcuted if necessary. So they are small (but useful) things, I'm wondering if creating one package for each is worth it, or another policy can apply. Cheers, Corentin _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

The Gentoo Haskell Team: ghc 7.8.3 and rare architectures

Planet Haskell - Sat, 09/13/2014 - 6:35am

After some initially positive experience with ghc-7.8-rc1 I’ve decided to upstream most of gentoo fixes.

On rare arches ghc-7.8.3 behaves a bit bad:

  • ia64 build stopped being able to link itself after ghc-7.4 (gprel overflow)
  • on sparc, ia64 and ppc ghc was not able to create working shared libraries
  • integer-gmp library on ia64 crashed, and we had to use integer-simple

I have written a small story of those fixes here if you are curious.


To get ghc-7.8.3 working nicer for exotic arches you will need to backport at least the following patches:

Thank you!

Categories: Offsite Blogs

The Gentoo Haskell Team: unsafePerformIO and missing NOINLINE

Planet Haskell - Sat, 09/13/2014 - 3:18am

Two months ago Ivan asked me if we had working darcs-2.8 for ghc-7.8 in gentoo. We had a workaround to compile darcs to that day, but darcs did not work reliably. Sometimes it needed 2-3 attempts to pull a repository.

A bit later I’ve decided to actually look at failure case (Issued on darcs bugtracker) and do something about it. My idea to debug the mystery was simple: to reproduce the difference on the same source for ghc-7.6/7.8 and start plugging debug info unless difference I can understand will pop up.

Darcs has great debug-verbose option for most of commands. I used debugMessage function to litter code with more debugging statements unless complete horrible image would emerge.

As you can see in bugtracker issue I posted there various intermediate points of what I thought went wrong (don’t expect those comments to have much sense).

The immediate consequence of a breakage was file overwrite of partially downloaded file. The event timeline looked simple:

  • darcs scheduled for download the same file twice (two jobs in download queue)
  • first download job did finish
  • notified waiter started processing of that downloaded temp file
  • second download started truncating previous complete download
  • notified waiter continued processing partially downloadeed file and detected breakage

Thus first I’ve decided to fix the consequence. It did not fix problems completely, sometimes darcs pull complained about remote repositories still being broken (missing files), but it made errors saner (only remote side was allegedly at fault).

Ideally, that file overwrite should not happen in the first place. Partially, it was temp file predictability.

But, OK. Then i’ve started digging why 7.6/7.8 request download patterns were so severely different. At first I thought of new IO manager being a cause of difference. The paper says it fixed haskell thread scheduling issue (paper is nice even for leisure reading!):

GHC’s RTS had a bug in which yield placed the thread back on the front of the run queue. This bug was uncovered by our use of yield which requires that the thread be placed at the end of the run queue

Thus I was expecting the bug from this side.

Then being determined to dig A Lot in darcs source code I’ve decided to disable optimizations (-O0) to speedup rebuilds. And, the bug has vanished.

That made the click: unsafePerformIO might be the real problem. I’ve grepped for all unsafePerformIO instances and examined all definition sites.

Two were especially interesting:

-- src/Darcs/Util/Global.hs -- ... _crcWarningList :: IORef CRCWarningList _crcWarningList = unsafePerformIO $ newIORef [] {-# NOINLINE _crcWarningList #-} -- ... _badSourcesList :: IORef [String] _badSourcesList = unsafePerformIO $ newIORef [] {- NOINLINE _badSourcesList -} -- ...

Did you spot the bug?

Thus The Proper Fix was pushed upstream a month ago. Which means ghc is now able to inline things more aggressively (and _badSourcesList were inlined in all user sites, throwing out all update sites).

I don’t know if those newIORef [] can be de-CSEd if types would have the same representation. Ideally the module also needs -fno-cse, or get rid of unsafePerformIO completely :].

(Side thought: top-level global variables in C style are surprisingly non-trivial in "pure" haskell. They are easy to use via peek / poke (in a racy way), but are hard to declare / initialize.)

I had a question wondered how many haskell packages manage to misspell ghc pragma decparations in a way darcs did it. And there still _is_ a few of such offenders:

$ fgrep -R NOINLINE . | grep -v '{-# NOINLINE' | grep '{-' -- ajhc-{- NOINLINE filterFB #-} ajhc-{- NOINLINE iterateFB #-} ajhc-{- NOINLINE mapFB #-} -- darcs-2.8.4/src/Darcs/Global.hs:{- NOINLINE _badSourcesList -} darcs-2.8.4/src/Darcs/Global.hs:{- NOINLINE _reachableSourcesList -} -- dph-lifted-copy-{- NOINLINE emptyP #-} -- dph-par-{- NOINLINE emptyP #-} -- dph-seq-{- NOINLINE emptyP #-} -- freesect-0.8/FreeSectAnnotated.hs:{- # NOINLINE showSSI #-} freesect-0.8/FreeSectAnnotated.hs:{- # NOINLINE FreeSectAnnotated.showSSI #-} freesect-0.8/FreeSect.hs:{- # NOINLINE fs_warn_flaw #-} -- http-proxy-0.0.8/Network/HTTP/Proxy/ReadInt.hs:{- NOINLINE readInt64MH #-} http-proxy-0.0.8/Network/HTTP/Proxy/ReadInt.hs:{- NOINLINE mhDigitToInt #-} -- lhc-0.10/lib/base/src/GHC/PArr.hs:{- NOINLINE emptyP #-} -- property-list-{- NOINLINE doubleToWord64 -} property-list-{- NOINLINE word64ToDouble -} property-list-{- NOINLINE floatToWord32 -} property-list-{- NOINLINE word32ToFloat -} -- warp-{- NOINLINE readInt64MH #-} warp-{- NOINLINE mhDigitToInt #-}

Looks like there is yet something to fix :]

Would be great if hlint would be able to detect pragma-like comments and warn when comment contents is a valid pragma, but comment brackets don’t allow it to fire.

{- NOINLINE foo -} -- bad {- NOINLINE foo #-} -- bad {-# NOINLINE foo -} -- bad {-# NOINLINE foo #-} -- ok

Thanks for reading!

Categories: Offsite Blogs

Hello and type-level SKI

haskell-cafe - Fri, 09/12/2014 - 9:56pm
Greetings all, I've been reading this list for a short while and I thought I'd like to begin to contribute where possible. This message pretty much serves to say: - Hello, Haskell! - This community is great, and it's always been a great pleasure to read the newsgroup(s) - Here is a small and likely multiply re-re-discovered `proof' of why the type system is Turing Complete I just thought I'd share this snippet here, but if this is not the right place, or it's too long or something please don't hesitate to let me know. Thanks for your attention, Yours &c., Tslil _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Type checker plugins

glasgow-user - Fri, 09/12/2014 - 5:41pm
Hi folks, Those of you at HIW last week might have been subjected to my lightning talk on plugins for the GHC type checker, which should allow us to properly implement nifty features like units of measure or type-level numbers without recompiling GHC. I've written up a wiki page summarising the idea: Feedback is very welcome, particularly if (a) you have an interesting use for this feature or (b) you think this is a terrible idea! Thanks, Adam
Categories: Offsite Discussion