News aggregator

ANNOUNCE: wxHaskell

haskell-cafe - Tue, 08/12/2014 - 5:37pm
L.S., I am happy to announce a new version of wxHaskell. This version binds to both wxWidgets 2.9 and 3.0 [0]. As wxWidgets 3.0 is significantly better, I advice everyone, who is already using wxHaskell, to upgrade to wxWidgets 3.0.1 What is it? ----------- wxHaskell[1] is a portable and native GUI library for Haskell. The goal of the project is to provide an industrial strength GUI library for Haskell, but without the burden of developing (and maintaining) one ourselves. wxHaskell is therefore built on top of wxWidgets – a comprehensive C++ library that is portable across all major GUI platforms; including GTK, Windows, X11, and MacOS X. Furthermore, it is a mature library (in development since 1992) that supports a wide range of widgets with the native look-and-feel. What's new? ----------- - Accept both wxWidgets 2.9 and 3.0, with a preference for 3.0 - Added bindings for wxGraphicsContext::CreatePath - Use the same custom hook for `cabal copy` in wxc/Setup.hs - Many updates in definition
Categories: Offsite Discussion

Neil Mitchell: Safe library - generalising functions

Planet Haskell - Tue, 08/12/2014 - 3:08pm

Summary: The Safe library now has exact versions of take/drop, with twelve functions implemented on top of a generalised splitAt.

The Safe library is a simple Haskell library that provides versions of standard Prelude and Data.List functions that usually throw errors (e.g. tail), but wrapped to provide better error messages (e.g. tailNote), default values (e.g. tailDef) and Maybe results (e.g. tailMay).

I recently released version 0.3.5, which provides a new module Safe.Exact containing crashing versions of functions such as zip/zipWith (which error if the lists are not equal length) and take/drop/splitAt (which error if there are not enough elements), then wraps them to provide safe variants. As an example, the library provides:

takeExact :: Int -> [a] -> [a]
takeExactMay :: Int -> [a] -> Maybe [a]

These are like take, but if the Int is larger than the length of the list it will throw an error or return Nothing. Some sample evaluations:

takeExactMay 2 [1,2,3] == Just [1,2]
takeExact 2 [1,2,3] == [1,2]
takeExactMay 2 [1] == Nothing
takeExact 2 [1] ==
1:error "Safe.Exact.takeExact, index too large, index=2, length=1"
take 1 (takeExact 2 [1]) == [1]

So takeExactMay computes up-front whether the whole computation will succeed, and returns a Nothing if it will fail. In contrast, takeExact produces elements while they are present, but if you demand an additional element that is missing it will result in an error. All the exceptions in the Safe library are designed to provide the maximum level of detail about what went wrong, here telling us the index we were after and the length of the list.

The library provides takeExact, dropExact and splitAtExact, plus Def/May/Note versions, resulting in twelve similar functions. While the implementation of any one function is reasonably short (although not that short, once proper error messages are provided), I didn't want to write the same code twelve times. However, generalising over functions that check up-front and those that check on-demand requires a bit of thought. In the end I settled for:

splitAtExact_ :: (String -> r) -> ([a] -> r) -> (a -> r -> r) -> Int -> [a] -> r
splitAtExact_ err nil cons o xs
| o < 0 = err $ "index must not be negative, index=" ++ show o
| otherwise = f o xs
f 0 xs = nil xs
f i (x:xs) = x `cons` f (i-1) xs
f i [] = err $
"index too large, index=" ++ show o ++ ", length=" ++ show (o-i)

Here the splitAtExact_ function has a parameterised return type r, along with three functional arguments that construct and consume the r values. The functional arguments are:

  • err :: String -> r, says how to convert an error into a result value. For up-front checks this produces a Nothing, for on-demand checks this calls error.
  • nil :: [a] -> r, says what to do once we have consumed the full number of elements. For take we discard all the remaining elements, for drop we are only interested in the remaining elements.
  • cons :: a -> r -> r, says how to deal with one element before we reach the index. For take this will be (:), but for functions producing a Maybe we have to check the r parameter first.

With this generalisation, I was able to write all twelve variants. As a few examples:

addNote fun msg = error $ "Safe.Exact." ++ fun ++ ", " ++ msg

takeExact = splitAtExact_ (addNote "takeExact") (const []) (:)

