summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2019-07-29 20:16:37 -0400
committerAndrew Cady <d@jerkface.net>2019-07-29 21:04:09 -0400
commita26aa4918ce8e508a9847b2eb3ddae786aed44d6 (patch)
treea5635210d991d3d6163fd2e2bd0873db908056ed
parent53386343424dcd1ebac3740e072ae87291b7bb06 (diff)
add some haskell
this is a "hello world" http server that runs on 8080
-rw-r--r--.gitignore3
-rw-r--r--Makefile3
-rw-r--r--anomic.hs39
-rw-r--r--package.yaml40
-rw-r--r--stack.yaml4
-rw-r--r--test/Spec.hs2
6 files changed, 90 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index f8288ba..bd901e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
1anomic.service 1anomic.service
2.stack-work/
3anomic.cabal
4*~ \ No newline at end of file
diff --git a/Makefile b/Makefile
index 0846157..a2133a4 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,8 @@ install:
18reload: $(SERVICE_FILE) 18reload: $(SERVICE_FILE)
19 systemctl --user daemon-reload 19 systemctl --user daemon-reload
20 systemctl --user enable $(SERVICE_NAME) || true 20 systemctl --user enable $(SERVICE_NAME) || true
21 systemctl --user reload $(SERVICE_NAME) 21 systemctl --user restart $(SERVICE_NAME)
22 systemctl --user status $(SERVICE_NAME)
22 23
23$(SERVICE_FILE): $(SERVICE_NAME).service 24$(SERVICE_FILE): $(SERVICE_NAME).service
24 install -T -m0644 $^ $@ 25 install -T -m0644 $^ $@
diff --git a/anomic.hs b/anomic.hs
new file mode 100644
index 0000000..73d45e8
--- /dev/null
+++ b/anomic.hs
@@ -0,0 +1,39 @@
1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE NoImplicitPrelude #-}
3{-# LANGUAGE TypeOperators #-}
4
5module Main where
6
7import Rebase.Prelude hiding (Handler)
8
9import Servant
10import Network.Wai.Handler.Warp
11
12type API = HelloWorldApi
13
14type HelloWorldApi = "hello" :> Get '[ PlainText] String
15
16type HandlerS state api = ServerT api (ReaderT state (ExceptT ServantErr IO))
17
18type HandlerG api = HandlerS Global api
19
20data Global =
21 Global
22 {
23 }
24
25api :: Proxy API
26api = Proxy
27
28webApp :: Global -> Application
29webApp global =
30 serve api $ hoistServer api (Handler . flip runReaderT global) server
31
32main :: IO ()
33main = run 8080 $ webApp Global
34
35helloWorld :: HandlerG HelloWorldApi
36helloWorld = return "Hello, World!"
37
38server :: HandlerG API
39server = helloWorld
diff --git a/package.yaml b/package.yaml
new file mode 100644
index 0000000..002ad71
--- /dev/null
+++ b/package.yaml
@@ -0,0 +1,40 @@
1name: anomic
2version: 0.1.0.0
3github: "afcady/anomic"
4author: "Andrew Cady"
5maintainer: "d@jerkface.net"
6copyright: "AllRightsReserved"
7description: A game of Nomic
8
9dependencies:
10- base >= 4.7 && < 5
11- rebase
12- servant-server
13
14ghc-options: -W -Wall -O2
15
16library:
17 source-dirs: src
18
19executables:
20 anomic:
21 main: anomic.hs
22 source-dirs: .
23 ghc-options:
24 - -threaded
25 - -rtsopts
26 - -with-rtsopts=-N
27 dependencies:
28 - anomic
29 - warp
30
31tests:
32 anomic-test:
33 main: Spec.hs
34 source-dirs: test
35 ghc-options:
36 - -threaded
37 - -rtsopts
38 - -with-rtsopts=-N
39 dependencies:
40 - anomic
diff --git a/stack.yaml b/stack.yaml
index e69de29..5c179cc 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -0,0 +1,4 @@
1resolver: lts-13.30
2packages:
3- .
4extra-deps:
diff --git a/test/Spec.hs b/test/Spec.hs
new file mode 100644
index 0000000..cd4753f
--- /dev/null
+++ b/test/Spec.hs
@@ -0,0 +1,2 @@
1main :: IO ()
2main = putStrLn "Test suite not yet implemented"