# News aggregator

### Is it practical to write a strong chess engine in Haskell?

I've been dabbling in writing a chess engine in Haskell for a while now. The main problem I am having is that a bitboard engine (the principle game representation is an array of fourteen 64 bit integers, one integer for every piece type, e.g. black bishop, white pawns) requires quick updating.

That is, I need to be able to non-patterned write and read an array really fast, at least at the assembly level. I used unsafe reads and writes to no avail. I'm not sure why it's so slow.

For those who are more experienced, is writing a mid strength or strong chess engine practical in Haskell? How about in idiomatic Haskell? I hear all the Haskell supporters saying that Haskell can do anything C can and almost just as fast, but I don't think I'll be convinced at least until a mid-strength chess engine is written.

What about in OCaml or a similar impure functional language?

Thanks for any answers.

Edit:

This got more response than I expected. The Haskell community is great.

I had to dig in the archives a little, but here is a quick repo I made: https://github.com/EricThoma/hchess.

Disclaimer: I wouldn't normally present this code online, as it probably has many errors and shows my novice. Most of it is very much C written in a do statement. The actual chess move-making isn't 100% accurate yet either. Frankly, I think I've grown enough as a programmer in the year or so since I wrote this that I'm a little embarrassed.

The way I am benchmarking it is by using a perft function, which is the most straightforward way to measure the raw move-making and move-generating speed of an engine. On my machine the engine barely cracks 1 million nodes per second. As a comparison, Stockfish is somewhere on the order of 50 million NPS, though I would think Stockfish runs on black magic if I couldn't see the source.

For those who understandably don't want to read my source, I am using Data.Vector.Unboxed.Mutable and Data.Vector.Unboxed and Data.IORef extensively, with unsafe writes and reads.

If I were to try again, I would definitely rewrite the engine base from the ground up. Also, I would write my own magic moves generator in Haskell (I have since done so in my C engine).

submitted by FrankAbagnaleSr[link] [26 comments]

### Wadler's Blog: Howard on Curry-Howard

### What Haskell feature do you miss the most when writing code in other languages?

For me it's the type synonyms and newtype. In Java I end writing functions with signatures like "int(Collection<Pair<Integer, Integer>>, int)", which of course need all kinds of documentation so that I remember what they do in a week. If I could easily create new types, that signature could be "ReturnCode(Collection<Pair<EntryId, Count>>, RowId)" (I might not go that far, but you get the point).

Integer is final in Java, so if I wanted to make a new type, I would have to create a wrapper type with an int field and then access the int field every time I used the object. Drives me insane. And there's no way at all that I know of to create a synonym so that I can use either type interchangeably.

submitted by dont_memoize_me_bro[link] [16 comments]

### Third call for papers, IFL 2014

### Third call for papers, IFL 2014

### [ny-haskell] Abstractions for the Functional Roboticist with Anthony Cowley

### CFP: PRDC2014 Call for Participation

### System.Process.readProcess "yes" [] "" >>= return .take 100

### New Functional Programming Job Opportunities

### SCSS 2014: Call for short and work-in-progress papers

### projects.haskell.org Pipermail not Google-indexed?

### The Ivory Language is an eDSL for safe systems programming. You can think of Ivory as a safer C, embedded in Haskell.

### Race conditions with threadWait(Read/Write) andcloseFdWith

### Wikipedia: "In functional programming, a monad is a structure that represents computations defined as sequences of steps." Do people here feel this is an accurate summary of FP monads, given e.g. the Maybe and List monads?

### Paresc's homepage is gone

Hi,

I just visited parsec's homepage and it's gone.

Anyone knows where I can find it?

LE: Meanwhile, I found this: https://research.microsoft.com/en-us/um/people/daan/download/parsec/parsec.pdf

submitted by paullik[link] [7 comments]

### Douglas M. Auclair (geophf): August Haskell Daily puzzles and solutions

**August, 2014**

- August 1st, 2014: "But programming isn't math, so ..." Today's #haskell problem? 'Fix' yesterday's solution to be less ... 'icky.' http://lpaste.net/108559 π, fast (So you're not eating π? ... okay: 'quickly.') A solution set to today's exercises with Wow-o-wow results. http://lpaste.net/108576
__Bonus__: August 1st, 2014: This is Embarrassing(ly parallel) to have π in da face! http://lpaste.net/108562- A-to-the-ST for da D-down-low-on-the-SL. Today's #haskell exercise is write your own language, then some rules. Yeah. http://lpaste.net/108733. LAWLZ! NAND on the A-to-the-ST! http://lpaste.net/108758 A solution to the first 2 exercises to today's problem. YMMV: not pretty nor generic.
- Baby needs a new pair of shoes! And you need a new daily #haskell problem to solve. http://lpaste.net/108820 Done! ;) Love is the Universal Language. No, wait. We were talking about Money, yes? Me confused. Solution to today's exercise http://lpaste.net/108829. I have a Yen for Thinking Japanese, or so I think so ... a solution to the bonus #haskell exercise http://lpaste.net/108871
- Bayes was a man of letters. A Bayesian classifier for letter-recognition? Sure, let's give it a go for today's #haskell exercise. http://lpaste.net/108901 So now we know 'M' looks like 'W' to some peeps but 'B', 'I', 'O' check out fine, so WE ARE READING WITH HASKELL! YAY http://lpaste.net/108916 ... added definitions to do test runs over the entire data set and then did various runs, tweaking the system. Results noted. Informative.
- Today's #haskell exercise. An expert system for blood donation. I use the term 'expert' loosely, eh? ;) http://lpaste.net/108989 Have at it! "I vant to drinq yur bloot! Bwa-hahaha!" Okay. That quote is just ... creepy. A solution to today's exercise is at http://lpaste.net/108994
- Veni, Vidi, ... Duci? http://lpaste.net/109043 Today's #haskell exercise. It is a relief to know that no tactical nukes were launched by testing the solution to today's #haskell exercise. http://lpaste.net/109061 or How do you count Mississippi's in Roman numerals?
- August 11th, 2014, Monday: You've heard of 'Rock Management'? How about ROCK LOBSTERS! GIVE ME A ROCK, NAOW!!!1!!!!11! Today's #haskell exercise http://lpaste.net/109188
- August 12th, 2014, Tuesday: To Fract or Not to Fract: why are we even considering this question? Today's #haskell exercise http://lpaste.net/109219

