Commit 0780749b authored by Yuanle Song's avatar Yuanle Song
Browse files

init commit

will start working on try1.hs
parents
Loading
Loading
Loading
Loading

LICENSE

0 → 100644
+30 −0
Original line number Diff line number Diff line
Copyright Yuanle Song (c) 2016

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.

    * Neither the name of Yuanle Song nor the names of other
      contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 No newline at end of file

README.md

0 → 100644
+4 −0
Original line number Diff line number Diff line
recreate the program in Raymond's talk using haskell

Raymond Hettinger Keynote — Python Russia Keynote documentation
https://dl.dropboxusercontent.com/u/3967849/pyru/_build/html/index.html

Setup.hs

0 → 100644
+2 −0
Original line number Diff line number Diff line
import Distribution.Simple
main = defaultMain
+31 −0
Original line number Diff line number Diff line
name:                queue-base-threading
version:             0.1.0.0
synopsis:            Initial project template from stack
description:         Please see README.md
homepage:            https://github.com/sylecn/queue-base-threading#readme
license:             BSD3
license-file:        LICENSE
author:              Yuanle Song
maintainer:          sylecn@gmail.com
copyright:           Copyright: (c) 2016 Yuanle Song
category:            Utilities
build-type:          Simple
extra-source-files:  README.md
cabal-version:       >=1.10

executable seq
  main-is:             sequential.hs
  ghc-options:         -threaded -rtsopts -with-rtsopts=-N
  build-depends:       base
  default-language:    Haskell2010

executable try1
  main-is:             try1.hs
  ghc-options:         -threaded -rtsopts -with-rtsopts=-N
  build-depends:       base
                     , random
  default-language:    Haskell2010

source-repository head
  type:     git
  location: https://github.com/sylecn/queue-base-threading

sequential.hs

0 → 100644
+16 −0
Original line number Diff line number Diff line
import Control.Monad
import Control.Concurrent.MVar
import Text.Printf

incrementAndPrint :: MVar Integer -> IO ()
incrementAndPrint counter = do
  newCount <- modifyMVar counter (\i -> return (i + 1, i + 1))
  printf "The count is %d\n" newCount
  putStrLn "---------------"

main :: IO ()
main = do
  putStrLn "Starting up"
  counter <- newMVar 0
  replicateM_ 10 (incrementAndPrint counter)
  putStrLn "Finishing up"
Loading