2015-08-17 23:56:29 +02:00
|
|
|
{-# LANGUAGE DataKinds #-}
|
|
|
|
{-# LANGUAGE DeriveGeneric #-}
|
2015-07-22 21:22:42 +02:00
|
|
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
2015-08-17 23:56:29 +02:00
|
|
|
{-# LANGUAGE TypeOperators #-}
|
2016-09-02 04:53:04 +02:00
|
|
|
|
|
|
|
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
|
|
|
|
|
2015-08-17 23:56:29 +02:00
|
|
|
import Data.Aeson
|
|
|
|
import GHC.Generics
|
|
|
|
import Network.Wai.Handler.Warp
|
|
|
|
import Servant
|
|
|
|
import Servant.Mock
|
|
|
|
import Test.QuickCheck.Arbitrary
|
2015-07-22 21:22:42 +02:00
|
|
|
|
|
|
|
newtype User = User { username :: String }
|
|
|
|
deriving (Eq, Show, Arbitrary, Generic)
|
|
|
|
|
|
|
|
instance ToJSON User
|
|
|
|
|
|
|
|
type API = "user" :> Get '[JSON] User
|
|
|
|
|
|
|
|
api :: Proxy API
|
|
|
|
api = Proxy
|
|
|
|
|
|
|
|
main :: IO ()
|
2016-09-02 04:53:04 +02:00
|
|
|
main = run 8080 (serve api $ mock api Proxy)
|