- Ooh! Bonus problem? On a Tuesday? Wowsers! Today's #haskell #bonus problem: "Continuum spectrum maximum... uh, 'thing'um" http://lpaste.net/109205
- August 13th, 2014, Wednesday. No problem! (literally), but: "Fract! The Cylons!" No... wait: Starbuck used a different word. A solution to yesterday's fracting problem is at http://lpaste.net/109341

Twin Peaks. Still not fracted, but data set with two spikes rolled into the base data set with smoothSpike fn

Fracted. Data set with peaks, fracted using the frackedSpike function

- August 14th, 2014, Thursday: Pining for that next fibo date-time before 2584. Today's #haskell problem inspired by @AlgebraFact http://lpaste.net/109349. Updated problem. Tightened up return value, removing unnecessary semideterminism. So, it gives, leik, a septatuple answer, leik. ... Yeah. Time keeps flowing like a (Fibonacci) river, to the sea. http://lpaste.net/109389 A solution to the 'next Fibonacci' problem posted today.
- Hail, Eris! or the Law of Fives or today's #haskell problem (implementing a Ripple-down rule set). Do it to it! http://lpaste.net/109350. One of three-parter solution to today's problem: Forall Existential(ism) http://lpaste.net/109458 A solution allowing forall-quantified values. Two of the three-part solution: All you need is fnord (la-di-da-di-dah)! Rippling down (and accumulating fired) rules http://lpaste.net/109433. Third of three-part solution: RippleDownRuleto ergo sum, adding rules to the RDR system http://lpaste.net/109473. Updated the 3rd solution to the RDR (Writer monad definition) to ripple down to left and right, fixing inconsistency in rule findings.
- August 18th, 2014: What's FP good for? Crypto and technical (financial) indicators. Why? Um, let's do today's #haskell exercise! http://lpaste.net/109553. Full on, all the way! Double Rain-... wait: line-graph. Solution to today's #haskell exercise http://lpaste.net/109597

- August 19th, 2014: What does it all mean? All the way! No, wait: this is just today's #haskell exercise (backtesting SMA indicator ). http://lpaste.net/109617 Take the monoid and run(State-WriterT), or WAAH! WAAH! I lost 100 corn chips on my investment strategy or, solution: http://lpaste.net/109687 But, as solace, it does come with a pretty picture, illustrating today's solution. Ooh!

- August 20th, 2014: Next up for today's #haskell exercise is the Exponential Moving Average. http://lpaste.net/109689 A solution to the E(xponential)M(oving)A(verage) #haskell problem: Stately Conformance http://lpaste.net/109707

- August 21st, 2014: My Jeans. No ... I meant: 'GENES'! That's it. Today's #haskell exercise. http://lpaste.net/109749 A solution to (not even CLOSE to) 'yesterday's' #haskell exercise: Nature or Nurture? We present a genetic algorithm http://lpaste.net/110330
- August 22nd, 2014: Today's (much delayed) #haskell problem: the Silver Ratio http://lpaste.net/109817 (from @AlgebraFact ) Every cloud has a silver lining .. Every Haskell problem has a solution. (sometimes) (except noncomputable problems) http://lpaste.net/109831

- August 25th, 2014: LYADCFGG! Today's #haskell exercise? (automated/learned) Document classification. http://lpaste.net/109980/
- August 26th, 2014: "Join me, Luke, on the Dark Side of the Force, and help me go #FORTH to solve today's #haskell exercise! MWA-HAHA!" http://lpaste.net/110062 The World's smallest DSL: Forth. A solution to today's #haskell exercise http://lpaste.net/edit/110085
- August 28th, 2014: "As I compose this #haskell problem ... p.s. I love you ... You! You! You!" #1960s #song http://lpaste.net/110135 A little card logic problem. Oh, NOES! LOOK OUT! IT'S A CARD-#SHARKNADO! Nah, it's just 'today's #haskell solution, is all http://lpaste.net/110334

- August 29th, 2014: Groovitudes! WordNet Themes! or: today's #haskell exercise http://lpaste.net/110171 A 3x3 matrix has 36 possible solutions. A 5x5 matrix? Over 200M poss solutions? YIKES! A solution to the themed-words http://lpaste.net/110293

**Notes**

- The Forth language problem solution given on August 26th gives a very snazzy RPN ('reverse Polish notation') calculator, but that's all it does the ':'-defining word needs access and look-ahead to the program parsed stream, and that's a bit more to ask than pushing and popping stack operators.
- For the August 29th problem(WordNet themes) the raw generated solution set is over 209M possibilities. My little Haskell program was not finished scanning them over four hours when I killed the process. However, my dear wife solved the problem in under five minutes. Setting aside the fact that she's a genius, the program needs to be better. It needs to use the ontology of English-language words to eliminate fruitless endeavors during their generation, not afterwards during the test phase.