diff --git a/.gitmodules b/.gitmodules index 045d0ba..90a700d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "deps/reflex-dom"] path = deps/reflex-dom url = https://github.com/ryantrinkle/reflex-dom +[submodule "deps/reflex"] + path = deps/reflex + url = https://github.com/ryantrinkle/reflex diff --git a/deps/reflex b/deps/reflex new file mode 160000 index 0000000..5b5a1c8 --- /dev/null +++ b/deps/reflex @@ -0,0 +1 @@ +Subproject commit 5b5a1c8d540ea9058988d4c564e2823aa099b840 diff --git a/deps/reflex-dom b/deps/reflex-dom index b3f9b5f..5ef54eb 160000 --- a/deps/reflex-dom +++ b/deps/reflex-dom @@ -1 +1 @@ -Subproject commit b3f9b5f0b477d4bb09f6a4076c902aefbe9f4eb0 +Subproject commit 5ef54eba94f867062765dc444c5ddbd3f461de02 diff --git a/deps/try-reflex b/deps/try-reflex index 8a2b9f3..3b823c7 160000 --- a/deps/try-reflex +++ b/deps/try-reflex @@ -1 +1 @@ -Subproject commit 8a2b9f350d265cecdd013a8818ef32e8ed7f3114 +Subproject commit 3b823c7e1ab7dd998c28e5d63daf4c233bbf6f18 diff --git a/exec/API.hs b/exec/API.hs index 45458f7..a0024af 100644 --- a/exec/API.hs +++ b/exec/API.hs @@ -5,4 +5,4 @@ module API where import Servant.API -type API = Get '[JSON] () +type API = Get '[JSON] () :<|> Get '[JSON] Int diff --git a/exec/Example.hs b/exec/Example.hs index 5993b5e..a521458 100644 --- a/exec/Example.hs +++ b/exec/Example.hs @@ -7,7 +7,6 @@ import Servant.Reflex import API import Data.Proxy import Reflex.Dom -import Reflex.Dom.Contrib.Xhr api :: Proxy API api = Proxy diff --git a/init-sandbox.sh b/init-sandbox.sh index cacb55a..ac8762a 100755 --- a/init-sandbox.sh +++ b/init-sandbox.sh @@ -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 +cabal sandbox add-source deps/reflex cabal sandbox add-source deps/reflex-dom cabal sandbox add-source deps/reflex-dom-contrib cabal sandbox add-source . -cd test/front && cabal sandbox init --sandbox=../../.cabal-sandbox && cd ../.. -cd test/back && cabal sandbox init --sandbox=../../.cabal-sandbox && cd ../.. +cd testserver && cabal sandbox init --sandbox=../.cabal-sandbox && cd .. diff --git a/servant-reflex.cabal b/servant-reflex.cabal index 1158a9f..9943eec 100644 --- a/servant-reflex.cabal +++ b/servant-reflex.cabal @@ -27,7 +27,7 @@ library data-default >= 0.5 && < 0.6, exceptions >= 0.8 && < 0.9, ghcjs-base, - ghcjs-dom == 0.1.*, + ghcjs-dom >= 0.2 && < 0.3, http-api-data >= 0.2 && < 0.3, http-media >= 0.6 && < 0.7, http-types >= 0.8 && < 0.9, @@ -35,7 +35,6 @@ library network-uri >= 2.6 && < 2.7, reflex, reflex-dom, - reflex-dom-contrib, safe, servant >= 0.5 && < 0.6, string-conversions, @@ -48,7 +47,7 @@ library ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 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 main-is: Example.hs other-modules: API diff --git a/src/Servant/Reflex.hs b/src/Servant/Reflex.hs index bbfd684..164daad 100644 --- a/src/Servant/Reflex.hs +++ b/src/Servant/Reflex.hs @@ -26,6 +26,7 @@ module Servant.Reflex import Control.Applicative ((<$>)) #endif import Control.Monad +import Control.Monad.Trans (liftIO) import Control.Monad.Trans.Except import Data.ByteString.Lazy (ByteString) import Data.Default @@ -43,7 +44,6 @@ import Servant.Common.Req import Reflex import Reflex.Dom import Web.HttpApiData -import Reflex.Dom.Contrib.Xhr import Reflex.Dom.Xhr -- * Accessing APIs as a Client @@ -94,11 +94,11 @@ instance #endif (MimeUnrender ct result) => HasReflexClient (Get (ct ': cts) result) where type Input (Get (ct ': cts) result) = () - type Output (Get (ct' : cts) result) = result - clientWithRoute Proxy req baseurl trigEvents = performAJAX requestBuilder responseParser - where - requestBuilder _ = XhrRequest "GET" (showBaseUrl baseurl) def - responseParser xhrResp = + type Output (Get (ct ': cts) result) = result + clientWithRoute Proxy req baseurl trigEvents = undefined -- performAJAX requestBuilder responseParser +-- where +-- requestBuilder _ = XhrRequest "GET" (showBaseUrl baseurl) def +-- responseParser xhrResp = undefined performAJAX :: (MonadWidget t m) diff --git a/test/back/API.hs b/test/back/API.hs deleted file mode 120000 index a415845..0000000 --- a/test/back/API.hs +++ /dev/null @@ -1 +0,0 @@ -../common/API.hs \ No newline at end of file diff --git a/test/common/API.hs b/test/common/API.hs deleted file mode 100644 index a0024af..0000000 --- a/test/common/API.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE TypeOperators #-} - -module API where - -import Servant.API - -type API = Get '[JSON] () :<|> Get '[JSON] Int diff --git a/test/front/API.hs b/test/front/API.hs deleted file mode 120000 index a415845..0000000 --- a/test/front/API.hs +++ /dev/null @@ -1 +0,0 @@ -../common/API.hs \ No newline at end of file diff --git a/test/front/LICENSE b/test/front/LICENSE deleted file mode 100644 index 790f041..0000000 --- a/test/front/LICENSE +++ /dev/null @@ -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. diff --git a/test/front/Main.hs b/test/front/Main.hs deleted file mode 100644 index 2b415ee..0000000 --- a/test/front/Main.hs +++ /dev/null @@ -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 - diff --git a/test/front/default.nix b/test/front/default.nix deleted file mode 100644 index 63e88b9..0000000 --- a/test/front/default.nix +++ /dev/null @@ -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; -} diff --git a/test/front/front.cabal b/test/front/front.cabal deleted file mode 100644 index 0f52d4d..0000000 --- a/test/front/front.cabal +++ /dev/null @@ -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 diff --git a/testserver/API.hs b/testserver/API.hs new file mode 120000 index 0000000..738c313 --- /dev/null +++ b/testserver/API.hs @@ -0,0 +1 @@ +../exec/API.hs \ No newline at end of file diff --git a/test/back/LICENSE b/testserver/LICENSE similarity index 100% rename from test/back/LICENSE rename to testserver/LICENSE diff --git a/test/back/Main.hs b/testserver/Main.hs similarity index 100% rename from test/back/Main.hs rename to testserver/Main.hs diff --git a/test/back/back.cabal b/testserver/back.cabal similarity index 100% rename from test/back/back.cabal rename to testserver/back.cabal