Is it possible to use fmap and other composition operators to avoid a lambda in something like the following?
filter (\x -> mod x 5 == 0) [0,3,5,13,25]submitted by stupidquest
[link] [33 comments]
I've come across this new plugin that makes writing Haskell in IntelliJ IDEA possible: haskell-idea-plugin. It seems to work nice so far, this makes me very happy, kudos to the authors.
But IDEA's editor doesn't seem to work with Hasklig, probably support for ligatures is missing or something... All text (including the symbols) looks just like plain Source Code Pro font.
So is there a way to make it work? Or some other way to make symbols commonly used in Haskell look nice, like candy in Leksah or that thing in Emacs?
Also if you can compare haskell-idea-plugin with the other IDEA plugin HaskForce, I would be interested in your experience.
I hope this is the right place for these kind of questions. Thank you for the answers.submitted by sideEffffECt
[link] [3 comments]
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.
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]
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]