News aggregator

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

New gtk2hs 0.12.4 release

gtk2hs - Wed, 11/21/2012 - 12:56pm

Thanks to John Lato and Duncan Coutts for the latest bugfix release! The latest packages should be buildable on GHC 7.6, and the cairo package should behave a bit nicer in ghci on Windows. Thanks to all!

~d

Categories: Incoming News