News for hackers. Stuff that matters.
Re:How to blink a light in 10 different programming languages by eutectic on Saturday November 07, 2015 @06:34PM (#10526687)
And in Haskell (feel free to include this):

    import Control.Concurrent (threadDelay)                                         
    import System.IO

    main :: IO ()                                                                   
    main = withFile "/sys/class/leds/beaglebone:green:usr0/brightness" AppendMode go
      where put h s = hPutStrLn h s >> threadDelay 2000000                          
            go  h   = let m = put h "0" >> put h "1" >> m in m
Re:How to blink a light in 10 different programming languages by gergoerdi on Sunday November 08, 2015 @09:44PM (#10531118)
As always, prefer prebuilt recursion scheme combinators instead of making your own. The following, using `forever`, is IMO much more readable because you don't have to mentally resolve the recursion:

  main :: IO ()
  main = withFile ledFile AppendMode $ \h -> do
      let put s = hPutStrLn h s >> threadDelay 2000000                          
      forever $ do
         put "0" 
         put "1"
    where
      ledFile = "/sys/class/leds/beaglebone:green:usr0/brightness"
Re:How to blink a light in 10 different programming languages by codygman on Sunday November 08, 2015 @02:20AM (#10527841)
Why:

    go  h = let m = put h "0" >> put h "1" >> m in m
Rather than:

    go  h = put h "0" >> put h "1"
Oh, recursion...
Re:How to blink a light in 10 different programming languages by mcconnma on Sunday November 08, 2015 @04:36AM (#10528071)
Thanks, any thoughts on why I get this?

$ ghc -o blink blink.hs [1 of 1] Compiling Main ( blink.hs, blink.o )

blink.hs:7:22: parse error on input `='

Re:How to blink a light in 10 different programming languages by eutectic on Sunday November 08, 2015 @05:15AM (#10528115)
Not sure; I copy-pasted it back from hackernews and it works fine for me.