News aggregator

Simplifying functions

Haskell on Reddit - Sun, 04/19/2015 - 2:55pm

We can simplify this function: product ys = foldl (\ acc x -> x*acc ) 1 ys into this one: product' = foldl1 (*)

But supposing we just had product = foldl1 (*), could we know how to expand it, or could it be expanded to any number of legitimate functions?

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

LPNMR 2015 Invitation to submit - 11 days to the deadline

General haskell list - Sun, 04/19/2015 - 1:34pm
Dear Colleagues, We warmly encourage you to consider LPNMR 2015 for work that you might have that you're looking to publish shortly. Our submission deadline is a few less than two weeks from now (Apr 30th). We remind you that two best general appeal papers from LPNMR are expected to be selected for fast publication in Artificial Intelligence, and two best papers in the logic programming area will be selected for fast track publication in TPLP. Also, for those lucky enough to have papers accepted to IJCAI-15, we will consider submissions for just oral presentation. For those not so lucky that have papers rejected from IJCAI-15, there is a comfortable time window after the notification to revise your paper and submit it to us for oral presentation and inclusion in the Springer LNCS proceedings. we look forward for your submissions! Best regards, the LPNMR 2015 PC Chairs
Categories: Incoming News

Why does the Functor signature not include a lift function?

Haskell on Reddit - Sun, 04/19/2015 - 12:31pm

In category theory, a functor is a transformation on a category which preserves composition. Because categories have both objects and morphisms, each functor has to be defined based on his action on both.

Haskell functors only have fmap, which represents the action of the functor on morphisms. Why no lift?

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

Wiring package for making ReaderT and friends much more usable.

Haskell on Reddit - Sun, 04/19/2015 - 11:20am

In this package:

There is support for transforming instances of ReaderT/WriterT/RWST so that it's easier to build components using those types and pull them together to build larger components and services within an application.

For example with a couple of methods like this:

userLookup :: Int -> ReaderT (Resource1, Database1) IO User ordersLookup :: Int -> ReaderT (Database2, Resource1) IO [String]

It's possible to pull them together like this:

composedLookup :: Int -> ReaderT (Resource1, Database1, Database2) IO String composedLookup userId = do user <- wire $ userLookup userId orders <- wire $ ordersLookup userId return $ describeOrders user orders submitted by seantparsons
[link] [6 comments]
Categories: Incoming News

Any connection or overlap between the utility of lazy evaluation and program slicing?

Haskell on Reddit - Sun, 04/19/2015 - 10:47am

Program slicing

Program slicing is a program transformation technique that slices away needless parts of a program, by trying to only keep around the parts of the program that are relevant relative to a slicing criterion. The background of the technique is from imperative programming, where the standard example is a procedure that calculates both the sum of the numbers 1 to n and the factorial of n and prints these numbers. Then you can slice the program on two criterion: printing the sum, or the factorial. The program slicer will eliminate all statements that are useless for each respective purpose, like deleting all statements that have to do with the factorial if all you are after is the sum.

In FP, it seems that the equivalent to slicing away statements is to slice away sub-expressions. As far as I know, one of the upsides of lazy evaluation is that the code becomes more modular in a composability-sense - like the fact that minimum = head . sort has a complexity of just O(n). So this advantage seems similar to program slicing - effectively optimize a program by just opting out of doing certain steps. Of course even if they achieve a similar goal, they are very different - one is a program transformation technique, the other is an evaluation strategy. But can, for example, program slicing be applied to a strict language in order to get some of the same benefits with regards to modularity and composability of code that you would get in a non-strict language?

I have tried to search around for this, but I haven't found anyone who bring up these two concepts together. Which makes me suspect that I have misinterpreted the utility of program slicing.

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

Apache Kafka Protocol in Haskell

Haskell on Reddit - Sun, 04/19/2015 - 8:11am

We are currently working on a package which provides an Apache Kafka implementation in Haskell. This includes: types, parsing and serialising for the given APIs. On top of this, a client library is provided which can be used to build consumer and producer clients.

