News aggregator

HAL-10 (preliminary announcement)

haskell-cafe - Sat, 08/22/2015 - 12:12pm
Dear all, I have been busy with many other things, so there are no concrete plans right now. But I think we should do it, and I am willing to host it at my institution. So - how about December 4/5 (Friday noon - Saturday noon)? (it is easier to get lecture rooms on the week-end) If you have comments or suggestions for HAL this year, then please email me, or stammtisch at , or someone could set up a wiki page somewhere. Let's say we start collecting opinions now, and make a decision and a formal announcement end of September. - Johannes Waldmann.
Categories: Offsite Discussion

"Growable" as an abstract container for enumerations?

Haskell on Reddit - Sat, 08/22/2015 - 11:17am

The Enum class gives us enumFrom, enumFromTo, succ, etc. My issue with these is their restriction to lists as their result:

enumFrom :: Enum a => a -> [a]

I'm wondering if there could be different behavior for different data types - generating a tree, for instance, might add multiple nodes on each layer, fanning out, instead of a singleton tree like lists.

I'm imagining something like the following class:

class Growable f where another :: a -> f a -> f a

And to revise Enum to fit:

enumFrom :: (Enum a, Growable f) => a -> f a

Do you think there is any value to this idea? If not, why? I think it would be great to have generic enumerations, but counter examples are always welcome!

submitted by Spewface
[link] [2 comments]
Categories: Incoming News

Joachim Breitner: Quickest path to a local apt repository

Planet Haskell - Sat, 08/22/2015 - 7:48am

As I’m writing this, DebConf 15 is coming to an end. I spend most of my time improving the situation of the Haskell Packages in Debian, by improving the tooling and upgrading our packages to match Stackage 3.0 and build against GHC 7.10. But that is mostly of special interest (see this mail for a partial summary), so I’d like to use this post to advertise a very small and simple package I just uploaded to Debian:

During one of the discussion here I noticed that it is rather tricky to make a locally built package available to apt-get. The latest version in unstable allows one to install a debian package simply by running apt-get install on it, but in some cases, e.g. when you want a convenient way to list all packages that you made available for local use, this is insufficient.

So the usual approach is to create a local apt repository with your packages. Which is non-trivial: You can use dpkg-scanpackage, apt-ftparchive or reprepro. You need to create the directories, run the commands, add the repository to your local sources. You need to worry about signing it or setting the right options to make apt-get accept it without signing.

It is precisely this work that my new package local-apt-repository automates for you: Once it is installed, you simply drop the .deb file into /srv/local-apt-repository/ and after the next apt-get update the package can be installed like any other package from the archive.

I chose to use the advanced features that systemd provides – namely activation upon path changes – so works best with systemd as the init system.

If you want to contribute, or test it before it passes the NEW queue, check out the git repository.

Categories: Offsite Blogs

Trying to learn the state monad -- critique please?

Haskell on Reddit - Fri, 08/21/2015 - 10:48pm

A bit of background: I've been working with Scala for a few years now, and I've decided to try to "make the leap" to Haskell -- I'm going through LYAHFGG, but I'm suplementing it by trying to reimplement some toy scala programs I've written. I've been working with the State Monad, and I've come up with a solution that works, but there are bits that feel redundant, and I'd really appreciate some guidance.

This particular example is a partial solution to the codeeval "Query Board" problem. In short, you manipulate a 256x256 matrix of integers by setting a row or column to a single value, or query the sum of a given row/column via a simple DSL. Here's what I have thus far:

{-# LANGUAGE FlexibleContexts #-} import Prelude hiding (length, replicate) import Control.Monad.State.Lazy import Data.Sequence --The Board type Board = Seq (Seq Int) --Result is a Sequence of the results of getCol and getRow type Result = Seq Int --Is the below necessary? Compilation fails if I try to use State Board Result, but succeeds with State BoardState Result type BoardState = (Board, Result) --I added the below function at the suggestion of HLint fin :: MonadState (t, Seq a) m => Seq a -> a -> t -> m (Seq a) fin result r board = do let nr = result |> r put (board, nr) return nr --getRow/Col leaves the board unaltered and appends the sum to the result getRow :: Int -> State BoardState Result getRow i = do (board, result) <- get let r = sum (index board i) fin result r board getCol :: Int -> State BoardState Result getCol j = do (board, result) <- get let r = sum (fmap (`index` j) board) fin result r board --setRow/Col replaces a row or column with the specified value, and leaves the result unaltered setRow :: Int -> Int -> State BoardState Result setRow i x = do (board, result) <- get let newRow = replicate (length $ board `index` i) x let newBoard = update i newRow board put (newBoard, result) return result setCol :: Int -> Int -> State BoardState Result setCol j x = do (board, result) <- get let newBoard = fmap (update j x) board put (newBoard, result) return result

With this, I can setup a chain of operations:

t3 = do setCol 32 20 setRow 15 7 setRow 16 31 getCol 32 setCol 2 14 getRow 10 setCol 14 0 getRow 15 setRow 10 1 getCol 2

and get a correct result with:

board = replicate 256 (replicate 256 0) print (evalState t3 (board, empty))

I feel like I'm missing something, in that when I implemented this in scala, I could do StateMonad[Board, Result] whereas I've not been able to get the Haskell version to compile without State (Board, Result) Result I end up putting the same value in two different places in each of my functions, and it seems like there should be a more elegant way to accomplish this.

submitted by ffxtian
[link] [4 comments]
Categories: Incoming News

Why do type definitions use the confusing -> syntax?

Haskell on Reddit - Fri, 08/21/2015 - 9:00pm

I'm learning Haskell, and I find this pretty confusing because -> seems to have two different meanings. (1) separating argument types, and (2) designating the return type:

f :: Int -> Int -> Int

Coming at this de novo, it looks to be saying "a function which takes an Int and returns a function which takes an Int and returns an int." I.e., as if it's a shorthand for this:

f :: Int -> (f :: Int -> Int)

But that's not the case, of course. Is there some reason or logic for this that can help me understand these statements? Because, for clarity's sake, in my opinion, the two different meanings should have two different representations. E.g.,

f :: Int, Int -> Int

Currently, my way of parsing these is, "Look for the last type in the list ... that's the return type. All the others are argument types."

EDIT: So! It looks the Haskell syntax really does mean what it says. I probably got confused by some tutorials which tried to simplify things.

submitted by caninestrychnine
[link] [20 comments]
Categories: Incoming News

Darcs Hacking Sprint #9 (September 18th-20th, Paris)

haskell-cafe - Fri, 08/21/2015 - 7:58pm
Dear Hackers the next Darcs Sprint that will be in Paris, on September 18-20 at IRILL (near Place d'Italie). Please check out the details at: Here are three things to know 1. Everybody is welcome to join us. We'd love to have you, whatever your Haskell or Darcs hacking experience. Also, if you've got a wacky idea for the future of version control, or a cool use for the Darcs library, you should join us too :-) 2. Please let us know if you're attending. Just add your name to and you're good to go. You can also send us an email. 3. We can reimburse travel costs (within reason!). Let us know if you'd like a reimbursement, and save your receipts. Many thanks to everybody who participated in our fundraising drives or who gave money on the side. Thanks also to the Software Freedom Conservancy for making fundraising and reimbursements so painless! If you can't join us in person, but you'd like to cheer
Categories: Offsite Discussion

Haskell Weekly News

haskell-cafe - Fri, 08/21/2015 - 6:40pm
*Top picks:* - Gabriel Gonzalez evaluates Haskell <> in the style of a State-of-the-Union address. He rates Haskell from Immature to Mature to Best-in-class under 28 headings, the first four being *Compilers,* *Server-side web programming,* *Scripting / Command-line applications,* and *Numerical programming.* He also recommends libraries and tutorials under each heading. Reverberations on Hacker News <> and /r/haskell <> . - Challenged over claims of FP productivity improvement, Douglas M. Auclair rattles off success stories from his previous work <> at various subsidiaries of the US Federal Gov fending for the taxpayer to the tune of billions of dollars. Nibbles of interest on Hacker New
Categories: Offsite Discussion

What exactly is going on here? [example function]

Haskell on Reddit - Fri, 08/21/2015 - 6:07pm

Learning Haskell is pretty mind blowing at times. I'm trying to really understand this example, found in

stripChars :: String -> String -> String stripChars = filter . flip notElem

Testing in GHCI:

stripChars "aei" "She was a soul stripper. She took my heart!"

"Sh ws soul strppr. Sh took my hrt!"

notElem returns a function that will return True or False whether the element is in the list? This is then passed to flip, which returns another function (with its arguments flipped) to filter?

submitted by joeblessyou
[link] [6 comments]
Categories: Incoming News

What is the reflection package for?

Haskell on Reddit - Fri, 08/21/2015 - 3:00pm

Reading the first few answers on this post on r/haskell I came across the reflection package.

I've read through and understood the first half of /u/aseipp 's reflection tutorial, and understand the Magic and unsafeCoerce trickery.

What I still don't understand is what reflection is for. The only real-world example given is this:

reify 6 (\p -> reflect p + reflect p)

I do not understand what this is for; I would have just written

(\p -> p + p) 6

How does reflection provide anything useful above just standard argument passing?

The original paper has a blurb about the motivation, describing the "configuration problem", but it just makes it sound like reflection is a complex replacement for ReaderT.

Can someone help me out in understanding this package?

submitted by NiftyIon
[link] [24 comments]
Categories: Incoming News