Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Haskell implementation #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions haskell/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.stack-work
14 changes: 14 additions & 0 deletions haskell/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Control.Concurrent
import Text.Read (readMaybe)
import System.Environment
import Control.Monad
import Data.Maybe
import Safe
import Control.Concurrent.Async

main :: IO ()
main = do
args <- getArgs
let numRoutines = fromMaybe 100_000 (args `atMay` 0 >>= readMaybe)
forConcurrently_ [1 .. numRoutines] \_ -> threadDelay 10_000_000
print "All finished."
28 changes: 28 additions & 0 deletions haskell/coroutines.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cabal-version: 1.12

name: coroutines
version: 0.0.0
build-type: Simple

executable coroutines
main-is: Main.hs
default-extensions:
OverloadedStrings
LambdaCase
QuasiQuotes
MultiWayIf
TemplateHaskell
DataKinds
ImplicitParams
PartialTypeSignatures
DeriveAnyClass
OverloadedRecordDot
ForeignFunctionInterface
BlockArguments
DuplicateRecordFields
ImportQualifiedPost
DeriveGeneric
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
base, async, safe
default-language: GHC2021
12 changes: 12 additions & 0 deletions haskell/dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")"

ghcid \
--command="stack ghci --ghci-options='+RTS -N'" \
--test=main \
--restart coroutines.cabal \
--restart stack.yaml \
--restart stack.yaml.lock
5 changes: 5 additions & 0 deletions haskell/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -euo pipefail

exec stack run "$@"
1 change: 1 addition & 0 deletions haskell/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
resolver: nightly-2023-04-18
12 changes: 12 additions & 0 deletions haskell/stack.yaml.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages: []
snapshots:
- completed:
sha256: 54e2d92fba7e5d56a9e1c1f173be9258ffcbbf8bd7087c1848c2feafe31881e6
size: 608629
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2023/4/18.yaml
original: nightly-2023-04-18