Created
April 21, 2018 16:25
-
-
Save domenkozar/ec42d9efc5ccfacf42dd2eb25190ab6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env nix-shell | |
#!nix-shell -i runghc -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [servant-generic servant-client])" | |
#!nix-shell -I nixpkgs=http://nixos.org/channels/nixpkgs-unstable/nixexprs.tar.xz | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE PartialTypeSignatures #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
import Data.Aeson.Types | |
import Data.Text | |
import GHC.Generics | |
import Servant | |
import Servant.API | |
import Servant.Client | |
import Servant.Generic | |
data Site route = Site | |
{ about :: route :- | |
Capture "x" Text :> Get '[JSON] Text | |
, faq :: route :- | |
Capture "y" Int :> ToServant (SubSite AsApi) | |
} deriving Generic | |
data SubSite route = SubSite | |
{ home :: route :- | |
Get '[JSON] Text | |
, homePost :: route :- | |
"asd2" :> | |
Post '[JSON] Text | |
, bet :: route :- | |
Capture "z" Text :> | |
"asd" :> Get '[JSON] Text | |
} deriving Generic | |
type SiteAPI = ToServant (Site AsApi) | |
siteAPI :: Proxy SiteAPI | |
siteAPI = Proxy | |
type HomeC = ClientM Text | |
type HomePostC = ClientM Text | |
type BetC = Text -> ClientM Text | |
bC :: Int -> HomeC :<|> (HomePostC :<|> BetC) | |
_ :<|> bC = client siteAPI | |
main :: IO () | |
main = print "ok" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment