From a26aa4918ce8e508a9847b2eb3ddae786aed44d6 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Mon, 29 Jul 2019 20:16:37 -0400 Subject: add some haskell this is a "hello world" http server that runs on 8080 --- anomic.hs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 anomic.hs (limited to 'anomic.hs') diff --git a/anomic.hs b/anomic.hs new file mode 100644 index 0000000..73d45e8 --- /dev/null +++ b/anomic.hs @@ -0,0 +1,39 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE TypeOperators #-} + +module Main where + +import Rebase.Prelude hiding (Handler) + +import Servant +import Network.Wai.Handler.Warp + +type API = HelloWorldApi + +type HelloWorldApi = "hello" :> Get '[ PlainText] String + +type HandlerS state api = ServerT api (ReaderT state (ExceptT ServantErr IO)) + +type HandlerG api = HandlerS Global api + +data Global = + Global + { + } + +api :: Proxy API +api = Proxy + +webApp :: Global -> Application +webApp global = + serve api $ hoistServer api (Handler . flip runReaderT global) server + +main :: IO () +main = run 8080 $ webApp Global + +helloWorld :: HandlerG HelloWorldApi +helloWorld = return "Hello, World!" + +server :: HandlerG API +server = helloWorld -- cgit v1.2.3