News aggregator

What's the performance bottleneck in this prime sieve function?

Haskell on Reddit - Fri, 07/11/2014 - 2:01am

Learning haskell, I wrote this simple function that's supposed to return a list of prime numbers up to n. It works for low enough n, but above 5000 or so, it becomes noticeably slower to begin, which is far lower than a prime sieve has any right to slow down. What am I missing?

import Data.List sieve :: (Integral a) => a -> [a] sieve n | n < 2 = [] | n == 2 = [2] | otherwise = comb [2..n] where comb xxs@(x:xs) | x^2 > last xs = xxs | otherwise = x : comb (xs \\ [2*x, 3*x .. n]) comb [] = [] submitted by ZankerH
[link] [21 comments]
Categories: Incoming News

I just built my first app in haskell (a CHIP-8 cpu emulator). Code review and/or tips?

Haskell on Reddit - Fri, 07/11/2014 - 12:01am

Hey guys,

I started working on an emulator for the old CHIP-8 CPU as a project to learn haskell. Although it probably wasn't the best choice of project due to how basic it is, I've definitely gotten hooked on haskell.

I've done a few clojure projects in the past, so I'm familiar with the functional programming basics, but I haven't experimented much with haskell's abstractions (apart from basic monads).

If anyone can offer any improvements or tips, i'd be greatly appreciated. I'm planning on doing plenty more haskell projects, so I'd like to nip any bad practices in the bud.

You can find the project here: https://github.com/tominated/chip-8-vm.

Thanks in advance!

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

Tutorial for reader and write monad?

Haskell on Reddit - Thu, 07/10/2014 - 9:24pm

Hey everyone. I've just started out with Haskell, and I just can't seem to understand how the reader and writer monads work. Could someone point me to some place where they're explained well? Thanks!

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

Meetup - Calling all haskellers from Croatia

haskell-cafe - Thu, 07/10/2014 - 8:07pm
We've opened a meetup group for all haskellers from Croatia and someone suggested we should post info about it here as it might reach more interested people that way. Here's the link to the meetup group (please join): http://www.meetup.com/haskellzg/ Sorry for the spam if this doesn't apply to you. -Deni _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

[ANN](and feedback request) unagi-chan: Fast and scalable concurrent queues for x86, with a Chan-like API

haskell-cafe - Thu, 07/10/2014 - 7:39pm
I'm happy to finally release unagi-chan, an implementation of high-performance concurrent FIFO queues that have an API very similar to Control.Concurrent.Chan. You can see benchmarks and documentation here: http://hackage.haskell.org/package/unagi-chan If you have a moment (especially if you're on a non-x86 architecture) please take 10 minutes and run the tests with: $ cabal configure --enable-tests $ cabal build $ time ./dist/build/test/test Thanks to Ryan Newton for helping answer some low-level questions about his atomic-primops package which provides the CAS and fetch-and-add implementations that are the core of unagi-chan. REQUEST FOR FEEDBACK: would anyone be interested in any functionality like the following: - concurrent builder for Text, something like: new :: IO (InTextChan , Lazy.Text) write :: String -> InTextChan -> IO () - something similar for ByteString (is there a class for types convertable to ByteString?) - concurrent Text and/or ByteSt
Categories: Offsite Discussion

ATX Haskell meetup/study groups happening this month!

Haskell on Reddit - Thu, 07/10/2014 - 4:46pm

http://www.meetup.com/ATX-Haskell/events/194123362/

Here in sunny Austin Texas we've spun up a Haskell meetup group, and if you're in the area, you should join! Specifically, we've set up a small meetup tomorrow as a training class to help people solidify and expand their Haskell knowledge.

We currently are having monthly meetups here with classical talks, and we're also planning of setting up monthly or biweekly study groups like the one tomorrow for people to talk and learn in a different setting. So the one tomorrow will hopefully be the first of many more to come.