dropExact = splitAtExact_ (addNote "dropExact") id (flip const)

takeExactMay = splitAtExact_ (const Nothing) (const $ Just []) (\a -> fmap (a:))

dropExactMay = splitAtExact_ (const Nothing) Just (flip const)

splitAtExact = splitAtExact_ (addNote "splitAtExact")
(\x -> ([], x)) (\a b -> first (a:) b)

splitAtExactMay = splitAtExact_ (const Nothing)
(\x -> Just ([], x)) (\a b -> fmap (first (a:)) b)

Normally I would have defined takeExact and dropExact in terms of fst/snd on top of splitAtExact. However, in the Safe library error messages are of paramount importance, so I go to additional effort to ensure the error says takeExact and not splitAtExact.

Categories: Offsite Blogs

What are some Haskell alternatives to Pandas/Numpy?

Haskell on Reddit - Tue, 08/12/2014 - 1:22pm

Title mostly says it all. I'm doing some data work at my job, and since we're a python shop we're using mostly pandas and numpy. They're great at what they do, but I would love to be able to do at least some of the same things in Haskell. It seems like making something like a pandas DataFrame would be possible in Haskell, and be quite useful. What are the best libraries for manipulating and operating on large matrices in Haskell, with efficient implementations of high-level tasks like time series, merge/join/groupby, parsing CSV and XLS, etc?

submitted by saikyou
[link] [26 comments]
Categories: Incoming News

A question about Functors.

Haskell on Reddit - Tue, 08/12/2014 - 1:01pm

If a functor a categorical homomorphism on objectes such as Maybe, then why do we call Maybe a Functor? Shouldn't fmap be the functor and the Maybe type constructor be the Category?

Forgive me if this is a stupid question, i'm reading "learn you a haskell". Thank you.

submitted by yyttr3
[link] [13 comments]
Categories: Incoming News

Help? Noob attempting to build hdevtools on Windows for Platform 2014.

Haskell on Reddit - Tue, 08/12/2014 - 10:52am

Haskell Sublime Text integration requires hdevtools.

hdevtools won't build right on Windows (requires unix, and even with MSYS it throws an unqualified error building that -- granted I haven't yet tried cygwin) which is fixed by this fork.

That fork fails to build with the newly-release Platform 2014 because it requires process==1.1.* and process is now at, with previous versions not installed.

Attempting to install process- fails because Not in scope: 'unsafePerformIO'.

Changing the requirement on the windows hdevtools fork to process==1.2.* allows me to configure, then gives me this on build:

src\Info.hs:130:59: Not in scope: data constructor `GHC.MatchGroup' Perhaps you meant `GHC.DocGroup' (imported from GHC) src\Info.hs:164:5: Not in scope: `Pretty.showDocWith' Perhaps you meant `Pretty.showDoc' (imported from Pretty) src\Info.hs:229:12: Not in scope: type constructor or class `PprTyThing.PrintExplicitForalls'

And the combination of my knowledge and Haskell documentation accessibility do not yet stack up to the task of hacking this out. :) Any pointers?

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

transformers: remove instance MonadFix ExceptT and ErrorT

libraries list - Tue, 08/12/2014 - 10:13am
I propose to remove the MonadFix instance for the ExceptT transformer, because it gives the illusion that it can handle exceptions, which it cannot. The current implementation is: instance (MonadFix m) => MonadFix (ExceptT e m) where mfix f = ExceptT $ mfix $ \ a -> runExceptT $ f $ case a of Right x -> x Left _ -> error "mfix ExceptT: Left" You see, that it cannot handle the exception case. Whenever someone needs an mfix on ExceptT I strongly suggest that he first handles the exception, thus turning (ExceptT e m a) into plain (m a) and then calls 'mfix' only on (m a). I further propose to declare the MonadFix instance as non-implementable in a way suggested in [1]: class NoMonadFix m where instance (NoMonadFix m) => MonadFix (ExceptT e m) where mfix = error "unimplementable" where no instance of NoMonadFix exist and NoMonadFix is not exported. Whenever someone tries to call 'mfix' on 'ExceptT e m' he will get the type error, that a NoMonadFix instance on 'm' is mi
Categories: Offsite Discussion

ಠ_ಠ :: String -> a

