First off, I really don't know anything about Haskell. My only exposure to the language has come from my heavy use of xmonad, which is written and configured in Haskell. I have managed to write a config that suits my purposes quite well, but that doesn't mean I understand it.
My problem is that I have something that looks like this in my code:myStartupHook = spawn "xsetbg ~/somebackground.png"
which sets the background image of the desktop. I like this. However, I am using MATLAB and have found out Java sucks balls in the most impressively obscure ways. Xmonad and java do not play nice together, and to get things working I need a line like:myStartupHook = setWMName "LG3D"
My question is how do I combine these two desirable commands into one line? Is that possible?submitted by Registar
[link] [11 comments]
As the performance of those monads is said to be abysmal, I rewrote RWS-like transformers (here).
These transformers are not really generic Writer instances (Only work on list, I needed them for a system where I mostly need cons, so this made sense to me), and doubled the speed of my program that way.
Is there already something like that on Hackage ? Would you think it is worth having it ?submitted by bartavelle
[link] [5 comments]
So, I'm trying to write a game using Reactive-banana and SDL. I've setup a gameloop based on this. The problem is that when I run the game it's just a black screen, it doesn't render the white cube as it is supposed to do. I've even tried making ship a constant event of some value and still it doesn't render. I've also double-checked the render function, and it does work if I just loop it. Anyone got an idea of what might be wrong?
Here is my code: https://gist.github.com/klrr/7660892submitted by klrr_
[link] [7 comments]
Amdahl's law for predicting the future of multicores considered harmful B.H.H. Juurlink , C. H. Meenderinck, ACM SIGARCH Computer Architecture News, Volume 40 Issue 2, May 2012, Pages 1-9.
Several recent works predict the future of multicore systems or identify scalability bottlenecks based on Amdahl's law. Amdahl's law implicitly assumes, however, that the problem size stays constant, but in most cases more cores are used to solve larger and more complex problems. There is a related law known as Gustafson's law which assumes that runtime, not the problem size, is constant. In other words, it is assumed that the runtime on p cores is the same as the runtime on 1 core and that the parallel part of an application scales linearly with the number of cores. We apply Gustafson's law to symmetric, asymmetric, and dynamic multicores and show that this leads to fundamentally different results than when Amdahl's law is applied. We also generalize Amdahl's and Gustafson's law and study how this quantitatively effects the dimensioning of future multicore systems.
Holden Karau: I've written a book "Fast Data Processing with Spark" which covers Python, Scala, and Java
Fast Data Processing with Spark covers how to write distributed map reduce style programs with Spark. The book guides you through every step required to write effective distributed programs from setting up your cluster and interactively exploring the API, to deploying your job to the cluster.
Personally, while the fast nature of Spark is not to be understated, I really enjoy its functional style APIs and find it a lovely environment to code in.
Basicaly, how would one insert an node at the nth dimension of a bianary tree, such as the one from Data.Tree?
Example:insertAtLevel 2 (Node 3 [Node 4 , Node 5, [Node 2 ]]) (Node 3 )
would giveNode 3 [Node 4 , Node 5 , [Node 2 , Node 3 ]] submitted by Undo_all
[link] [8 comments]
I was just messing around with the loeb function that was posted here a few days ago and wanted to try and make it effectful.mmoeb f x = mfix go where go g = f ($ g) x mloeb :: :: (MonadFix m, Traversable t) => t (t b -> m b) -> m (t b) mloeb x = mmoeb mapM
then we just make up a IO-indexing function likegetIndex xs = getLine >>= (\x -> return $ xs !! (read x))
then you canmloeb [getIndex, getIndex, const $ return 3]
which works like you'd expect. Obviously you can substitute mapM for anything that lets you dofmapM :: (Monad m, Functor f) => (a -> m b) -> f a -> m (f b)
I'd kind of like to be able to provide a 'seed' value, so for example if I wanted to make a Game of Life I could just have a grid of the function setting the rules, and a seed grid, and just take the sequence. I'm not sure exactly how to do that though.submitted by onomatic
[link] [7 comments]
There are three parts to this post. Everyone should read the first two sections, especially the second section. Haskellers should also be sure to read the third section.The Announcement
If you don't yet know: I'm transgender. My sense of gender and self have never aligned with my physical appearance, and I’ve spent most of my life dealing with this fact. This is not an acquired condition nor a recent change; it is an intrinsic and life-long part of who I am. I began the process of transitioning half a year ago and, over the next six months or so, I will complete the transition to living as a woman full-time.
Many of my followers are already familiar with transgender issues, but since this is a public announcement I assume many of you are not. There are numerous resources online for learning more, but I find the PFLAG pamphlet to be a particularly good place to start. If you still have any questions after reading that, I can provide additional resources and am willing to answer questions.How to respond
This is going to depend on how you know me.
- If we interact predominantly online
- This includes everyone in the Haskell community (both online and academically), as well as everyone from Reddit, Twitter, etc. Henceforth, please use feminine pronouns (she/her/hers) exclusively when referring to me. I understand this will take some getting used to, but it will soon become second nature.
- If we interact predominantly in person
- I'd prefer you use feminine pronouns (she/her/hers) when referring to me, especially when online and when mentioning me anonymously. But, for the time being, masculine pronouns (he/him/his) are still acceptable. Sometime in the spring I will send another announcement around letting you know when "T-day" is. After that date, I will be presenting as female full-time and will no longer tolerate masculine pronouns.
I shouldn't have to say this, but since there were some complaints about the "homosexual propaganda" in my recent posts, may I remind my readers of The Planet Haskell policies regarding political and religious content. I rarely post political content, but am well within the guidelines in doing so. The stated mission of Planet Haskell is to "show what is happening in the community, what people are thinking about or doing". I am an active and well-known member of the Haskell community, and the violence endured by trans people is something I've been thinking a lot about lately. When Chung-chieh Shan gave the 2013 Haskell Symposium program chair report, he made a specific point of highlighting the effects of sexism, racism, homophobia, and transphobia in driving people out of the Haskell community. Therefore, I think it is fair to say that these issues are pertinent, above and beyond my personal involvement with them.
That said, I do not intend to discuss trans issues at length on this blog. Nevertheless, on occasion, these issues will come up because I refuse to live in silence and shame for who I am.
My program decodes text that has been through a Caesar cipher.
The first file exports two pure functions, one is the Caesar cipher itself, and the other is the decoder. The decoder works by trying all 26 possibilities and returning the one that has the most real words in it.
The second file handles IO. It uses two files: secrets.txt is a list of secrets to be decoded, each on its own line. dict.txt is the dictionary with each word on its own line.
I don't have any particular questions, I'm just looking for general advice on writing good Haskell code. Thanks!submitted by CoreyN
[link] [28 comments]