As for now, we have Produce and Fetch APIs working. There is also a producer and consumer console-client they already use the protocol package and are fully compatible with Apache Kafka! Consumer: Producer:

But why here on reddit? Well, as a matter of fact, we are haskell beginners and since this is part of our bachelors thesis and meanwhile also our favourite project, we hope to find some feedback and best case some code reviews of more advanced haskell devs :) But any thoughts are (be it code or project related or none at all) are welcome!

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

Haskell for Android

Haskell on Reddit - Sun, 04/19/2015 - 7:51am

Has anybody tried developing for Android in Haskell? How was it? Which library was it? How about the performance and the size of the apk?

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

Haskell for Hens : Arduino vs Raspberry Pi

Haskell on Reddit - Sun, 04/19/2015 - 2:46am

We've just got some chickens and my girlfriend asked me if I could find a solution to open and close the door of the chicken house automatically (when the sun rise/set). That seems the perfect opportunity for a little Arduino/Raspberry Pi project.

I don't know anything about them, but from what I've seen, the Arduino seems more adapted for that kind of project. However, I would prefer to program it in Haskell (to double the fun) but from what I've read it's not possible (yet) to compile Haskell to Arduino where it seems possible with Raspberry Pi.

Has anybody experience with using Haskell with them ?

submitted by maxigit
[link] [25 comments]
Categories: Incoming News

does anyone know what awelon is?

Haskell on Reddit - Sun, 04/19/2015 - 12:55am

After reading, it's clear to me that this blog has a lot of good ideas.

But after reading several posts, and Mr. or Mrs. dmbarbour's repository, I really have no idea what "the next step" is, WRT global shared mutable state and stuff. like any libraries that expose this model of programming in Haskell. Or a post with more concrete examples.

The author seems to be working on awelon (written in Haskell), a programming... Language? Environment?

I may be misunderstanding, but something like: "the global store is memcached or the file system or whatever, here are some primitives and combinators for accessing different parts of the global store, don't define functions the normal way but instead do it in this special way to minimize local state" or maybe "here is this new type, it's like a Reader or a State, and you want every function you define to have it as its return type, but somehow it's not a huge pain because of this novel contribution". etc.

anyways, if anyone has any insight, that would be appreciated.

submitted by sambocyn
[link] [7 comments]
Categories: Incoming News

What Haskell web framework do you use and why?

Haskell on Reddit - Sat, 04/18/2015 - 5:43pm

I'd quite like to learn how to make Haskell powered websites and I'm having trouble deciding which framework to use. Thanks in advance

submitted by destructaball
[link] [91 comments]
Categories: Incoming News

How to stay compatible with older ghc?

Haskell on Reddit - Sat, 04/18/2015 - 5:37pm

My current approach for backwards compatibility with older ghc/base versions is to have a custom prelude, that contains some CPP and other nastiness, for example: I was wondering if there's a cleaner solution...

submitted by sinelaw
[link] [9 comments]
Categories: Incoming News

dependency issues on a new install of haskell-platform 2014.2.0.0 64bit on OSX

haskell-cafe - Sat, 04/18/2015 - 5:58am
so I keep seeing failures in some modules, but if i install them by hand things get resolved. How do i get cabal to do this for me? so the dependencies: criterion -> monad-par- -> parallel- which fails but installing parallel- unravels the broken dependency chain. Below is the output: cabal: Error: some packages failed to install: criterion- depends on monad-par- which failed to install. monad-par- failed during the building phase. The exception was: ExitFailure 1 statistics- depends on monad-par- which failed to install. anatolys-MacBook:rbm anatolyy$ cabal install monad-par Resolving dependencies... Configuring monad-par- Building monad-par- Failed to install monad-par- Last 10 lines of the build log ( /Users/anatolyy/.cabal/logs/monad-par- ): Building monad-par- Preprocessing library monad-par- <command line>: cannot satisfy -package-id parallel-
Categories: Offsite Discussion

all for Contributions - Haskell Communities and Activities Report, May 2015 edition (28th edition)

