News aggregator

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

New Functional Programming Job Opportunities

haskell-cafe - Mon, 08/11/2014 - 5:00pm
Here are some functional programming job opportunities that were posted recently: Big Data Engineer / Data Scientist at Recruit IT Cheers, Sean Murphy
Categories: Offsite Discussion

Snap projects to learn from

Haskell on Reddit - Mon, 08/11/2014 - 4:05pm

Can you recommend reliable open-source Snap projects?

I have some knowledge of Haskell (mostly gained from Learn You a Haskell), and I have experience creating web apps with Django.

The idea is to see good examples of web development using Haskell that we can learn from. (The focus of my interest would be project structuring, testing and session handling.)

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

Dan Burton: Similarities: Monoid, MonadPlus, Category

Planet Haskell - Mon, 08/11/2014 - 3:41pm
This is perhaps obvious to anyone who has thoroughly studied category theory, but the similarities between Monoid, MonadPlus, and Category, have really struck me lately. I’m going to take a smidgeon of artistic license to present this train of thought. … Continue reading →
Categories: Offsite Blogs

How to write reverse of this function?

Haskell on Reddit - Mon, 08/11/2014 - 12:01pm

I made a function in Haskell that takes in a number and returns a list of integers from 1 to that number.

gen x = [1..x] gen 4 -> [1, 2, 3, 4]

As I was learning about the monads I noticed that I could bind a list into this function as it has the type of (a -> m a).

[2, 3, 6, 1, 4] >>= gen -> [1, 2, 1, 2, 3, 1, 2, 3, 4, 5, 6, 1, 1, 2, 3, 4]

Then I wanted to write a function that would reverse the (>>= gen) and i came up with this function.

revgen (x:xs) = case (null xs) of False -> case ((head xs) - x) of 1 -> 1 + revgen xs otherwise -> 0 : revgen xs True -> 1 : []

But it doesn't work, I think because of the revgen returning both numbers and lists. But I can't come up with a way to do this any other way with one function. Also the nested cases look ugly as hell but I quess they work as intented because at least it compiles.

submitted by SpacemanInBikini
[link] [10 comments]
Categories: Incoming News

Updating code to work with vinyl 0.4

haskell-cafe - Mon, 08/11/2014 - 10:43am
Hi, I'm looking for some help in helping to migrate to vinyl-0.4 from earlier version. I'll first outline how I currently have things set up and then ask a few questions. For reference the whole project is at [1]. You can just skip to questions in the end if you want to. I have a small project which goes out to a few sites, fetches some similar XML data, parses some fields and returns a data type. My original attempt was to generate a data type per site but that was very ugly: couldn't reuse functions, accessors, anything. So I then turned to vinyl and have the following solution: I have a bunch of common fields defined like this: -- file_url ∷ "file_url" ::: String file_url = Field parent_id ∷ "parent_id" ::: Maybe Integer parent_id = Field -- and so on. I'm using HXT to process the XML I get from each site so I have created many HXT arrows creating each field like this: -- parent_idA ∷ (Functor (cat XmlTree), ArrowXml cat) ⇒ cat XmlTree (PlainRec '["parent_id" ::: Maybe Integer]
Categories: Offsite Discussion

OTAS Quant 1: Position Keeping

Haskell on Reddit - Mon, 08/11/2014 - 10:09am
Categories: Incoming News

Additive/Multiplicative Inverse of Algebraic Types?

Haskell on Reddit - Mon, 08/11/2014 - 9:35am

I apologize if this is way off topic, but I've been poring over this for a while and I think this might be a good place to ask: has there been any research on 'inverse types'? Either in Haskell or in general.

I'm trying to learn more about abstract algebra and algebraic data types, and from what I can tell the types form a semiring (though if there's a more accurate/complete structure please let me know!). What I'm wondering is if it's possible to extend this semiring to a full ring, or even a field. I've heard of a Grothendieck construction for groups and suspect it is also applicable to semirings, but I haven't really investigated that area very much.

Additionally I can't seem to find any intuitive expression of the additive or multiplicative inverse of a type offhand, but I'm curious if there even is one. Additive inverses seem to make a little bit of sense perhaps in a resource consumption sort of way, but it's shaky at best. And I have no idea what the reciprocal of a type would represent either, though I did see a 'quotient type' mentioned at the end of the clowns and jokers paper.

submitted by asampson
[link] [30 comments]
Categories: Incoming News

Easy Haskell Profiling

Haskell on Reddit - Mon, 08/11/2014 - 9:19am
Categories: Incoming News

WLP/WFLP - Call for Participation - September 15-17

General haskell list - Mon, 08/11/2014 - 9:17am
Call for Participation 28th Workshop on (Constraint) Logic Programming (WLP 2014) co-located with 23rd International Workshop on Functional and (Constraint) Logic Programming (WFLP 2014) Lutherstadt Wittenberg, Germany, September 15 - 17 Early registration deadline: August 26 The international workshops on functional and logic programming aim at bringing together researchers interested in functional programming, logic programming, as well as their integration. The workshops on (constraint) logic programming serve as the scientific forum of the annual meeting of the Society of Logic Programming (GLP e.V.) and bring together researchers interested in logic programming, constraint programming, and related areas like databases, artificial intelligence, and operations research. Invited Speakers: Michael Hanus: Declarative Multi-paradigm Programming (Tutorial). Sven Thiele: Answer Set Programming for Systems Biology. Accepted Papers and Preliminary Program:
Categories: Incoming News

Type families on unboxed types

Haskell on Reddit - Mon, 08/11/2014 - 4:24am

I have:

type family Flip a where Flip (a -> b) = b -> a > :kind! Flip (Int -> Bool) Flip (Int -> Bool) :: * = Bool -> Int

but it doesn't work for unboxed values:

> Flip (Int# -> Bool) Flip (Int# -> Bool) :: * = Flip (Int# -> Bool) > import Data.Type.Equality > :t Refl :: (Flip (Int# -> Bool) :~: (Bool -> Int#)) <interactive>:1:1: Warning: Couldn't match type ‘Flip (Int# -> Bool)’ with ‘Bool -> Int#’ Expected type: Flip (Int# -> Bool) :~: (Bool -> Int#) Actual type: (Bool -> Int#) :~: (Bool -> Int#) In the expression: Refl :: Flip (Int# -> Bool) :~: (Bool -> Int#) Refl :: (Flip (Int# -> Bool) :~: (Bool -> Int#)) :: (Bool -> Int#) :~: (Bool -> Int#)

Is there any way to fix that?

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