Skip to content

Commit 1cfca98

Browse files
committed
Add skeleton main function
1 parent 07e9d50 commit 1cfca98

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

how-does-servants-type-dsl-work.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ executable server
1111
build-depends: base ^>=4.12.0.0
1212
, servant-server
1313
, time
14+
, wai
15+
, warp
1416
hs-source-dirs: src
1517
default-language: Haskell2010

src/Main.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE DeriveGeneric #-}
3+
{-# LANGUAGE TypeApplications #-}
34
{-# LANGUAGE TypeOperators #-}
45
{-# OPTIONS_GHC -Wall #-}
56

67
module Main where
78

9+
import Data.Proxy (Proxy(Proxy))
810
import Data.Time (Day)
911
import GHC.Generics (Generic)
12+
import Network.Wai (Application)
13+
import Network.Wai.Handler.Warp (run)
1014
import Servant
1115
( (:<|>)
1216
, (:>)
1317
, Capture
1418
, Get
1519
, JSON
20+
, serve
1621
)
1722

1823
data User = User
@@ -34,5 +39,8 @@ type UsersAPI =
3439
"users"
3540
:> (UsersIndex :<|> UsersShow)
3641

42+
usersApp :: Application
43+
usersApp = serve (Proxy @UsersAPI) _usersServer
44+
3745
main :: IO ()
38-
main = putStrLn "Hello, Haskell!"
46+
main = run 8080 usersApp

0 commit comments

Comments
 (0)