mirror of
https://github.com/ilyakooo0/servant-reflex.git
synced 2024-09-11 07:15:29 +03:00
Reorganize testserver, update all deps to 'improved-base'
This commit is contained in:
parent
11e01e767f
commit
6e33745d1c
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -13,3 +13,6 @@
|
|||||||
[submodule "deps/reflex-dom"]
|
[submodule "deps/reflex-dom"]
|
||||||
path = deps/reflex-dom
|
path = deps/reflex-dom
|
||||||
url = https://github.com/ryantrinkle/reflex-dom
|
url = https://github.com/ryantrinkle/reflex-dom
|
||||||
|
[submodule "deps/reflex"]
|
||||||
|
path = deps/reflex
|
||||||
|
url = https://github.com/ryantrinkle/reflex
|
||||||
|
1
deps/reflex
vendored
Submodule
1
deps/reflex
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 5b5a1c8d540ea9058988d4c564e2823aa099b840
|
2
deps/reflex-dom
vendored
2
deps/reflex-dom
vendored
@ -1 +1 @@
|
|||||||
Subproject commit b3f9b5f0b477d4bb09f6a4076c902aefbe9f4eb0
|
Subproject commit 5ef54eba94f867062765dc444c5ddbd3f461de02
|
2
deps/try-reflex
vendored
2
deps/try-reflex
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 8a2b9f350d265cecdd013a8818ef32e8ed7f3114
|
Subproject commit 3b823c7e1ab7dd998c28e5d63daf4c233bbf6f18
|
@ -5,4 +5,4 @@ module API where
|
|||||||
|
|
||||||
import Servant.API
|
import Servant.API
|
||||||
|
|
||||||
type API = Get '[JSON] ()
|
type API = Get '[JSON] () :<|> Get '[JSON] Int
|
||||||
|
@ -7,7 +7,6 @@ import Servant.Reflex
|
|||||||
import API
|
import API
|
||||||
import Data.Proxy
|
import Data.Proxy
|
||||||
import Reflex.Dom
|
import Reflex.Dom
|
||||||
import Reflex.Dom.Contrib.Xhr
|
|
||||||
|
|
||||||
api :: Proxy API
|
api :: Proxy API
|
||||||
api = Proxy
|
api = Proxy
|
||||||
|
@ -31,10 +31,10 @@ cabal sandbox add-source deps/servant-snap/deps/servant/servant-lucid
|
|||||||
cabal sandbox add-source deps/servant-snap/deps/servant/servant-mock
|
cabal sandbox add-source deps/servant-snap/deps/servant/servant-mock
|
||||||
|
|
||||||
cabal sandbox add-source deps/servant-snap
|
cabal sandbox add-source deps/servant-snap
|
||||||
|
cabal sandbox add-source deps/reflex
|
||||||
cabal sandbox add-source deps/reflex-dom
|
cabal sandbox add-source deps/reflex-dom
|
||||||
cabal sandbox add-source deps/reflex-dom-contrib
|
cabal sandbox add-source deps/reflex-dom-contrib
|
||||||
|
|
||||||
cabal sandbox add-source .
|
cabal sandbox add-source .
|
||||||
|
|
||||||
cd test/front && cabal sandbox init --sandbox=../../.cabal-sandbox && cd ../..
|
cd testserver && cabal sandbox init --sandbox=../.cabal-sandbox && cd ..
|
||||||
cd test/back && cabal sandbox init --sandbox=../../.cabal-sandbox && cd ../..
|
|
||||||
|
@ -27,7 +27,7 @@ library
|
|||||||
data-default >= 0.5 && < 0.6,
|
data-default >= 0.5 && < 0.6,
|
||||||
exceptions >= 0.8 && < 0.9,
|
exceptions >= 0.8 && < 0.9,
|
||||||
ghcjs-base,
|
ghcjs-base,
|
||||||
ghcjs-dom == 0.1.*,
|
ghcjs-dom >= 0.2 && < 0.3,
|
||||||
http-api-data >= 0.2 && < 0.3,
|
http-api-data >= 0.2 && < 0.3,
|
||||||
http-media >= 0.6 && < 0.7,
|
http-media >= 0.6 && < 0.7,
|
||||||
http-types >= 0.8 && < 0.9,
|
http-types >= 0.8 && < 0.9,
|
||||||
@ -35,7 +35,6 @@ library
|
|||||||
network-uri >= 2.6 && < 2.7,
|
network-uri >= 2.6 && < 2.7,
|
||||||
reflex,
|
reflex,
|
||||||
reflex-dom,
|
reflex-dom,
|
||||||
reflex-dom-contrib,
|
|
||||||
safe,
|
safe,
|
||||||
servant >= 0.5 && < 0.6,
|
servant >= 0.5 && < 0.6,
|
||||||
string-conversions,
|
string-conversions,
|
||||||
@ -48,7 +47,7 @@ library
|
|||||||
ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2
|
ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2
|
||||||
|
|
||||||
executable example
|
executable example
|
||||||
build-depends: reflex, servant-reflex, base, servant, reflex-dom, reflex-dom-contrib
|
build-depends: reflex, servant-reflex, base, servant, reflex-dom
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
main-is: Example.hs
|
main-is: Example.hs
|
||||||
other-modules: API
|
other-modules: API
|
||||||
|
@ -26,6 +26,7 @@ module Servant.Reflex
|
|||||||
import Control.Applicative ((<$>))
|
import Control.Applicative ((<$>))
|
||||||
#endif
|
#endif
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
|
import Control.Monad.Trans (liftIO)
|
||||||
import Control.Monad.Trans.Except
|
import Control.Monad.Trans.Except
|
||||||
import Data.ByteString.Lazy (ByteString)
|
import Data.ByteString.Lazy (ByteString)
|
||||||
import Data.Default
|
import Data.Default
|
||||||
@ -43,7 +44,6 @@ import Servant.Common.Req
|
|||||||
import Reflex
|
import Reflex
|
||||||
import Reflex.Dom
|
import Reflex.Dom
|
||||||
import Web.HttpApiData
|
import Web.HttpApiData
|
||||||
import Reflex.Dom.Contrib.Xhr
|
|
||||||
import Reflex.Dom.Xhr
|
import Reflex.Dom.Xhr
|
||||||
|
|
||||||
-- * Accessing APIs as a Client
|
-- * Accessing APIs as a Client
|
||||||
@ -94,11 +94,11 @@ instance
|
|||||||
#endif
|
#endif
|
||||||
(MimeUnrender ct result) => HasReflexClient (Get (ct ': cts) result) where
|
(MimeUnrender ct result) => HasReflexClient (Get (ct ': cts) result) where
|
||||||
type Input (Get (ct ': cts) result) = ()
|
type Input (Get (ct ': cts) result) = ()
|
||||||
type Output (Get (ct' : cts) result) = result
|
type Output (Get (ct ': cts) result) = result
|
||||||
clientWithRoute Proxy req baseurl trigEvents = performAJAX requestBuilder responseParser
|
clientWithRoute Proxy req baseurl trigEvents = undefined -- performAJAX requestBuilder responseParser
|
||||||
where
|
-- where
|
||||||
requestBuilder _ = XhrRequest "GET" (showBaseUrl baseurl) def
|
-- requestBuilder _ = XhrRequest "GET" (showBaseUrl baseurl) def
|
||||||
responseParser xhrResp =
|
-- responseParser xhrResp = undefined
|
||||||
|
|
||||||
performAJAX
|
performAJAX
|
||||||
:: (MonadWidget t m)
|
:: (MonadWidget t m)
|
||||||
|
@ -1 +0,0 @@
|
|||||||
../common/API.hs
|
|
@ -1,8 +0,0 @@
|
|||||||
{-# LANGUAGE DataKinds #-}
|
|
||||||
{-# LANGUAGE TypeOperators #-}
|
|
||||||
|
|
||||||
module API where
|
|
||||||
|
|
||||||
import Servant.API
|
|
||||||
|
|
||||||
type API = Get '[JSON] () :<|> Get '[JSON] Int
|
|
@ -1 +0,0 @@
|
|||||||
../common/API.hs
|
|
@ -1,30 +0,0 @@
|
|||||||
Copyright (c) 2016, Greg Hale
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following
|
|
||||||
disclaimer in the documentation and/or other materials provided
|
|
||||||
with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of Greg Hale nor the names of other
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -1,28 +0,0 @@
|
|||||||
{-# LANGUAGE ScopedTypeVariables #-}
|
|
||||||
{-# LANGUAGE RankNTypes #-}
|
|
||||||
|
|
||||||
module Main where
|
|
||||||
|
|
||||||
import Servant.Reflex
|
|
||||||
import API
|
|
||||||
import Data.Proxy
|
|
||||||
import Reflex.Dom
|
|
||||||
import Reflex.Dom.Contrib.Xhr
|
|
||||||
|
|
||||||
api :: Proxy API
|
|
||||||
api = Proxy
|
|
||||||
|
|
||||||
url :: BaseUrl
|
|
||||||
url = BaseUrl Http "localhost" 8000 ""
|
|
||||||
|
|
||||||
main :: IO ()
|
|
||||||
main = mainWidget run
|
|
||||||
|
|
||||||
run :: forall t m. MonadWidget t m => m ()
|
|
||||||
run = do
|
|
||||||
let (getUnit :<|> get100) = client api url
|
|
||||||
b :: Event t () <- button "Get unit"
|
|
||||||
res :: Event t ((),()) <- getUnit b
|
|
||||||
c <- foldDyn (\_ (n :: Int) -> succ n) 0 res
|
|
||||||
display c
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
{ mkDerivation, base, servant, servant-reflex, stdenv }:
|
|
||||||
mkDerivation {
|
|
||||||
pname = "front";
|
|
||||||
version = "0.1.0.0";
|
|
||||||
src = ./.;
|
|
||||||
isLibrary = false;
|
|
||||||
isExecutable = true;
|
|
||||||
executableHaskellDepends = [ base servant servant-reflex ];
|
|
||||||
license = stdenv.lib.licenses.bsd3;
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
-- Initial front.cabal generated by cabal init. For further documentation,
|
|
||||||
-- see http://haskell.org/cabal/users-guide/
|
|
||||||
|
|
||||||
name: front
|
|
||||||
version: 0.1.0.0
|
|
||||||
-- synopsis:
|
|
||||||
-- description:
|
|
||||||
license: BSD3
|
|
||||||
license-file: LICENSE
|
|
||||||
author: Greg Hale
|
|
||||||
maintainer: imalsogreg@gmail.com
|
|
||||||
-- copyright:
|
|
||||||
-- category:
|
|
||||||
build-type: Simple
|
|
||||||
-- extra-source-files:
|
|
||||||
cabal-version: >=1.10
|
|
||||||
|
|
||||||
executable front
|
|
||||||
main-is: Main.hs
|
|
||||||
other-modules: API
|
|
||||||
other-extensions: ScopedTypeVariables, RankNTypes
|
|
||||||
build-depends: base >=4.8 && <4.9, servant, servant-reflex
|
|
||||||
-- hs-source-dirs:
|
|
||||||
default-language: Haskell2010
|
|
1
testserver/API.hs
Symbolic link
1
testserver/API.hs
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../exec/API.hs
|
Loading…
Reference in New Issue
Block a user