News aggregator

Are transformers the answer to this problem?

Haskell on Reddit - Tue, 07/01/2014 - 8:43am

I'm writing a small program (an extension of a Pokemon game that got posted here a while ago) where I'm trying to not use IO as much as possible. The program relies on randomness (picking a random Pokemon and move) and on writing (say things like "Pokemon X attacked you for Y damage!").

Again, I'm trying NOT to use IO, so instead I'm using Rand (Control.Monad.Random) and Writer. Now, I have a couple of functions that return Rand g a (where a can be a pokemon name or move), but I would like to "log" the name and move after they come in.

Here's a simplified version of what I'm trying to do:

battle :: _ battle = do move <- getRandomMove -- returns an Rand g Move tell ["Pokemon attacked you with " ++ name move] damage <- calculateDamage -- returns an Rand g Damage tell ["And did " ++ damage] battle

Of course, this doesn't work (I'm mixing my Rands and Writers). I thought "maybe this is what Transformers are for?"). I tried using WriterT and RandT in a combination of ways, but I always go stuck, which makes me think that's not right either.

So my question are:

  • Are transformers the answer to my problem?
  • If so, how do you use them? (I'm failing to understands them from the tutorials I've found online)
  • If not, how could I solve this problem?

Edit: Formatting Edit2: battle is recursive

submitted by Die-Nacht
[link] [13 comments]
Categories: Incoming News

Algorithm for labeling same-colored regions in a 2Darray?

haskell-cafe - Tue, 07/01/2014 - 4:17am
(Apparently joining the list through the Google Groups interface doesn't work, but the post still shows up there. Sorry if you see this twice!) For fun, I'm writing a rules engine for the board game Go (in Haskell obviously). I have a board, which is a grid of spaces that can contain a black piece, a white piece, or nothing. Part of what i need to do is to detect regions of the same "color" (black, white, or empty) and get information about them like their size, the color of the bordering spaces, etc. Regions are bounded by other colors or the board edges in cardinal directions. I'm just starting on this so I haven't picked my data structures yet, but Vector (Vector _) or Map (Int, Int) _ are what I've toyed with. I have a vague idea of how I would go about this in an imperative language with mutation. I'd iterate over the board, keeping lists of points contained in the same region, combining (relabeling) regions if they happen to connect later on. (I realize there are probably better algorithms in those l
Categories: Offsite Discussion

PhD opportunities at the University of Birmingham

Haskell on Reddit - Tue, 07/01/2014 - 3:49am

We have a number of openings for PhD study at the University of Birmingham, and we also have an imminent funding deadline, so please contact me (or any of us in the theory group at Birmingham) immediately if you're interested.

I personally am looking for students interested in designing the next generation of functional languages. You can find a fuller announcement here.

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

Making new Unboxed Algebraic Types? (A Repa Problem)

haskell-cafe - Mon, 06/30/2014 - 7:55pm
Hi, could someone offer som advice on handling composite types with the Repa library? I can see a /long/ way around my problem, but I wonder what is the /best/ way ... The problem is that I am trying to parallellise a probabilistic algorithm using Repa. To handle pseudo-randomness in parallel, I couple each data element with a generator state, in a tuple. The generator state is of type TFGen (tf-random package) or StdGen¹ (random package), neither of which is an Unbox instance. Hence, I have been using boxed repa arrays. The code does not execute in parallel, and if I understand correctly this is because of the Boxed type. There is a workaround², but that requires an NFData instance. To make a NFData instance and work through the code to support it should be as simple as it is tedious, but it would still leave the other drawbacks of a boxed type. (In particular, I do sequential fold because the Repa fold function did not support boxed types.) I could of course rewrite the published libraries to us
Categories: Offsite Discussion

Haskell Wiki user account creation

haskell-cafe - Mon, 06/30/2014 - 4:33pm
Hi, I read the following note at the log-in page of haskell wiki: NOTE: Automatic wiki account creation has been disabled. If you would like an account please email "nominolo" (at the email service from Google) or on the haskell-cafe mailing list. Does anyone know the exact email address I should be sending to (is it nominolo< at > Thanks, Haitham _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

ANN: rest

haskell-cafe - Mon, 06/30/2014 - 3:27pm
We at Silk are proud to announce the release of our Haskell REST framework `rest'. Please see the related blog post for more information: Cheers, Adam _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

FARM 2014 Call for Participation

General haskell list - Mon, 06/30/2014 - 12:11pm
Dear Haskell interested, Please find enclosed the call for participation in FARM 2014: 2nd ACM SIGPLAN International Workshop on Functional Art, Music, Modelling and Design, co-located with ICFP 2014v in Gothenburg, September. All the best, /Henrik ---------- FARM 2014 2nd ACM SIGPLAN International Workshop on Functional Art, Music, Modelling and Design Gothenburg, Sweden; 6 September, 2014 The ACM SIGPLAN International Workshop on Functional Art, Music, Modelling and Design (FARM) gathers together people who are harnessing functional techniques in the pursuit of creativity and expression. Functional Programming has emerged as a mainstream software development paradigm, and its artistic and creative use is booming. A growing number of software toolkits, frameworks and environments for art, music and design now employ functional programming languages and techniques. FARM is a forum for exploration and critical evaluation of these developme
Categories: Incoming News

New gtk2hs 0.12.4 release

gtk2hs - Wed, 11/21/2012 - 12:56pm

Thanks to John Lato and Duncan Coutts for the latest bugfix release! The latest packages should be buildable on GHC 7.6, and the cairo package should behave a bit nicer in ghci on Windows. Thanks to all!


Categories: Incoming News