News aggregator

A replayable free monad transformer - input wanted

Haskell on Reddit - Sat, 01/17/2015 - 9:48pm

I've implemented a replayable variant of FreeT. It is on github at conklech/replay. The representation looks like this:

data RF x f a b = Pure a | LiftR (x -> b) (f x) newtype ReplayT x f m a = ReplayT { runReplayT :: m (RF x f a (ReplayT x f m a)) }

You can see that the main difference is that it's been coyonedaed, although the type x is fixed in the signature. (Unlike Coyoneda where it's an existential; I think this change prevents implementing Traversable.)

I say it's "replayable" because the fixed type x allows an interpreter to record each effect in f in a log. That log can then be replayed in lieu of repeating the effects.

I provide a function to embed an effect whose result will be recorded:

record :: (Monad m, Functor f) => f x -> ReplayT x f m x

as well as replay:

replay :: (Functor f, Functor m, Monad m) => [x] -> ReplayT x f m a -> m (Either a (f [x]))

The inner f [x] in the result type represents an effect in f that performs the next recorded effect and returns the new effect log.

This construction makes the most sense when f is something like Reader x and m is a monad that can be repeatedly performed and has some meaningful intermediate state, such as State. I wrote a simplistic example of a text-based game, along with a simple interpreter.

The original intention was to write things like the example game using a framework like blaze-react, which requires a pure state transformer, without using a continuation or Mealy machine or other such un-serializable construction. With this, only the log needs to be kept in the state. Furthermore, the log represents a "save file" of sorts.

The only prior work I found was an assignment in Chalmers's current TDA342 course, which demands something a bit less general, and Peter Thiemann's WASH/CGI from the turn of the century, which was able to run monadic scripts from a cgi handler by serializing the results of all IO effects in the session state.

Questions:

  1. Naming? I haven't put this on hackage yet because I don't know whether replay or ReplayT are helpful or accurate names.

  2. Is this useful in other contexts?

  3. Is this a sensible implementation?

  4. How can I better explain what this is, what it can do, and how to use it?

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

Canoo RIA Blog

del.icio.us/haskell - Sat, 01/17/2015 - 9:33pm
Categories: Offsite Blogs

Type synonyms considered harmful?

haskell-cafe - Sat, 01/17/2015 - 9:06pm
Hi, I've recently had a discussion about type synonyms and when to use them in haskell. On the one hand, they make reading type signatures easier and tell you what is meant, not just what is inside. On the other hand they also sort of hide what is inside, although you will probably need to know exactly that when using them. This might make reading code for new collaborators more difficult if they have to memorize all type synonyms first. So there are basically a few questions: * What do you think is a good policy for when and how to use them? Or would you say just not use them at all and put equivalent information in parameter documentation? * What are the upsides, downsides, pitfalls and also alternatives? (for completeness, also since https://www.haskell.org/haskellwiki/Type_synonym is a bit sparse) * Can we do something to improve the downsides? Or is there already something? (e.g. editor/IDE that can tell me the underlying type, error messages etc.) -- Regards, Julian Ospald
Categories: Offsite Discussion

CFW: The 5th International Conference on Current and Future Trends of ICT in Healthcare (ICTH)

General haskell list - Sat, 01/17/2015 - 7:18pm
*** Apologies if you receive multiple copies of this message *** ----------------- Call for Workshops Proposals ------------------------ The 5th International Conference on Current and Future Trends of Information and Communication Technologies in Healthcare (ICTH) 27-30 September, 2015 Berlin, Germany http://icth-15.dai-labor.de/ ------------------------------------------------------------------------------- Important Dates =============== - Workshop Proposal Due: February 25, 2015 - Acceptance Notification: March 1, 2015 The ICTH-2015 organizing committee invites proposals for workshops. The main objective of the workshops is to provide a forum for researchers and professionals to discuss a specific topic from the field of ICTH-2015 and its related areas. All papers accepted for workshops will be included in the ICTH-2015 proceedings, which will be published by Elsevier. The authors must follow Elsevier guidelines as given
Categories: Incoming News

