News aggregator Committee Financial Statement 2014

haskell-cafe - Mon, 03/09/2015 - 12:05am
Dear Haskellers,  The Committee [1] manages funds for and oversees infrastructure.   The funds available to generally come from two sources: 1) Mentor payments from the Google Summer of Code program. 2) Since the end of 2013, occasional donations [2] from the Haskell community at large. Our funds are held by Software in the Public Interest, a 501(c)3 US non-profit, through which we also accept donations. In return for its services, SPI receives 5% of donations to  According to our charter, "Each year, the committee will post a statement of the assets, and the transactions for that year.” We apologize for having been delinquent in this regard.  Included in this message is a brief statement of assets over the period 31 December 2013 - 31 December 2014, as well as an approximate breakdown of expenses. The statements we receive from the SPI are not in the most usable format [3], and we hope to provide more accurate ac
Categories: Offsite Discussion

For my final project for a functional languages class, I decided to write Conway's Game of Life in Haskell.

Haskell on Reddit - Mon, 03/09/2015 - 12:01am

The results are actually really cool:

But besides that, the reason I'm posting here (other then to brag a little :p) is to ask some of you haskell masters to have a quick glance through my code and to give me advice/suggestions on how I can improve in the future.

submitted by ultra_sabreman
[link] [19 comments]
Categories: Incoming News

How to abstract away set representation

haskell-cafe - Sun, 03/08/2015 - 9:52pm
Hello all, I was trying to construct a data type "Profile" which allows some set-like behavior. I started with functions to count, add and filter profiles. type Count = Int data Prof a = P { pCount :: Count, pFilter :: (a -> Bool) -> Prof a, pAdd :: (Prof a) -> (Prof a) } | NoProfile When I tried to actually implement a Profile, the first two functions were easy: exProfile :: [Int] -> Prof Int exProfile xs = P { pCount = length xs, pFilter = \p -> exProfile [x | x<-xs, p x], } But I didn't know how to implement pAdd. I was tempted to write something like pAdd = exProfile (xs ++ ys) But I wouldn't know where to take the ys from. I also hesitate to declare a toList function (which would solve the problem) in Prof. I would only do this *because* it is handy in exProfile, not because it is an intrinsic feature of Prof. What would be a good way to work with set-like behavior without being tied to one particular imple
Categories: Offsite Discussion

Add MonadError () Maybe

libraries list - Sun, 03/08/2015 - 7:29pm
With Maybe being isomorphic to Either (), can we have the instance MonadError () Maybe? I'm interested in the MonadError class, and write generic code against it, and would like it to work with Maybe.
Categories: Offsite Discussion

Is there a name for this?

haskell-cafe - Sun, 03/08/2015 - 5:11pm
Given a class Foo: does the record type Foo' where the fields of the record Foo' are just implementations of the functions of Foo have any special name? In some sense it's a canonical instance of Foo; we could trivially write a universal function. I ran across this pattern and wondered whether it was useful enough to have received a name.  It vaguely resembles a typeclass dictionary or a vtable in an OOP language. --Eric _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

My first Haskell project - Am I on the right track?

Haskell on Reddit - Sun, 03/08/2015 - 4:15pm

Hi -
I recently made my first Haskell project, a simple console game of Mastermind. It works alright, but I'm sure it's fairly ugly by Haskell standards. I'm not sure if this is the right subreddit for this, but I'd appreciate any feedback on how to improve the code and style.

Link to the project

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

Ian Ross: Constraint kinds and associated types

Planet Haskell - Sun, 03/08/2015 - 12:32pm
Constraint kinds and associated types March 8, 2015

This is going to be the oldest of old hat for the cool Haskell kids who invent existential higher-kinded polymorphic whatsits before breakfast, but it amused me, and it’s the first time I’ve used some of these more interesting language extensions for something “real”.


I have a Haskell library called hnetcdf for reading and writing NetCDF files. NetCDF is a format for gridded data that’s very widely used in climate science, meteorology and oceanography. A NetCDF file contains a number of gridded data sets, along with associated information describing the coordinate axes for the data. For example, in a climate application, you might have air temperature or humidity on a latitude/longitude/height grid.

So far, so simple. There are C and Fortran libraries for reading and writing NetCDF files and the interfaces are pretty straightforward. Writing a basic Haskell binding for this stuff isn’t very complicated, but one thing is a little tricky, which is the choice of Haskell type to represent the gridded data.

