Skip to content
Permalink
Browse files

Define the Users API as a type

  • Loading branch information...
bradparker committed Oct 2, 2019
1 parent dcdc67c commit 0f89c4320919b3985208bf5a4e002035566a7884
Showing with 24 additions and 0 deletions.
  1. +1 −0 how-does-servants-type-dsl-work.cabal
  2. +23 −0 src/Main.hs
@@ -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
@@ -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.
You can’t perform that action at this time.