Tomorrow the study group will be downtown at MakerSquare - and if you're in the area, you should come by! Brand new to Functional Programming? Don't have GHC installed? Don't even know what Haskell is? No matter - things will happen, people will learn things, and you should come by and learn how awesome it is and how awesome all of us are, and we'll help you as much as we can.

Next week we'll be having a meeting at Rackspace in North Austin, where we'll be talking about error handling in Haskell, and I'll probably talk about something and I have no idea what that will be yet (it'll be a secret).

We normally have a turnout of about 20 people for the meetings. But that's just because you haven't come and hung out yet. The meetings are typically open forum and rather lax. So you're encouraged to raise your hand or just speak up.

We also tend to go drink beers and talk into the night afterwords - with many riveting conversations, including subjects like (roughly in order of priority):

  • Tacos. Beer. Serious business.
  • Why is software so terrible?
  • How to achieve world domination in a purely-functional way?
  • Education and how to do that properly.
  • War stories (tears of joy/pain are encouraged)
  • Cloud computing (the half-dozen Rackspace employees love this one!)
  • Ask Austin (me, not the town) how some random GHC thing works.
  • Non-taco-related foods.

Also, a bajillion points go to Rackspace for giving us a great working space for our meetups so far and providing us with great pizza for the past several meetings.

submitted by aseipp
[link] [comment]
Categories: Incoming News

Edwin Brady: Resource-dependent Algebraic Effects

Planet Haskell - Thu, 07/10/2014 - 11:21am

A new draft paper, Resource-dependent Algebraic Effects, is available. Abstract:

There has been significant interest in recent months in finding new ways to implement composable and modular effectful programs using handlers of algebraic effects. In my own previous work, I have shown how an algebraic effect system (called “effects“) can be embedded directly in a dependently typed host language. Using dependent types ought to allow precise reasoning about programs; however, the reasoning capabilities of effects have been limited to simple state transitions which are known at compile-time. In this paper, I show how effects can be extended to support reasoning in the presence of run-time state transitions, where the result may depend on run-time information about resource usage (e.g. whether opening a file succeeded). I show how this can be used to build expressive APIs, and to specify and verify the behaviour of interactive, stateful programs. I illustrate the technique using a file handling API, and an interactive game.

I’ve just submitted this, although constructive comments and suggestions are still of course very welcome!


Categories: Offsite Blogs

Threading Argument vs Reader Monad

Haskell on Reddit - Thu, 07/10/2014 - 11:19am

I've been wondering about this for a little bit:

Q: When is it more convenient to use a Reader Monad as opposed to just threading an argument through your program?

I.e. what is the advantage of:

f :: String -> Reader Config SomeType -- vs g :: String -> Config -> SomeType

One advantage I've seen is that if you don't annotate your functions with type signatures and use the Reader Monad with type inference, you can change the type of the shared environment without having to update much code (except code that pulls out of the shared environment, but that can be factored out and shared as well). Is this the only advantage? The disadvantage to this approach, imo, is you lose the nice readability you get from explicit type signatures.

On the other hand, if you need to introduce a dependency, you can just thread it through your function via plain-old arguments. What do you lose with this? Is it that you must update all functions that depend on modified methods, and programming in a monadic style may avoid some of these explicit refactorings?

Perhaps using the Reader Monad becomes more handy in large code-bases?

Thanks!

PS - my apologies if I'm not articulating this well.

Edit: thank you everyone. The consensus as I understand it seems to be (upstream/downstream refer to a methods call graph):

  1. Reader monad allows environment-independent methods from having to manage the environment for downstream dependencies.
  2. Reader monad is safer (you cannot manipulate or change the environment in an upstream method)
  3. MonadReader class makes working with Reader monad nice .
submitted by aaronlevin
[link] [16 comments]
Categories: Incoming News

Parsing Python source code

Haskell on Reddit - Thu, 07/10/2014 - 11:01am

For my summer project, I’d like to learn Haskell by implementing a Python 3 interpreter. I’m evaluating options for parsing, specifically the whitespace sensitivity part. Either:

  • Alex + custom lexer pass to accommodate indent tracking + Happy (conventional approach)
  • Parsec + indents package

