News aggregator

Mutation analysis for Haskell (alpha)

Haskell on Reddit - Tue, 01/06/2015 - 11:33am

Here is our MuCheck library which implements mutation analysis for Haskell.

Mutation analysis is used to evaluate quality of test suites. It does this by introducing small defects in the program, and verifying whether the test suite is able to detect the introduced defect.

A companion package is DMuCheck which allows you to parallelize the analysis either in multiple processes or across different machines using cloud-haskell.

The mutation analysis still needs to be done per function, and I still haven't implemented filtering out non-covered mutants. But it should be usable otherwise. It currently implements adapters for QuickCheck, SmallCheck, HUnit and Hspec

Any comments on better structuring it and improving it are appreciated.

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

Should I hold my hopes for TypeDirectedNameResolution?

Haskell on Reddit - Tue, 01/06/2015 - 10:23am

Today I learned about Type directed name resolution.

It basically let you define functions with the same name but different first argument type:

data X = ... data Y = ... null :: X -> Bool null :: Y -> Bool

which one could argue to be some kind of "explicit type classes but not really type classes".

You can see its benefits especially for container classes like Map and Set and lists, that share a lot of common member functions.

And also introduces the obj.fn notation so that any functions of type:

fn :: Type -> Rest

can be called as on any object obj of type Type as:


So give something like:

data Location = Location { address :: Address , city :: City } data Person = Person { location :: Person , ... }

, given person of type Person you could have:

let city = address = person.location.address

That proposal is part of the let's fix records problem (to which there are other proposals I have yet to take a look at).

How was that discussion (started 3 years ago AFAIK) ended? Where could I find an implementation of such an extension? How likely it is that we get to solve this problem in future versions of Haskell?

Thanks for the attention.

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

GHC 7.10.0-rc1 build for Mac OS X

Haskell on Reddit - Tue, 01/06/2015 - 8:46am

I made a Mac OS X build of GHC 7.10.0 RC1. It was suggested that I post it here, so here you go. You can download it here, and install it as usual (./configure --prefix=<prefix> && make install). Let me know in the comments if you run into any issues.

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

Making a Blog with Yesod

Haskell on Reddit - Tue, 01/06/2015 - 8:39am
Categories: Incoming News

Philip Wadler: A contrary view to 'Antidotes to the Imitation Game'

Planet Haskell - Tue, 01/06/2015 - 8:02am
For five years, Barry Cooper has run the Alan Turing Year (ATY) mailing list, tracking worldwide activity related to the Turing Centennial and after. If you want a contrast to the view given by Antidotes to The Imitation Game, see Barry's most recent ATY post.

While I agree that fiction can sometimes can closer to truth than nonfiction, I disagree with Barry's claim that the 'higher-order' interpretation of the film accurately captures the arc of Turing's life. I suspect the real Turing differs hugely from the film's version, despite the effort and skill Tyldum, Cumberbatch, and others invested in the film.

Many computing scientists are disappointed by the divergence from history in The Imitation Game, while others think that if it does well at the Academy Awards that the popularisation of Turing will be good for our profession. There is something to be said for both points.

Hollywood's attempts at biography seems to inevitably involve gross oversimplification or distortion. Is this really necessary for a film to succeed? Does anyone have favourite examples of films that did not grossly distort their subject matter?

Categories: Offsite Blogs

I think I don't "get" netwire 5.0 types...

Haskell on Reddit - Tue, 01/06/2015 - 5:59am

Hello! I'm tying to learn the basics of FRP using netwire. However, I don't "get" what the Session type means (or what it should be). Consider the following example:

-- Let's start with the most simple wire I can imagine oneIfLessThanTen :: SimpleWire Int Int oneIfLessThanTen = mkPure_ $ \a -> if a < 10 then Right (a + 1) else Left () twoIfLessThanTwenty :: SimpleWire Int Int twoIfLessThanTwenty = mkPure_ $ \a -> if a < 20 then Right (a + 2) else Left () compositeWire :: SimpleWire Int Int compositeWire = oneIfLessThanTen <|> twoIfLessThanTwenty

So far, so good. Now, let's create a funcion to loop in the wire until it inhibits and print the value on the screen:

-- AFAIK, i need a wire, a session and the initial value. -- Since I dont know/care about the session let's just call it 's' loopWire :: SimpleWire Int Int -> s -> Int -> IO () loopWire wire session value = do (step, newSession) <- stepSession session (result, newWire) <- stepWire wire step (Right value) case result of Left _ -> putStrLn "Signal inhibited." Right v -> do putStrLn ("Value: " ++ show v) loopWire newWire newSession v