General haskell list - Sat, 04/18/2015 - 3:04am
Dear all, We would like to collect contributions for the 28th edition of the ============================================================ Haskell Communities & Activities Report Submission deadline: 17 May 2015 (please send your contributions to hcar at, in plain text or LaTeX format) ============================================================ This is the short story (one extra point to the story added from previous editions): * If you are working on any project that is in some way related to Haskell, please write a short entry and submit it. Even if the project is very small or unfinished or you think it is not important enough --- please reconsider and submit an entry anyway! * If you are interested in an existing project related to Haskell that has not previously been mentioned in the HCAR, please tell us, so that we can contact the project leaders
Categories: Incoming News

Typeclasses and exception safety

Haskell on Reddit - Fri, 04/17/2015 - 9:57pm

Almost a year into Haskell as a hobbyist I have two general thoughts that I think are related and I wanted to get some opinions on them.

Having now written it out, this seems a bit rant like and it's kind of long. The TL;DR is: (1) we don't seem to have a generalized typeclass for some things, e.g. no MonadMaybe, and (2) when it comes to IO I can compile code that will crash at runtime due to an exception, when even Java won't let that happen. Finally (3) is my understanding correct / is there some way of addressing this?

Generalized typeclasses

I recently noticed that there are two general "types" of Monads (with a whole bunch of exceptions and variations). The first is SomeMonad a that is specifically about the a. A Tree a, Maybe a, [a], ST s a etc. While the second is a Monad to which the a can often be superfluous, Reader r (), State s (), Writer w () etc. With some that skirt the line (IO, Iter, Rand). I'm sure there's some formal Category theoretic way of saying that.

For the most part when using one of the second type, they tend to be implemented in terms of a Typeclass e.g. MonadReader or MonadState. This makes using them in a transformer stack very easy without having to worry about littering the code with lifts.

With FTP we seem to have done that with Collections. But we don't really do it with anything else. Suppose you have a Transformer stack MaybeT m a, and inside of that stack you use Data.Map.lookup which returns Maybe a, then you would have to run MaybeT . return over it to get it into MaybeT.

I figured that with EitherT I could use MonadThrow with return and throwM as a generalizer. I discovered however that at some point I'd need to catch the exception with catch ea (\e -> left e). Which left me wondering why there isn't a generalized typeclass for the likes of Either and Maybe. And secondly, why the compiler wasn't telling me that an exception hadn't been caught.

Exception Safety

One of the great things about Java was how it forced exception handling. If you call a method that throws an exception, you either have to handle it or your method has to throw the same exception. Which means that somewhere along the call stack you must handle it.

To me one of Java's biggest downfalls is that this isn't more rigid. Lookup functions for example don't tended not to throw a NullPointerException and use of Optional certainly wasn't very wide spread. But because exceptions either had to be handled or bubbled their way up the call stack, when they were present you could always choose when you wanted to address them.

I realised today that Haskell doesn't necessarily handle this very well when it comes to IO. I am able to compile a program that will crash on an exception.

I was looking at the async package today. The first thing I noticed was the more specialized type signature async :: IO a -> IO (Async a) instead of a generalized async :: MonadIO m => m a -> m (Asnyc a). Then I noticed that the type signature waitCatch :: Async a -> IO (Either SomeException a) which also forces specialization of the error handling to Either. But even if I use waitCatch is there some asynchronous exception that might be thrown in the parent? Can I get any guarantees from the type signature?

More to the point, I can compile my program using just wait and not handle any exceptions downstream at all. If I make a Map with known values the compiler won't let me get away with not handling null pointer exceptions (or pretending they don't exist with fromJust). But the compiler is perfectly happy to let me make a request to an external server that may timeout, give a bad response, or cause some other exception.

How to address it?

Is there some way the compiler can tell me when a process will crash at runtime because an exception hasn't been handled? Obviously I don't want my code littered with try/catch/finally blocks. But even that might be better than deferring the issue to runtime.

Hopefully not too much of a rant. Almost a year into Haskell now and this is the first time this occurred to me. Perhaps I just have some misunderstanding that could be addressed.

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