Haskell on Reddit - Tue, 08/12/2014 - 9:51am
Categories: Incoming News

HGamer3D - version 0.4

haskell-cafe - Tue, 08/12/2014 - 7:36am
You will find version 0.4 of HGamer3D on github and hackage now. It also comes with some updated introductions on . best regards Peter (uotbw) _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

[code review] Strive: a client for the Strava API

Haskell on Reddit - Tue, 08/12/2014 - 7:24am

I've spent the last couple months tinkering on a client for Strava's API. I ended up using http-conduit for making requests, aeson for decoding JSON, and a lens-based interface for manipulating records. I'd love some feedback about the decisions I've made and the code I wrote. In particular, I'd like some feedback about:

  • Template Haskell. It cleaned up my code, but the TH code I wrote is gross. I don't yet know enough to make it better. (See issue #69 for details.)
  • Template Haskell again. Is it recommended to use something like zeroth to avoid a compile-time dependency on TH? (See issue 76 for details.)
  • Internals. Should I export stuff in the Strive.Internal module?

Thanks in advance for any input!

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

What's your opinion on "Beginning Haskell: A Project-Based Approach"?

Haskell on Reddit - Tue, 08/12/2014 - 3:57am

I've just finished chapter 11, and I don't really know whether I should continue. /u/ReinH already stated that there's something wrong with it:

[...] unfortunately I don't know of a good, modern, pragmatic guide to Haskell. Beginning Haskell: a Project Based Approach could have been that but the book is so poorly put together that I worry that one might become a worse Haskeller after reading it, which is a real shame (I suspect that a lot of this is the publisher's fault).

The book is riddled with wrong types, constraints and typos. While typos are usually OK, wrong types and constraints are a personal no-go. An example:

Functors, Applicatives, and Monads

There are some interesting things going on with the use of (<$>) in the preceding section. The signature of (<$>) is equal to that of fmap of a Functor:

(<$>) :: Applicative f => (a -> b) -> f a -> f b fmap :: Functor f => (a -> b) -> f a -> f b

At some point before that section (<$>) has type (a ->b) -> f a -> f b (missing constraint). Stuff like this prevents me from recommending the book to anyone asking about Haskell. However, it also prevents me from going on.

So how reliable are chapters 11-16 (and appendix)? Are they also riddled with wrong types and/or missing constraints? And what is your general opinion on BH:APBA?

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

strictness in Data.Map.Strict with Text

Haskell on Reddit - Tue, 08/12/2014 - 2:40am

I was watching the Udacity course on "Design of Computer Programs" and thought it would be kindof fun to redo the stuff in Haskell.

So I more or less 1:1 the python stuff there into Haskell (you can find it here: Gist )

Now to get the stats for the hand-ranks I thought it a good idea to draw 1mio. random hands and classify them using this function:

randomStats :: Int -> IO [(Text, Float)] randomStats n = percentOf . sortWith (negate . snd) . M.toList <$> drawHands n M.empty where drawHands n' m = if n' == 0 then return m else do !r <- classifyRank . head <$> randomHands defaultDeck 1 let m' = M.insertWith (+) r 1 m drawHands (n'-1) m' percentOf :: [(Text, Int)] -> [(Text, Float)] percentOf = map (\ (x,c) -> (x, 100 * fromIntegral c / fromIntegral n))

Where this is using Data.Map.Strict and Data.Text.

Now as far as I understand the strict maps they should eval the keys into WHNF - but when I remove the bang from r I can watch the program eating memory till I run out of RAM/Swap ;) ... with it it runs fine (not really quick but ok)

Can someone explain to me why? Should not insertWith do basically the same?

Thank you for your help

submitted by CKoenig
[link] [8 comments]
Categories: Incoming News

The Good, the Bad and the GUI

haskell-cafe - Mon, 08/11/2014 - 11:16pm
Dear All, Haskell is great for great many areas, let me name just two: - parsers, translators, interpreters, compilers; highly concurrent systems. Haskell is however not great for GUIs. I've been thinking a little why this is so. I think one of the reasons might be that in Haskell it is unusual to deal with data that is incomplete or otherwise erroneous. Let me try to explain, what I mean, by example. If you declare Person class in Java, you automatically get a thingy that you can readily use in UI construction, because all the fields can temporarily be null, even the required ones. In Haskell you'd need two data types: the usual proper Haskell data type, and another which wraps every field in Maybe, facilitates editing, validation, etc. Perhaps it would be possible to generate one data type from the other, or generate both from a common specification. Let me write the same thing in other words. It is not controversial to say on this list that specifying what is correct means, is a good idea.
Categories: Offsite Discussion

