Skip to content

Commit

Permalink
Define the Users API as a type
Browse files Browse the repository at this point in the history
  • Loading branch information
bradparker committed Oct 2, 2019
1 parent dcdc67c commit 0f89c43
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions how-does-servants-type-dsl-work.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ maintainer: hi@bradparker.com
executable server
main-is: Main.hs
build-depends: base ^>=4.12.0.0
, servant-server
hs-source-dirs: src
default-language: Haskell2010
23 changes: 23 additions & 0 deletions src/Main.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wall #-}

module Main where

import Servant
( (:<|>)
, (:>)
, Capture
, Get
, JSON
)

data User = User

type UsersIndex =
Get '[JSON] [User]

type UsersShow =
Capture "username" String
:> Get '[JSON] User

type UsersAPI =
"users"
:> (UsersIndex :<|> UsersShow)

main :: IO ()
main = putStrLn "Hello, Haskell!"

0 comments on commit 0f89c43

Please sign in to comment.