I started with Parsec, but got burned by it’s lexeme function eating newlines. Right now I'm using Alex + Happy, and wishing I had the help of idents. I’m more familiar with traditional yacc-esque LALR parser generators, so there's a comfort using them. (Since Python's grammar is LL, I believe it means Parsec is a viable option.)

Any advice on what to go with here?

submitted by mattygrocks
[link] [4 comments]
Categories: Incoming News

Help with performance of a sliding puzzle solver

Haskell on Reddit - Thu, 07/10/2014 - 10:13am

Hello, as a practice exercise I decided to code a sliding puzzle solver (like 8-puzzle or 15-puzzle). Now, the solution is there and it is working but the problem I face now is the runtime. I would like to request some help with optimising the solution (if at all possible). I'm interested to see what steps one could take to improve performance of their Haskell program.

My implementation can be found here: https://gist.github.com/anonymous/166d8a3323a3f96eab04

Sample input file:

4 5 4 3 8 9 2 6 1 0 13 14 7 15 11 10 12

If you run it under the profiler you will see that the amount of data we generate is about 9Gb. And the "problematic" functions are manhattan and boardDistance. I'm currently clueless about how to tackle these functions to optimise them (if at all possible). Seeking for your help!

Thanks

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

If you want to write PHP, learn Haskell

Haskell on Reddit - Thu, 07/10/2014 - 8:25am

Hi Timothy,

I’m xxxxx from Facebook’s recruiting team. I found your profile on Github and Haskellers and think that you could be a great match for Facebook.

We are currently looking for Senior Software Engineers to join our London office and work on products such as Search, Mobile Engineering, Developer Platform, Security, Site Integrity, etc.

Your passion for Haskell really caught my attention :)

Would you be interested in having a conversation about the opportunities at Facebook London that might be of interest to you?

If you are interested, let me know a day/time that suits and we can organise a time to talk.

Thanks, xxxxx

The funny thing, is I got an almost identical email from google a while back. These are all sent out as template letters.

Actually, I think that this isn't a great thing. This is zero barrier recruting. They didn't look at my code and chances are they'd stop being interested the second they saw my resume. I don't yet have enough experience working in a group to work as a senior engineer. I have about 12 hours work experience. It doesn't cost them anything to send out these emails en-mass. But it probably costs a lot of young developers time and stress trying to respond to them only to find later that the interest wasn't meant seriously.

submitted by timthelion
[link] [35 comments]
Categories: Incoming News

PEPM 2015: Call for papers

General haskell list - Thu, 07/10/2014 - 6:43am
PEPM 2015 Paper Submission Deadline: September 12 (FIRM) Note: deadline is significantly earlier than previous years. Hope to see you in Mumbai, India! ----------------------------- C A L L F O R P A P E R S ----------------------------- ======= PEPM 2015 =========== ACM SIGPLAN 2015 WORKSHOP ON PARTIAL EVALUATION AND PROGRAM MANIPULATION Tue-Wed, January 13-14, 2015, Mumbai, India, co-located with POPL'15 http://conf.researchr.org/home/pepm2015 Sponsored by ACM SIGPLAN SCOPE The PEPM Symposium/Workshop series aims at bringing together researchers and practitioners working in the areas of program manipulation, partial evaluation, and program generation. PEPM focuses on techniques, theory, tools, and applications of analysis and manipulation of programs. The 2015 PEPM workshop will be based on a broad interpretation of semantics-based program manipulation and continue last years' successful effort to expand t
Categories: Incoming News

Review brainfuck interpreter in Haskell

Haskell on Reddit - Thu, 07/10/2014 - 6:08am

https://github.com/kmspriyatham/brainfuck-in-haskell/blob/master/brainfuck.hs

Please go through it and tell me anything that can be done more elegantly. Thanks in advance.

submitted by kmspriyatham
[link] [5 comments]
Categories: Incoming News

Hackage update, part 3

Haskell on Reddit - Thu, 07/10/2014 - 3:10am
Categories: Incoming News