In Haskell, we have a number of different array abstractions that are in common use – you can think of flattening your array data into a vector, using a Repa array, using a hmatrix matrix, or a number of other possibilities. I wanted to support a sort of “store polymorphism” over these different options, so you’d be able to use the same approach to read data directly into a Repa array or a hmatrix matrix.

NcStore: first try

To do this, I wrote an NcStore class, whose first version looked something like this:

class NcStore s where toForeignPtr :: Storable e => s e -> ForeignPtr e fromForeignPtr :: Storable e => ForeignPtr e -> [Int] -> s e smap :: (Storable a, Storable b) => (a -> b) -> s a -> s b

It’s basically just a way of getting data in and out of a “store”, in the form of a foreign pointer that can be used to pass data to the NetCDF C functions, plus a mapping method. This thing can’t be a functor because of the Storable constraints on the types to be stored (which we need so that we can pass these things to C functions).

That works fine for vectors from Data.Vector.Storable:

instance NcStore Vector where toForeignPtr = fst . unsafeToForeignPtr0 fromForeignPtr p s = unsafeFromForeignPtr0 p (Prelude.product s) smap = map

and for Repa foreign arrays:

import Data.Array.Repa import qualified Data.Array.Repa as R import qualified Data.Array.Repa.Repr.ForeignPtr as RF import Data.Array.Repa.Repr.ForeignPtr (F) instance Shape sh => NcStore (Array F sh) where toForeignPtr = RF.toForeignPtr fromForeignPtr p s = RF.fromForeignPtr (shapeOfList $ reverse s) p smap f s = computeS $ f s Additional element type constraints

However, there’s a problem if we try to write an instance of NcStore for hmatrix matrices. Most hmatrix functions require that the values stored in a hmatrix matrix are instances of the hmatrix Element class. While it’s completely trivial to make types instances of this class (you just write instance Element Blah and you’re good), you still need to propagate the Element constraint through your code. In particular, I needed to use the hmatrix flatten function to turn a matrix into a vector of values in row-major order for passing to the NetCDF C API. The flatten function has type signature

flatten :: Element t => Matrix t -> Vector t

so that Element constraint somehow has to get into NcStore, but only for cases when the “store” is a hmatrix matrix.

Constraint kinds to the rescue

At this point, all the real Haskell programmers are asking what the big deal is. You just switch on the ConstraintKinds and TypeFamilies extensions and rewrite NcStore like this:

class NcStore s where type NcStoreExtraCon s a :: Constraint type NcStoreExtraCon s a = () toForeignPtr :: (Storable e, NcStoreExtraCon s e) => s e -> ForeignPtr e fromForeignPtr :: (Storable e, NcStoreExtraCon s e) => ForeignPtr e -> [Int] -> s e smap :: (Storable a, Storable b, NcStoreExtraCon s a, NcStoreExtraCon s b) => (a -> b) -> s a -> s b

Here, I’ve added an associated type called NcStoreExtraCon s a, which is a constraint, I’ve given a default for this (of (), which is a “do nothing” empty constraint), and I’ve added the relevant constraint to each of the methods of NcStore. The NcStore instances for storable Vectors and Repa arrays look the same as before, but the instance for hmatrix matrices now looks like this:

instance NcStore HMatrix where type NcStoreExtraCon HMatrix a = C.Element a toForeignPtr (HMatrix m) = fst3 $ unsafeToForeignPtr $ C.flatten m fromForeignPtr p s = let c = last s d = product s in HMatrix $ matrixFromVector RowMajor (d `div` c) (last s) $ unsafeFromForeignPtr p 0 (Prelude.product s) smap f (HMatrix m) = HMatrix $ C.mapMatrix f m

I’ve just added the Element constraint on the type of values contained in the “store” to the instance, and I can then use any hmatrix function that requires this constraint without any trouble: you can see the use of flatten in the toForeignPtr method definition.


The problem I had here is really just an instance of what’s come to be called the “restricted monad” problem. This is where you have a type class, possibly with constraints, and you want to write instances of the class where you impose additional constraints. The classic case is making Set a monad: Set requires its elements to be members of Ord, but Monad is fully polymorphic, and so there’s no way to make an instance of something like Ord a => Monad (Set a).

There’s even a package on Hackage called rmonad that uses just this “constraint kinds + associated types” approach to allow you to write “restricted monads” of this kind. So this appears to be a well-known method, but it was fun to rediscover it. The ability to combine these two language extensions in this (to me) quite unexpected way is really rather satisfying!