Unsurprisingly, the code doesn't compile (Couldn't match type "Identity" with "IO"). Looks like my simple wires aren't that simple anymore. My first idea was to change from SimpleWire Int Int to Wire s e m Int Int, but this time the compiler borked (Couldn't match type "e" with "()" and Couldn't match type "m" with "IO"), which made me turn my wires into Wire s () IO Int Int.

However, this was not enough (Couldn't match expected type "s" with actual type "Session IO s"). Since I couldn't even imagine what exactly the session type should be, I cheated and copied the definition from SimpleWire. This is the end result (and it's working):

oneIfLessThanTen :: Wire (Timed NominalDiffTime ()) () IO Int Int oneIfLessThanTen = ... twoIfLessThanTwenty :: Wire (Timed NominalDiffTime ()) () IO Int Int twoIfLessThanTwenty = ... compositeWire :: Wire (Timed NominalDiffTime ()) () IO Int Int compositeWire = oneIfLessThanTen <|> twoIfLessThanTwenty loopWire :: Wire (Timed NominalDiffTime ()) () IO Int Int -> Session IO (Timed NominalDiffTime ()) -> Int -> IO () loopWire wire session value = ... main :: IO () main = loopWire compositeWire clockSession_ 0

Now, I have to ask:

  1. I think I'm making this way more complicated than it should. How can I avoid such crazy type signatures?
  2. In the type Wire s e m a b, how I'm supposed to "guess" the type of s? The e, m, a and b are pretty clear to me, but I can't get what the type of s should be.
  3. This is probably related to the above questions, but I couldn't run testWire or testWireM at all (the types never matched - I'm probably lost in the function signature)
  4. Both SimpleWire and WireP looks quite limited (because of Identity). Am I missing something here?

EDIT: Syntax error when typing the code.

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

Magnus Therning: Adder as a state machine

Planet Haskell - Mon, 01/05/2015 - 6:00pm

In my previous post I wrote about a, probably rather naïve, approach to constructing state machines in Haskell. I ended it with a saying that the pattern matching of Haskell makes it rather simple to manually write the step function required to create a working state machines. Hopefully this post can convince you I’m right.

The vehicle I’ve chosen is a very simple machine capable of reading two integers and adding them. In slightly more detail it’s a machine that:

  1. reads a total of three parts, two integers followed by a plus sign (+)
  2. each part is separated by whitespace
  3. on errors the machine resets and starts over

The signals (a.k.a. the output alphabet) is the following type

data CalcSignal = CalcNothing | CalcResult Int | CalcError CalcStates String deriving (Eq, Show)

The events (a.k.a. the input alphabet) is simply Char. The states are

data CalcStates = Start | ReadFirst Int | ReadSecond Int Int | ReadOperator Int Int deriving (Eq, Show)

where the names hopefully are self explanatory. The type of the machine is then

type CalcMachine = Machine CalcStates Char CalcSignal

The machine itself can then be written like this:

calcMachine :: CalcMachine calcMachine = createMachine Start go where go Start e | isNumber e = (ReadFirst (read [e]), CalcNothing) | otherwise = (Start, CalcError Start "No number") go s@(ReadFirst i) e | isNumber e = (ReadFirst (10 * i + read [e]), CalcNothing) | isSpace e = (ReadSecond i 0, CalcNothing) | otherwise = (Start, CalcError s "Bad format") go s@(ReadSecond l i) e | isNumber e = (ReadSecond l (10 * i + read [e]), CalcNothing) | isSpace e = (ReadOperator l i, CalcNothing) | otherwise = (Start, CalcError s "Bad format") go s@(ReadOperator i j) e | e == '+' = (Start, CalcResult (i + j)) | isSpace e = (s, CalcNothing) | otherwise = (Start, CalcError s "Bad operator")

That’s rather simple and easy to read I find. Though I’m not sure it scales too well to much larger machines. I’ve not really used any DSLs to create large machines either, so I don’t know how well any method scales ;)

To do a bit of exploratory testing it’s handy to create the following function

calculate :: String -> IO () calculate = foldM_ go calcMachine where go mach c = do let (m, s) = stepMachine mach c print s return m

Using that function it’s easy to check if the machine works as intended.