CFP" The 5th International Conference on Current and Future Trends of ICT in Healthcare

General haskell list - Sat, 01/17/2015 - 7:17pm
The 5th International Conference on Current and Future Trends of Information and Communication Technologies in Healthcare September 27-30, 2015 Berlin, Germany http://icth-15.dai-labor.de/ Important Dates ------------------ - Workshop Proposals: February 15, 2015 - Paper Submission Due: May 6, 2015 - Acceptance Notification: June 26, 2015 - Final Manuscript Due: July 26, 2015 The 5th International Conference on Current and Future Trends of Information and Communication Technologies in Healthcare (ICTH) is a premier venue for bringing together multi-disciplinary researchers, professionals and practitioners from academia and healthcare who are engaged in different facets of ICT and healthcare. The conference encourages innovative research contributions providing the recent significant developments and promising future trends of ICT based applications, systems, tools, environments and infrastructures in the fields of health/medical care, and related domains, such as public health and pharmaceuticals. Papers o
Categories: Incoming News

www.fpcomplete.com

del.icio.us/haskell - Sat, 01/17/2015 - 5:11pm
Categories: Offsite Blogs

Young Haskeller looking for some feedback on his code!

Haskell on Reddit - Sat, 01/17/2015 - 3:55pm

I'm relatively new to Haskell & FP in general, and today I set out to write my first non-trivial program. I'm looking for some feedback on the code-style and ways to improve it (in both style and efficiency, as its unbearably slow at the moment). The program finds the optimal path/solution to a given level from the recently published "Parity" game http://www.abefehr.com/parity/.

The code is up on Github: https://github.com/jcla1/parity-solver

submitted by jcla1
[link] [24 comments]
Categories: Incoming News

Code-completion problem with emacs,ghc-mod and auto-complete