Differentiating Data With Q

Haskell on Reddit - Mon, 08/11/2014 - 9:44pm
Categories: Incoming News

Position available: Haskell application engineer (North America)

Haskell on Reddit - Mon, 08/11/2014 - 9:42pm

Haskell Application Engineer - Telecommute - anywhere in North America

Hi everyone. We have a new opening on the FP Complete team for a Haskell programmer with a lot of initiative and the desire to interact directly with business customers.

This job involves not only application design and coding, but also lots of communication with customers (and potential customers): to determine their broad and immediate needs, identify an initial problem that we can solve, understand their urgency, budget, and decision-making process, and develop proposals on how new and existing code can be used to solve the problem. And of course, ultimately, to design and implement the solution -- either solo or with colleagues.

This position requires a demonstrated ability to write and deliver working applications using Haskell or another modern (preferably functional) language. You must have excellent communication skills in English, and be able to talk to people and figure out what they want. We will consider applications from less advanced programmers if they have a willingness to learn and very strong customer-facing skills.

This is a near-full-time contractor position, with fairly flexible hours, intended to last long-term. You'll work mostly from home (anywhere in North America) via Internet, and may occasionally travel to meet with your users in person.

You must have a history of taking initiative, and be able to deliver on projects without lots of supervision. You must have a demonstrated ability to learn new languages, libraries, and tools, figure out and document people’s needs and requirements, and turn requirements into detailed solution designs.

If you have some understanding of quantitative financial analysis, or similar kinds of data analysis, that's a big plus. If you have experience driving successful project approvals, another big plus.

If you are a good programmer with a head for business or sales, this might be a great fit. Applicants for previous positions are also welcome to re-apply.

To apply, email me at or PM me. Include a resume or C.V., and links to cool things you have done, ideally including code projects.

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

Foldr/build fusion and reverse

libraries list - Mon, 08/11/2014 - 9:01pm
Currently, reverse does not participate at all. This law looks eminently exploitable: foldr c n (reverse xs) = foldl (flip c) n xs foldr c n $ reverse $ build xs = _______________________________________________ Libraries mailing list Libraries< at >
Categories: Offsite Discussion

Any tips on "doing it right" for a small program?

haskell-cafe - Mon, 08/11/2014 - 7:41pm
Dear reader, I'm still new to haskell, and decided to convert a simple bash script to a full-on-bells-and-whistles Haskell program (as a learning experience). As you might guess I could use some help. The program is very simple, in Bash it reads: CMDPATTERN="$< at >" while [[ "`pgrep --count --full "$CMDPATTERN"`" -gt 1 ]]; do sleep 5 done AKA: while there is a command running with the given string, loop. I called this script "after" and use it on the commandline to chain commands from different terminals. The Haskell version is available at What I have done: - Add Travis CI - Add a first test case using test-framework - Add commandline option parsing using "options" - Implement a fork-join behavior using parallel-io What I would like help with: - How to add a --version that reflects the after.cabal version? - Is there a library for what I'm doing in Process.hs (listing running processes, etc.)? - How to add "-p <pid>" support, so I can do "after -p 129 -p 402" (after bot
Categories: Offsite Discussion

Request: Pre-built VM image with GHCJS setup

Haskell on Reddit - Mon, 08/11/2014 - 7:33pm

So, as many of you know, GHCJS is pretty hard to get set up.

Clearly, some people have gotten GHCJS set up, and some will be in a VM image.

So, I'm requesting that someone share that image.

I've tried the Vagrant images, but they haven't worked for me, even the pre-built ones. They don't seem to have been updated for quite some time, and I get errors running vagrant up with them.

GHCJS would be great if it were easy, but in the meantime, I think having a good starter VM floating around would be a good solution.

That said, if someone has a good guide of how to get the vagrant images up and working, that would be great. But would much prefer a VM image I can just download and run.

submitted by jmite
[link] [14 comments]
Categories: Incoming News