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]
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?
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:
- I think I'm making this way more complicated than it should. How can I avoid such crazy type signatures?
- 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.
- 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)
- 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]
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:
- reads a total of three parts, two integers followed by a plus sign (+)
- each part is separated by whitespace
- on errors the machine resets and starts over
The signals (a.k.a. the output alphabet) is the following typedata CalcSignal = CalcNothing | CalcResult Int | CalcError CalcStates String deriving (Eq, Show)
The events (a.k.a. the input alphabet) is simply Char. The states aredata 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 thentype 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 functioncalculate :: 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.
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
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.
Why does the default cabal package file have a build-depends of base >= 4.7 && base < 4.8? Why not just base?
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]