> calculate "56 67 +" CalcNothing CalcNothing CalcNothing CalcNothing CalcNothing CalcNothing CalcResult 123

So far so good. What about the behaviour on errors?

> calculate "5a6 67 +" CalcNothing CalcError (ReadFirst 5) "Bad format" CalcNothing CalcNothing CalcNothing CalcNothing CalcNothing CalcResult 73

That looks good enough to me. Though there is (at least) one detail of how the machine works that might be surprising and hence should be fixed, but I’ll leave that as an exercise for the reader ;)

As I mentioned in the previous post I’ve been using this method for writing state machines to implement two different protocols. For the IO I used conduit which means I had to turn the state machine into a conduit. I’ll write about that in a later post though.

Categories: Offsite Blogs

FP Complete: A New Release for the New Year: Announcing Release 3.2

Planet Haskell - Mon, 01/05/2015 - 6:00pm
A New Release for the New Year

We recently released version 3.2 of FP Haskell Center. We want to take this opportunity to list some of the new features and highlight the additions of a Hosted Haddocks button and the ability to set up personal RSS feeds within each account.

3.2 Features List
  • Support for downloading extra packages from arbitrary.tar and .gz urls (available from the “extra packages” tab of the settings page)
  • Auto-insert functionality works for error messages (used to only work for warnings)
  • Toggle executable bit in UI. You can now make data files executable inside the IDE.
  • Updated hlint version for better functionality
  • Hosted Haddock button
  • Per-user RSS feed /user-feed/username to access
More about the features we think you’ll be the most interested inHosted Haddock Button

Often times when you’re working on a codebase, it’s convenient to generate the Haddocks to get an idea of what’s going on. It’s also useful to be able to share those generated Haddocks with others. FP Haskell Center now allows you to do both with a single click. Inside the deployment menu, you can now generated Haddocks for your current project. Links to dependencies will be created correctly, and the generated URL is fully shareable with others.

Per-user RSS Feed

Users now have the ability to set up personal RSS Feeds within their accounts. This answers a request from some users to be able to more easily let people stay up-to-date with their content. This ties in nicely with our previous addition of Disqus comments.

Feedback is always appreciated

We are proud of every improvement we make to FP Haskell Center and look forward to your feedback. With each release we are continuing to raise the quality of our product.

Categories: Offsite Blogs

Why does the default cabal package file have a build-depends of base >= 4.7 && base < 4.8? Why not just base?

Haskell on Reddit - Mon, 01/05/2015 - 4:22pm

It occurs to me that a project should always use the latest base package. So why limit it to 4.7.x?

submitted by stasiana
[link] [12 comments]
Categories: Incoming News

Functional Jobs: Senior Software Engineer at McGraw-Hill Education (Full-time)

Planet Haskell - Mon, 01/05/2015 - 8:15am

This Senior Software Engineer position is with the new LearnSmart team at McGraw-Hill Education's new and growing Research & Development center in Boston's Innovation District.

We make software that helps college students study smarter, earn better grades, and retain more knowledge.

The LearnSmart adaptive engine powers the products in our LearnSmart Advantage suite — LearnSmart, SmartBook, LearnSmart Achieve, LearnSmart Prep, and LearnSmart Labs. These products provide a personalized learning path that continuously adapts course content based on a student’s current knowledge and confidence level.

On our team, you'll get to:

  • Move textbooks and learning into the digital era
  • Create software used by millions of students
  • Advance the state of the art in adaptive learning technology
  • Make a real difference in education

Our team's products are built with Flow, a functional language in the ML family. Flow lets us write code once and deliver it to students on multiple platforms and device types. Other languages in our development ecosystem include especially JavaScript, but also C++, SWF (Flash), and Haxe.

If you're interested in functional languages like Scala, Swift, Erlang, Clojure, F#, Lisp, Haskell, and OCaml, then you'll enjoy learning Flow. We don't require that you have previous experience with functional programming, only enthusiasm for learning it. But if you have do some experience with functional languages, so much the better! (On-the-job experience is best, but coursework, personal projects, and open-source contributions count too.)

We require only that you:

  • Have a solid grasp of CS fundamentals (languages, algorithms, and data structures)
  • Be comfortable moving between multiple programming languages
  • Be comfortable with modern software practices: version control (Git), test-driven development, continuous integration, Agile

Get information on how to apply for this position.

Categories: Offsite Blogs