A peer-to-peer stack for code collaboration
Remove GHCJS related code
Thomas Scholtes10405b4dad13
diff --git a/.weeder.yaml b/.weeder.yamlindex bd70218..534d1fa 100644--- a/.weeder.yaml+++ b/.weeder.yaml@@ -1,25 +1,5 @@- package:- name: radicle- - section:- # BEGIN ignore everything because this target is not build by- # default.- - name: exe:radicle-client-ghcjs- - message:- - name: Module not compiled- - module: GHCJS.hs- - message:- - name: Redundant build-depends entry- - depends:- - bytestring- - exceptions- - ghcjs-base- - ghcjs-dom- - http-media- - protolude- - radicle- - servant- - servant-client-ghcjs- # END- section:- name: test:spec- message:diff --git a/exe/GHCJS.hs b/exe/GHCJS.hsdeleted file mode 100644index defde04..0000000--- a/exe/GHCJS.hs+++ /dev/null@@ -1,125 +0,0 @@-{-# OPTIONS_GHC -fno-warn-deprecations #-}-module GHCJS where--import Protolude hiding (TypeError)--import API-import Control.Monad.Catch (MonadThrow)-import Data.IORef-import qualified Data.JSString as JSS-import Data.Scientific (floatingOrInteger)-import qualified Data.Text as T-import GHC.Exts (fromList)-import GHCJS.Foreign.Callback (Callback, OnBlocked(..), syncCallback1)-import GHCJS.Marshal-import GHCJS.Types-import JavaScript.Object (getProp, setProp)-import JavaScript.Object.Internal (Object(..))-import Radicle-import Radicle.Internal.PrimFns (allDocs)-import Servant.Client.Ghcjs-import Servant.Client.Internal.XhrClient (runClientMOrigin)-import System.Console.Haskeline (InputT, defaultSettings, runInputT)--main :: IO ()-main = do- bndsRef <- newIORef bindings- res <- runInputT defaultSettings- $ runLang bindings- $ interpretMany "[repl]" "(load! \"rad/prelude.rad\")"- case res of- (Left err, _) -> liftIO $ print $ renderPrettyDef err- (Right _, newBnds) -> liftIO $ writeIORef bndsRef newBnds- cb <- syncCallback1 ContinueAsync (jsEval bndsRef)- js_set_eval cb---- * FFI--foreign import javascript unsafe "eval_fn_ = $1"- js_set_eval :: Callback a -> IO ()---- * Export---- | Interop with JS is quite nasty. We take a JS object, expecting the 'arg'--- property to be set to the argument, and we set the 'result' property of it--- with the result.------ The IORef keeps the state/env of the REPL so far.-jsEval :: IORef (Bindings (PrimFns (InputT IO))) -> JSVal -> IO ()-jsEval bndsRef v = runInputT defaultSettings $ do- let o = Object v- ms <- liftIO $ fromJSVal =<< getProp "arg" o- let s = case ms of- Just s' -> s'- _ -> panic "expecting 'arg' key"- bnds <- liftIO $ readIORef bndsRef- res <- runLang bnds $ interpretMany "[repl]" s- out <- JSS.pack . T.unpack <$> case res of- (Left err, _) -> pure $ renderPrettyDef err- (Right v', newBnds) -> do- _ <- liftIO $ writeIORef bndsRef newBnds- pure $ renderPrettyDef v'- sout <- liftIO $ toJSVal out- liftIO $ setProp "result" sout o---- * Primops--bindings :: Bindings (PrimFns (InputT IO))-bindings = e { bindingsPrimFns = bindingsPrimFns e <> primops }- where- e :: Bindings (PrimFns (InputT IO))- e = replBindings--primops :: PrimFns (InputT IO)-primops = fromList $ allDocs [sendPrimop, receivePrimop]- where- sendPrimop =- ( "send!"- , "Given a URL (string) and a vector of value, sends the value `v` to the\- \ remote chain located at the URL for evaluation."- , \case- [String name, Vec v] -> do- res <- liftIO $ runClientM' name (submit $ toList v)- case res of- Left e -> throwErrorHere . OtherError- $ "send!: failed:" <> show e- Right _ -> pure $ List []- [_, _] -> throwErrorHere $ TypeError "send!: first argument should be a string"- xs -> throwErrorHere $ WrongNumberOfArgs "send!" 2 (length xs)- )- receivePrimop =- ( "receive!"- , "Given a URL (string) and a integral number `n`, queries the remote chain\- \ for the last `n` inputs that have been evaluated."- , \case- [String name, Number n] -> do- case floatingOrInteger n of- Left (_ :: Float) -> throwErrorHere . OtherError- $ "receive!: expecting int argument"- Right r -> do- liftIO (runClientM' name (since r)) >>= \case- Left err -> throwErrorHere . OtherError- $ "receive!: request failed:" <> show err- Right v' -> pure v'- [String _, _] -> throwErrorHere $ TypeError "receive!: expecting number as second arg"- [_, _] -> throwErrorHere $ TypeError "receive!: expecting string as first arg"- xs -> throwErrorHere $ WrongNumberOfArgs "receive!" 2 (length xs)- )---- * Helpers--identV :: Text -> Value-identV = Keyword . unsafeToIdent---- * Client functions--submit :: [Value] -> ClientM Value-submit = client chainSubmitEndpoint . Values--since :: Int -> ClientM Value-since = client chainSinceEndpoint--runClientM' :: (MonadThrow m, MonadIO m) => Text -> ClientM a -> m (Either ServantError a)-runClientM' baseUrl endpoint = do- url <- parseBaseUrl $ T.unpack baseUrl- liftIO $ runClientMOrigin endpoint $ ClientEnv urldiff --git a/package.yaml b/package.yamlindex 170f518..8908b15 100644--- a/package.yaml+++ b/package.yaml@@ -99,18 +99,12 @@ executables:- bytestring- directory- optparse-applicative- when:- - condition: impl(ghcjs)- buildable: falseghc-options: -main-is RadicleExeradicle-server:main: Server.hssource-dirs: exeother-modules: [Server.DB]- when:- - condition: impl(ghcjs)- buildable: falsedependencies:- radicle- aeson@@ -126,40 +120,10 @@ executables:- wai-corsghc-options: -main-is Server- radicle-client-ghcjs:- main: GHCJS.hs- source-dirs: exe- other-modules: []- dependencies:- - radicle- - ghcjs-base- - exceptions- - bytestring- - servant- - servant-client-ghcjs- - http-media- when:- - condition: impl(ghcjs)- then:- buildable: true- dependencies: ghcjs-dom- else:- buildable: false- # XXX(xla): We need to remove the debug linking as it produces output js of- # aroud 27MB.- # We force debug linking as without it we encounter a runtime exception- # in ghcjs due to the metadata initializer only supporting objects with up- # to 100- # fields: https://github.com/ghcjs/ghcjs/issues/498#issuecomment-230725647- ghc-options: -main-is GHCJS -debug-radicle-doc:main: Doc.hssource-dirs: exe/other-modules: []- when:- - condition: impl(ghcjs)- buildable: falsedependencies:- radicle- optparse-applicative@@ -171,9 +135,6 @@ executables:main: ReferenceDoc.hssource-dirs: exe/other-modules: []- when:- - condition: impl(ghcjs)- buildable: falsedependencies:- radicle- pandoc@@ -187,9 +148,6 @@ executables:main: GithubIssues.hssource-dirs: exe/other-modules: []- when:- - condition: impl(ghcjs)- buildable: falsedependencies:- radicle- containers@@ -202,9 +160,6 @@ executables:main: Benchmarks.hssource-dirs: exe/other-modules: []- when:- - condition: impl(ghcjs)- buildable: falsedependencies:- radicle- criterion@@ -214,9 +169,6 @@ executables:main: Machines.hssource-dirs: exe/other-modules: []- when:- - condition: impl(ghcjs)- buildable: falsedependencies:- radicle- uuiddiff --git a/scripts/upload-ghcjs.sh b/scripts/upload-ghcjs.shdeleted file mode 100755index 9acaea6..0000000--- a/scripts/upload-ghcjs.sh+++ /dev/null@@ -1,26 +0,0 @@-#!/bin/bash --#===============================================================================-#-# FILE: upload-ghcjs.sh-#-# USAGE: ./upload-ghcjs.sh-#-# DESCRIPTION: Build and upload radicle JS-#-# OPTIONS: ----# REQUIREMENTS: UglifyJS, gsutil-# CREATED: 08/29/2018 14:52-#===============================================================================--set -o nounset-set -o errexit--export STACK_YAML=stack-ghcjs.yaml--[[ -d out ]] || mkdir out-stack build-ORIG=$(find .stack-work/dist -name all.js)--uglifyjs $ORIG > out/all.min.js--gsutil cp out/all.min.js gs://static.radicle.xyzdiff --git a/src/Radicle/Internal/Effects/Capabilities.hs b/src/Radicle/Internal/Effects/Capabilities.hsindex 0de02bf..8d600ff 100644--- a/src/Radicle/Internal/Effects/Capabilities.hs+++ b/src/Radicle/Internal/Effects/Capabilities.hs@@ -24,10 +24,6 @@ import System.IO)import System.Process(CreateProcess, ProcessHandle, createProcess, waitForProcess)-#ifdef ghcjs_HOST_OS-import GHCJS.DOM.XMLHttpRequest- (getResponseText, newXMLHttpRequest, openSimple, send)-#endifimport Radicle.Internal.Core@@ -133,26 +129,11 @@ class (Monad m) => SetSubs m whereclass (Monad m) => ReadFile m wherereadFileS :: Text -> m (Either Text Text) -- ^ Left error or Right contents-#ifdef ghcjs_HOST_OS-instance ReadFile (InputT IO) where- readFileS = lift . requestFile- where- requestFile :: Text -> IO (Either Text Text)- requestFile filename = do- req <- newXMLHttpRequest- openSimple req ("GET" :: Text) filename- send req- resp <- getResponseText req- pure $ case resp of- Nothing -> Left "no response from server"- Just v -> Right v-#elseinstance ReadFile (InputT IO) wherereadFileS = lift . readFileSinstance ReadFile IO wherereadFileS fname = (Right . decodeUtf8With lenientDecode <$> BS.readFile (toS fname))`catch` (\(e :: IOException) -> pure (Left (show e)))-#endifinstance {-# OVERLAPPABLE #-} ReadFile m => ReadFile (Lang m) wherereadFileS = lift . readFileSdiff --git a/stack-ghcjs.yaml b/stack-ghcjs.yamldeleted file mode 100644index 483d571..0000000--- a/stack-ghcjs.yaml+++ /dev/null@@ -1,29 +0,0 @@-resolver: nightly-2018-04-21-compiler: ghcjs-0.2.1.9011009_ghc-8.4.1-compiler-check: match-exact--setup-info:- ghcjs:- source:- ghcjs-0.2.1.9011009_ghc-8.4.1:- url: https://github.com/alexanderkjeldaas/ghcjs/releases/download/fghcjs-8.4.1/ghcjs.tar.gz-packages:-- .-extra-deps:-- git: [email protected]:well-typed/cborg.git- commit: 37de2c0ae6bc7fa53f24f8d13748a7c370da9149- subdirs:- - serialise- - cborg-- git: https://github.com/ghcjs/ghcjs-base.git- commit: 01014ade3f8f5ae677df192d7c2a208bd795b96c-- git: [email protected]:haskell-servant/servant.git- commit: c3caa149551843fdd74eb5abf3251a16547161dd- subdirs:- - servant- - servant-client-ghcjs- - servant-client-core-- ghcjs-dom-0.9.2.0-- terminfo-0.4.1.2-- ghcjs-dom-jsffi-0.9.2.0-- uuid-1.3.13