haskell-cafe - Sat, 01/17/2015 - 3:19pm
Hi, Cafe! I'm struggling to configure my emacs for haskell development with ghc-mod and auto-complete. It works well for the most part, but I've run into the issue when completing qualified names. In the following example I don't get any completion after BS: module Playground where import qualified Data.ByteString.Lazy as BL doWork :: BL.By -- no completion after dot Completion for unqualified names and module name in imports works just fine. Maybe someone has run into this issue before? My .emacs: (ac-config-default) (auto-complete-mode t) (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) (autoload 'ghc-init "ghc" nil t) (add-hook 'haskell-mode-hook (lambda () (ghc-init))) (defun my-ac-haskell-mode () (setq ac-sources (append ac-sources '(ac-source-ghc-mod)))) (add-hook 'haskell-mode-hook 'my-ac-haskell-mode) (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) (add-hook 'haskell-mode-hook 'turn-on-haskell-indent) (ac-define-source ghc-mod '((depends ghc)
Categories: Offsite Discussion

[Question] Solving names that refer to each other

Haskell on Reddit - Sat, 01/17/2015 - 2:19pm

Let's say that I have an association list:

xs :: [(String, Either String Int)] xs = [ ("a", Left "b") , ("b", Right 42) , ("c", Left "a") , ("d", Left "e") ]

The value each item can either refer to another name or an Int. I want to write a function that can solve the references like:

solve :: [(String, Either String Int)] -> [(String, Maybe Int)]

So that solve xs becomes

[ ("a", Just 42) -- a refers to b, which is 42 , ("b", Just 42) -- b is just 42 , ("c", Just 42) -- c refers to a, which refers to b, which is 42 , ("d", Nothing) -- e does not exist ]

However, my implementation, while simple and it looks like that it could work, will just hit a <<loop>> error when run:

solve xs = let xs' = map (solve' xs') xs in xs' where solve' xs' (name, Left ref) = case lookup ref xs' of Just x -> (name, x) Nothing -> (name, Nothing) solve' xs' (name, Right x) = (name, Just x)

I'm currently out of ideas how to implement this properly. Any helps would be welcome. Thanks!

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

Matthew Sackman: Free speech values

Planet Haskell - Sat, 01/17/2015 - 11:35am

In the aftermath of the attacks on Charlie Hebdo in Paris, there has been some high quality thinking and writing. There's also been some really stupid things said, from the usual protagonists. It's an interesting facilitation that the internet now provides: as I no longer watch any news on TV (in fact I don't watch any news at all), nor subscribe to any newspaper, I'm used to reading articles from a wide range of sources. Equally, it's much easier for me to avoid opinion I disagree (right-wing press) with or trivialised dumbed-down reporting (e.g. BBC news). Because of this ease of reading what you want to (in both the good and bad sense), I thought a lot of the reaction was measured and sensible. Turns out I was just unaware of most of the reaction going on.

Anyway there seems to be virtually nothing left to say on this, so this post is really little more than a bunch of links to pieces I thought were thoughtful and well written.

I am an agnostic. I personally don't believe in any religion but I accept I can't prove that every religion is false and so I may be wrong. I tend to treat the beliefs of any religion as arbitrary and abstract ideas. Thus one place to start is the acknowledgement that the laws of any country or civilisation are as arbitrary and ad-hoc as the rules or teachings of any religion. They are just things that people choose to believe in, or follow, or not violate. In the UK, some of our law is based in Christianity (e.g. thou shalt not murder - though I've no idea whether ideas like that actually predate Christianity; I wouldn't be surprised if they do) though other parts of Christianity are not encoded in law (adultery is not illegal, for example).

Many have careless labelled these attacks as an attack of free speech and thus that the reaction is about defending free speech. As such, much has been written about how it's possible to defend the right Charlie Hebdo has to publish anything they want, even if it's offensive, even whilst criticising their choice of content.

Freedom of speech is, I believe, essential for any sort of democracy to work. This doesn't suggest that if you have freedom of speech then you have a democracy (I don't believe in the UK, or arguably anywhere in Europe or north America there is functioning democracy; merely systemic corporate dictatorships disguised by corrupt elected faux-representatives), but without freedom of speech, you certainly don't have any ability to transparently hold people to account and thus corruption and abuse will obviously take hold. But freedom of speech is a choice, it's not something axiomatic to existence; it's something many people have chosen to attach huge importance to and as such will defend. But just because there are widely agreed reasons to defend the concept of freedom of speech doesn't mean that it's self-evidently a "better" idea than not having freedom of speech. To judge something as "better" than something else requires all manner of discussion of the state of human existence. Consequently, criticising people for not holding freedom of speech in the same regard as we claim to do is no different from criticising people for their choice of clothing, or housing, or diet, or career, or religious views.

Of course in the UK, we don't have freedom of speech as an absolute concept nor does most of Europe. In the UK, "incitement to racial hatred" was established as an offence by the provisions of §§ 17-29 of the Public Order Act 1986, and The Criminal Justice and Public Order Act 1994 made publication of material that incited racial hatred an arrestable offence. It's not difficult to find stories of people getting arrested for saying things on twitter, the easiest is of course making bomb threats. UKIP (an extremist right wing political party in the UK) even managed to get police to visit a man who'd posted a series of tweets fact-checking UKIP policies. Thankfully, he wasn't arrested.

The USA appears to hold freedom of speech as a much more inviolable concept. For example:

The ACLU vigorously defends the right of neo-Nazis to march through a community filled with Holocaust survivors in Skokie, Illinois, but does not join the march; they instead vocally condemn the targeted ideas as grotesque while defending the right to express them.

But whilst the outpouring in Paris and the crowds gathered as a statement of unity were warmly defiant, it is somewhat likely that rather more than physical violence that was being defied, and more than freedom of speech defended by the crowd. As Brian Klug wrote:

Here is a thought experiment: Suppose that while the demonstrators stood solemnly at Place de la Republique the other night, holding up their pens and wearing their “je suis charlie” badges, a man stepped out in front brandishing a water pistol and wearing a badge that said “je suis cherif” (the first name of one of the two brothers who gunned down the Charlie Hebdo staff). Suppose he was carrying a placard with a cartoon depicting the editor of the magazine lying in a pool of blood, saying, “Well I’ll be a son of a gun!” or “You’ve really blown me away!” or some such witticism. How would the crowd have reacted? Would they have laughed? Would they have applauded this gesture as quintessentially French? Would they have seen this lone individual as a hero, standing up for liberty and freedom of speech? Or would they have been profoundly offended? And infuriated. And then what? Perhaps many of them would have denounced the offender, screaming imprecations at him. Some might have thrown their pens at him. One or two individuals — two brothers perhaps — might have raced towards him and (cheered on by the crowd) attacked him with their fists, smashing his head against the ground. All in the name of freedom of expression. He would have been lucky to get away with his life.

It seems that some things you can say and governments will try and protect you. It would appear in much of Europe that blaspheming Islam is legally OK. But, as noted above, saying other things will get you arrested. The French "comedian" Dieudonné was arrested just 48 hours after the march through Paris on charges of "defending terrorism". Whilst not arrested, the UK Liberal Democrat MP David ward tweeted "Je suis Palestinian" during the Paris marches and criticised the presence of the Israeli prime minister, Netanyahu, subsequently eliciting a complaint from the Israeli ambassador to Britain. Of course the "world leaders" who gathered in Paris have a wonderful record themselves on "protecting" free speech.

Charlie Hebdo did not practise satire by mocking select, specific targets, nor did they mock all major religions equally. It's been widely reported that they sacked a cartoonist for making an anti-Semitic remark and that:

Jyllands-Posten, the Danish newspaper that published caricatures of the Prophet in 2005, reportedly rejected cartoons mocking Christ because they would "provoke an outcry" and proudly declared it would "in no circumstances ... publish Holocaust cartoons".

But of course it comes down to the content of the publication. In this case the cartoons exist to ridicule, make fun of and offend members of one of the world's largest religions, Islam, by mocking their prophet Mohammed. As Amanda Taub writes:

Dalia Mogahed, the Director of Research at the Institute for Social Policy and Understanding, explained that Mohammed is a beloved figure to Muslims, and "it is a human impulse to want to protect what's sacred to you".

Mogahed compared the cartoons to the issue of flag-burning in the United States, noting that a majority of Americans favour a constitutional amendment to ban flag-burning for similar reasons: the flag is an important symbol of a national identity, and many Americans see flag-burning as an attack on that identity, or even on the country itself. That's not extremism or backwardness; it's about protecting something you cherish.

In any large group of people, there will be the vast majority of sound mind and thought, and a small minority who are not. This is just the fact that all over the earth, humans are not all the same: there is some variance in health, intelligence, and every other aspect of what a human is. Any large sampling of humans will show the same set of variations. So if you offend a huge group of people, you will offend tall people and short people, rich people and poor people, fat people and thin people, violent people and peaceful people. Unsurprisingly, it would appear that the background of these killers suggests there is little to do with Islam there, and more to do with the their upbringing, family, education and integration with society.

Thus even if you feel Charlie Hebdo's publications of the cartoons served some purpose (given their biased choice of target, their purpose does not seem to be an exercise in itself of freedom of speech), it should be obvious that by offending so many people, they were placing themselves in danger. The same is true of any sustained, systemic, deliberate offence to any of this planet's major religions, races, nationalities or any other grouping of humans which share values. So it becomes a balancing act between how much do you believe in the message you're publishing versus the risk you're putting yourself in. You can view the actions of Edward Snowden in this same context: he felt that the message he was delivering on the abuses of surveillance power carried out by governments across the world outweighed the significant danger he was putting himself in, and so both delivered the message and accepted the need to flee from his country, probably never to return, in fear of the consequences of his actions.

Thankfully, throughout history, there have been people who have chosen to put themselves in the path of great harm (often losing their lives as a result) in order to report, expose, document and publicise matters which the wider public needed to know. Governments, monarchies and empires have crumbled when faced with popular revolt.

So freedom of speech requires consideration. It is perfectly reasonable not to say something because you anticipate you won't enjoy the consequences. Most of us do not conduct our lives by going around saying anything and everything we want to our friends and family: if we did, we'd rapidly lose a lot of friends. The expression "biting your tongue" exists for a reason. Equally, it's perfectly reasonable for a news outlet to decide not to re-publish the Charlie Hebdo cartoons if they fear a violent response that they suspect the local police forces cannot prevent; not to mention just not wanting to offend so many people.

I view as daft the idea that people should never choose not to publish something out of fear. People absolutely should choose not to publish, if they feel the risk to the things they hold dear is not outweighed by the message they're delivering. Everything in life is a trade-off and every action has consequences. Whilst I agree with the right to free speech, that does not imply saying anything you like is free of consequences. If it were, it would require that words have no meaning, and subsequently all communication is void: if anything you say has no consequence then you can say nothing.

I am certainly not suggesting the murders were in any way justified, or that Islam or any other religion or collection of humans should be beyond criticism or even ridicule. At the end of the day, no human is perfect, and as such we can all benefit from a thorough dose of criticism once in a while. Every article I've linked to in this post repeats that such violence, regardless of the provocation, is abhorrent, and I agree with that: murder is never an acceptable response to any drawing, written or spoken word. But that doesn't mean that these events weren't predictable.

Finally then we get to the insanely idiotic response from the UK government. That MI5 should have more powers that they don't need (they probably just need more money), and that we must deny terrorists "safe space" to communicate online. Which means banning encryption, which means it's impossible to use the internet for anyone. The home secretary, Theresa May said:

We are determined that as far as possible there should be no safe spaces for terrorists to communicate. I would have thought that that should be a principle ... that could have been held by everybody, across all parties in this House of Commons.

So of course, if terrorists can't communicate in private then no one can. Quickly, we've immediately gone from lazy labelling of events as an attack on free speech to a knee jerk response of "free speech yes, but you certainly can't have free speech in private, because you might be a terrorist". Again, it's a trade-off. I doubt that having such restrictions on communication will make the earth or this country safer for anyone and of course the impossibility of a controlled study means it cannot be proven one way or another. No security service is ever going to be flawless and from time to time very horrible things will continue to happen. I think most people are aware of this and accept this; we're all going to die after all. The loss of civil liberties though is certainly far more worrying to me.

In theory, I would think these proposals so lunatic as to never see the light of day (it would be completely impossible to enforce for one thing - terrorists along with everyone else would learn to use stenography to encode their messages in pictures of cats, thus rendering their traffic no different to that of everyone else). Sadly, Labour have stated they don't believe their position to be that far away from the Conservatives, which is deeply worrying. Labour don't exactly have a great record on this area either given their previous ID card schemes and the introduction of detention-without-charge. What is needed is some transparency. We need an informed debate, with MI5 and GCHQ providing some independently verifiable facts and figures that demonstrate how they are being thwarted in what they're trying to do. We need to understand properly what the risk to us is, and most importantly we need to understand why these threats exist and what else we can do to make them decrease.

I've never seen it said that any UK Government policy in the last 15 years has made the UK less of a target for such attacks. Maybe we should look at that before we start subjecting ourselves to Orwellian control.

Categories: Offsite Blogs

announce: xmonad-entryhelper

Haskell on Reddit - Sat, 01/17/2015 - 1:59am

xmonad-entryhelper

This package is for those who loves to keep things in sandboxes.

After suffering from dependency hell several times, I find it really helps to minimize system level packages and keep other packages either in user level or in sandboxes.

I was able to remove xmonad from system packages, and have ~/.xinitrc to call my compiled xmonad config. But soon I realized, different from xmonad itself, the compiled config cannot do some fancy stuff like up-to-date checking, recompilation & send xmonad restart requests.

Therefore I wrote this package to wrap the main function to deal with xmonad arguments like --recompile and --restart. This makes the compiled binary behave like xmonad binary itself.

Additionally with this package you will be able to customize recompiling action: for example you can use Makefile to manage your xmonad config and set environment variable $XMONAD_HOME to your xmonad path. Then you can make your "xmonad --recompile" call shell command "cd ${XMONAD_HOME} && make all" to do the job.

Hope you like this package!

submitted by Javran
[link] [6 comments]
Categories: Incoming News

Any efficient library for sprite-based animations?

Haskell on Reddit - Fri, 01/16/2015 - 11:21pm

Gloss, which I was using, doesn't have a "blit" function to paste an image in another (which is required for a sprite based animation). REPA has a (//) operation that could be used to set individual pixels and thus implement this - but reading the code I feel it is kinda slow (maybe I am mistaken, but looks like it does a lookup in a list for each pixel?)

Is there any similar library which offers such option?

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

haskell.org slow

haskell-cafe - Fri, 01/16/2015 - 6:48pm
Anyone know when haskell.org <http://haskell.org/> will be usable again? Page loads take 20+ seconds. Info at https://status.haskell.org <https://status.haskell.org/> indicates there's a DB problem, but there's no ETA and performance has been bad for over 10 days. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Is this warning really a good idea?

Haskell on Reddit - Fri, 01/16/2015 - 2:17pm

I have the following line of code

mapM_ (\uid -> printEmailAddress connection uid) (reverse messageList)

The compiler gives me the following warning

Warning: Avoid lambda Found: \ uid -> printEmailAddress connection uid Why not: printEmailAddress connection

Now, I understand the warning completely from a technical perspective but it seems to me that the statement becomes much less clear if the parameter is removed so is this really a good thing to warn about? If so, why?

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

Shower thought: would an efficient supercompiler make ad-hoc static type systems possible in a dynamically typed language?

Haskell on Reddit - Fri, 01/16/2015 - 2:15pm

I've been thinking, suppose we had an efficient supercompiler in a dynamic language (say, an untyped dialect of Haskell). Then, we could simulate types with tagged values.

TypeError = symbol Correct = symbol Int = symbol Double = symbol check TypeError expr = TypeError check Correct expr = expr tagInt num = (Int, num) isInt (Int,_) = Correct isInt _ = TypeError tagDouble num = (Double, num) isDouble (Double,_) = Correct isDouble _ = TypeError let addDoubles x y = check (isDouble x) (check (isDouble y) (x + y)) let program x = addDoubles (tagDouble 3.0) (tagInt x)

If this program was fully supercompiled, it would in inevitably result in:

program x = TypeError

So we know our program won't typecheck when it supercompiles to TypeError! But if you supercompile this:

program x = add (tagDouble 3.0) (tagDouble x)

This would be supercompiled to:

program x = 3.0 + x

That is, we got rid of the runtime checking, like a static type system should do. Of course, you would need a few ad-hoc syntax sugars to simulate Haskell's syntax, but, functionally speaking, am I correct in thinking supercompilation would allow ad-hoc type systems?

Edit: code

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

Haskell Platform 2.0 comes with empty /bin

Haskell on Reddit - Fri, 01/16/2015 - 11:41am

I don't understand why I followed a simple GUI install and yet GHC 7.8 wasn't installed. I have already uninstall-hs --remove all from my computer. Attempting to start from scratch. I'll try to download the .tar.bz file again but when building it the gwd-pwd executable binary file WON'T EXECUTE. So I can't even ./configure . Anyone else run into this or know of a way to work around this?

submitted by dgomez1092
[link] [3 comments]
Categories: Incoming News