haskell <script src="" type="text/javascript"></script> <script type="text/javascript"> (function () { var articleId = fyre.conv.load.makeArticleId(null); fyre.conv.load({}, [{ el: 'livefyre-comments', network: "", siteId: "290329", articleId: articleId, signed: false, collectionMeta: { articleId: articleId, url: fyre.conv.load.makeCollectionUrl(), } }], function() {}); }()); </script>
Categories: Offsite Blogs

Philip Wadler: Multiple inheritance

Planet Haskell - Sun, 03/08/2015 - 10:42am
Retweeted by Don Syme.
Categories: Offsite Blogs

raspberrypi and ghci

haskell-cafe - Sun, 03/08/2015 - 8:24am
Hello, I have a B++ pi. I did a "apt-get install haskell-platform. No " ghci"!. So I did a google on this issue. Circa 2013 ghci seemed to be an issue with raspberrypi/arm. What is the current status of "ghci" on the pi/arm??. Vasili _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

Missing instances for Eq1 (Const a), Ord1 (Const a), Show1 (Const a), Ord1 (Const a)

libraries list - Sat, 03/07/2015 - 9:39pm
I was looking at switching a chunk of my code over from prelude-extras to transformers 0.5, but the classes in are currently missing instances for Control.Applicative.Const. =/ -Edward _______________________________________________ Libraries mailing list Libraries< at >
Categories: Offsite Discussion

[Announce] New release of SBV is out

haskell-cafe - Sat, 03/07/2015 - 8:18pm
A new release of SBV is out (v4.1): The main change in this release is the connection to Berkeley's ABC <> system, which is an industrial strength synthesis and verification system. SBV can now generate proof goals that are discharged by ABC, using state-of-the-art SAT based techniques. ABC is especially extremely well-tuned for dealing with problems in the bit-vector theory, and is heavily used in the hardware industry as a backend verification tool. Also included in this release is better support for IEEE-floats, and a reworked implementation of the connection to the Boolector <> solver. Thanks to Adam Foltzer of Galois for contributing the connection to ABC, and Alan Mischenko from Berkeley to add the necessary infrastructure to ABC to allow for this bridge to be built. Full release notes: SBV web page:
Categories: Offsite Discussion

Any Haskell-OpenGL tutorial including shader compilation, buffer usage and so on?

Haskell on Reddit - Sat, 03/07/2015 - 7:23pm

Does anyone who has already worked with Haskell's OpenGL library know if there is a tutorial including shader compilation, uploading buffers and so on? If not, what is your approach to using OpenGL's lib? What documentation are you using, and how do you link its information to the lib (the high-level wrapper, not the raw bindings).


submitted by SrPeixinho
[link] [28 comments]
Categories: Incoming News

ghc -O2 out of memory

haskell-cafe - Sat, 03/07/2015 - 5:56pm
I've written a program that reads a Excel file, parses the contents and generates a haskell module. Every cell in the xls has it's own function in the module. This worked fine. Now I have a bigger xls. The resulting module Xls.hs contains 30000 lines haskell code (without comment). I created a testprogram test.hs that calculates and prints one cell. I did ghc --make test.hs and everything works fine. The generated execuatable is very slow. I did ghc --make -O2 test.hs. The compilations takes 15 minutes and aborts with 'ghc: out of memory'. I'am working on Win 7 64 bits , ghc version = 7.8.3. What can I do to fix this? I do need -O2. I found with smaller xls's that optimization speeds up the executable dramatically. Before I start experimenting, does it help to split up the xls .hs in seperate files? I.e. the cells that refer to other cells and cells that don't refer to other cells. Or will I still get 'out of memory' because the optimization is global? Kees ______________________________
Categories: Offsite Discussion

-staticlib flag for building standalone static libraries producing very large libraries

glasgow-user - Sat, 03/07/2015 - 1:18pm
Hi all, Can anyone explain the following problem I'm having? I'm currently writing a game in Haskell. When I produce a plain old executable (for local testing) it's about 23M. However, when I create a static lib using the -staticlib flag it is 54M. Why the discrepancy? Sean _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users< at >
Categories: Offsite Discussion

New release of SBV (v4.1)

Haskell on Reddit - Sat, 03/07/2015 - 12:25pm
Categories: Incoming News