News aggregator

Proposal: Use uninterruptibleMask for cleanup actions in Control.Exception

libraries list - Wed, 09/03/2014 - 9:56pm
I'd like to propose a change in the behavior of Control.Exception to help guarantee cleanups are not accidentally lost. For example, bracket is defined as: bracket before after thing = mask $ \restore -> do a <- before r <- restore (thing a) `onException` after a _ <- after a return r This definition has a serious problem: "after a" (in either the exception handling case, or the ordinary case) can include interruptible actions which abort the cleanup. This means bracket does not in fact guarantee the cleanup occurs. For example: readMVar = bracket takeMVar putMVar -- If async exception occurs during putMVar, MVar is broken! withFile .. = bracket (openFile ..) hClose -- Async exception during hClose leaks the file handle! Interruptible actions during "before" are fine (as long as "before" handles them properly). Interruptible actions during "after" are virtually always a bug -- at best leaking a resource, and at worst breaking the program's invariants. I propose changing all the cleanup ha
Categories: Offsite Discussion

References on how to compile lazy functional languages

Haskell on Reddit - Wed, 09/03/2014 - 4:56pm

Hello to all!

I'm interested in implement a llvm compiler for a lazy version of simply typed lambda calculus, as an exercise. Which articles / books should I read in order to start this task? I know that there is the SPJ book "Implementation of Functional Programming Languages". Is this a good start or there is some more recent reference ?

Thanks!

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

Package bounds approximation

haskell-cafe - Wed, 09/03/2014 - 9:48am
Dear Cafe, I was wondering if there exists a tool to approximate what would be the minimal versions of the dependencies required by a package. I know that calculating this exactly is a bit intractable, but I was considering whether a tool that works as follows would work: 1) Compile the package with known to work dependencies 2) For each version of dependency as d: For each function in d used by My Package: * Perform unification of the resulting type when compiled with known to work dependencies and the type exported by the api of the version of the dependency in consideration. If all unifications succeeds, mark the version as compatible, incompatible otherwise This approximation is obviously not complete. Nevertheless, I would like to get opinions about whether this would be a good/useful/feasible approximation? Does the current GHC api export enough functionality for this package to be feasible? Are there alternatives? I was consider doing this as my `hack`
Categories: Offsite Discussion

ICFP "The Ghost of Church" -- collaborate?

Haskell on Reddit - Wed, 09/03/2014 - 9:00am

I am at ICFP right now (it's great!). There seems to be some kind of mystery going on called "The Ghost of Church". It involves some QR-codes that are put up at the conference venue here and there.

I have worked on it a bit, but I am utterly stuck! Anyone else here has taken a look at it? Has anyone solved it yet?

Shall we collaborate and win this thing with "team /r/haskell"? We could use this thread to share information.

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

"Lower case" infix type operator variables

haskell-cafe - Wed, 09/03/2014 - 7:03am
I spent a few moments confused by the fact the TypeOperators was insufficient to allow the following type to be parsed     constA :: Arrow (~>) => b -> (a ~> b) My current intuition is that since I *can* write things like     newtype (~>) a b = A (a -> b) there is clashing in the type operator space for “upper case” and “lower case” identifiers. Is it possible or advisable to mitigate this clash and provide some syntax for “type operator variables”? Joseph_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

GHC not able to detect impossible GADT pattern

glasgow-user - Wed, 09/03/2014 - 6:59am
I’ve been trying to stretch GHC’s type system again and somehow managed to get myself into a position where GHC warns about a non-exhaustive pattern where adding the (according to GHC) missing pattern results in a type error (as intended by me). It seems that even with closed type families GHC can’t infer some patterns can never occur? Complete code to reproduce the issue is including below, the non-exhaustive pattern happens in the local definitions ‘f’ of push and pull. I’m open to suggestions for other approaches. Kind regards, Merijn {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} module Test where import Data.Proxy import GHC.Exts data Message data SocketType = Dealer | Push | Pull data SocketOperation = Read | Write type family Restrict (a :: SocketOperation) (as :: [SocketOperation]) ::
Categories: Offsite Discussion

Hackage update, part 4

Haskell on Reddit - Wed, 09/03/2014 - 5:13am
Categories: Incoming News

HTTP package - supported GHC versions

libraries list - Tue, 09/02/2014 - 10:24pm
Hi, The HTTP package supports a whole load of old GHCs - the current version should actually work with GHC 6.10. For future releases I plan to drop most of these. Any opinions about how far back it should support? I'm thinking restricting it to either 7.4+ or 7.6+, but I'm open to keeping support for older versions too if there's a real need. Cheers, Ganesh
Categories: Offsite Discussion

Functional dependency failure

haskell-cafe - Tue, 09/02/2014 - 9:45pm
Hi! I have following code: STRead.hs: import Control.Monad.Reader import Control.Monad.ST import qualified Data.Vector.Mutable as MV import qualified Data.Vector as V type ReadVecMonad s = ReaderT (MV.MVector s Int) (ST s) freezeV :: ReadVecMonad s (V.Vector Int) freezeV = ask >>= lift V.freeze Trying to compile this I have "Couldn't match type ... When using functional dependencies to combine" error following with kind mismatch and type with literaly the same type mismatch. How can I work this around? There's full error message: STRead.hs:9:11: Couldn't match type `V.MVector s Int' with `(->) (V.MVector (Control.Monad.Primitive.PrimState (ReaderT (V.MVector s Int) (ST s))) Int)' When using functional dependencies to combine MonadReader r (ReaderT r m), arising from the dependency `m -> r' in the instance declaration in `Control.Monad.Rea
Categories: Offsite Discussion

Compose to avoid lambdas?

Haskell on Reddit - Tue, 09/02/2014 - 7:34pm

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]
Categories: Incoming News

IntelliJ IDEA haskell-idea-plugin + Hasklig

Haskell on Reddit - Tue, 09/02/2014 - 5:27pm

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]
Categories: Incoming News

ETAPS 2015 2nd call for papers

General haskell list - Tue, 09/02/2014 - 11:32am
****************************************************************** CALL FOR PAPERS: ETAPS 2015 18th European Joint Conferences on Theory And Practice of Software London, UK, 11-18 April 2015 http://www.etaps.org/2015 ******************************************************************
Categories: Incoming News

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

Haskell on Reddit - Tue, 09/02/2014 - 11:13am

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]
Categories: Incoming News

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

Haskell on Reddit - Tue, 09/02/2014 - 8:52am

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]
Categories: Incoming News