diff options
author | Andrew Cady <d@jerkface.net> | 2019-07-29 20:16:37 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2019-07-29 21:04:09 -0400 |
commit | a26aa4918ce8e508a9847b2eb3ddae786aed44d6 (patch) | |
tree | a5635210d991d3d6163fd2e2bd0873db908056ed /anomic.hs | |
parent | 53386343424dcd1ebac3740e072ae87291b7bb06 (diff) |
add some haskell
this is a "hello world" http server that runs on 8080
Diffstat (limited to 'anomic.hs')
-rw-r--r-- | anomic.hs | 39 |
1 files changed, 39 insertions, 0 deletions
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 | |||
5 | module Main where | ||
6 | |||
7 | import Rebase.Prelude hiding (Handler) | ||
8 | |||
9 | import Servant | ||
10 | import Network.Wai.Handler.Warp | ||
11 | |||
12 | type API = HelloWorldApi | ||
13 | |||
14 | type HelloWorldApi = "hello" :> Get '[ PlainText] String | ||
15 | |||
16 | type HandlerS state api = ServerT api (ReaderT state (ExceptT ServantErr IO)) | ||
17 | |||
18 | type HandlerG api = HandlerS Global api | ||
19 | |||
20 | data Global = | ||
21 | Global | ||
22 | { | ||
23 | } | ||
24 | |||
25 | api :: Proxy API | ||
26 | api = Proxy | ||
27 | |||
28 | webApp :: Global -> Application | ||
29 | webApp global = | ||
30 | serve api $ hoistServer api (Handler . flip runReaderT global) server | ||
31 | |||
32 | main :: IO () | ||
33 | main = run 8080 $ webApp Global | ||
34 | |||
35 | helloWorld :: HandlerG HelloWorldApi | ||
36 | helloWorld = return "Hello, World!" | ||
37 | |||
38 | server :: HandlerG API | ||
39 | server = helloWorld | ||