A peer-to-peer stack for code collaboration
Create rad-base for findModule and the rad source code to live in
Fintan Halpennye44b5fa76e9e
diff --git a/package.yaml b/package.yamlindex 014480e..4482d5e 100644--- a/package.yaml+++ b/package.yaml@@ -37,9 +37,6 @@ ghc-options:- -Wincomplete-uni-patterns- -Wredundant-constraints-data-files:-- rad/**/*.rad-library:source-dirs: srcdependencies:diff --git a/rad-base/README.md b/rad-base/README.mdnew file mode 100644index 0000000..41d5c02--- /dev/null+++ b/rad-base/README.md@@ -0,0 +1,19 @@+# rad-base++The `rad-base` provides a home for the `radicle` prelude functionality, living under the+`rad` directory.++As well as this, there is one module `Radicle.Path` that exports `findModule`. This allows+`radicle-repl` to look up a module based on a path, using `rad` as a default.++```haskell+-- | Importing works as follows:+--+-- (1) If the RADPATH environment variable exists, search there+-- (2) Otherwise search in data-dir+-- (3) Finally we search in the current directory.+--+-- RADPATH should be a colon-separated list of directories (just like PATH).+findModule :: FilePath -> IO (Maybe FilePath)+findModule = ...+```diff --git a/rad-base/Setup.hs b/rad-base/Setup.hsnew file mode 100644index 0000000..4467109--- /dev/null+++ b/rad-base/Setup.hs@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMaindiff --git a/rad-base/package.yaml b/rad-base/package.yamlnew file mode 100644index 0000000..d86f01b--- /dev/null+++ b/rad-base/package.yaml@@ -0,0 +1,22 @@+name: rad-base+version: 0.1.0.0+github: "githubuser/rad-base"+license: BSD3+author: "Author name here"+maintainer: "[email protected]"+copyright: "2019 Author name here"++extra-source-files:+- README.md++dependencies:+- base >= 4.7 && < 5++data-files:+- rad/**/*.rad++library:+ source-dirs: src+ dependencies:+ - directory+ - filepathdiff --git a/rad-base/rad-base.cabal b/rad-base/rad-base.cabalnew file mode 100644index 0000000..db21a32--- /dev/null+++ b/rad-base/rad-base.cabal@@ -0,0 +1,82 @@+-- This file has been generated from package.yaml by hpack version 0.28.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: 07477c660d947749e9be5cd5231d92da2e1ab8a245cbc6ece7ea63a038b1044e++name: rad-base+version: 0.1.0.0+homepage: https://github.com/githubuser/rad-base#readme+bug-reports: https://github.com/githubuser/rad-base/issues+author: Author name here+maintainer: [email protected]+copyright: 2019 Author name here+license: BSD3+build-type: Simple+cabal-version: >= 1.10+extra-source-files:+ README.md+data-files:+ rad/currency.rad+ rad/examples/counter.rad+ rad/monadic/issue-remote.rad+ rad/monadic/issue.rad+ rad/monadic/issues-upgrade.rad+ rad/monadic/items.rad+ rad/monadic/names-remote.rad+ rad/monadic/names-upgrade.rad+ rad/monadic/names.rad+ rad/monadic/patch-remote.rad+ rad/monadic/patch.rad+ rad/monadic/project-remote.rad+ rad/monadic/project.rad+ rad/prelude.rad+ rad/prelude/auth.rad+ rad/prelude/basic.rad+ rad/prelude/bool.rad+ rad/prelude/cmd-parsing.rad+ rad/prelude/dict.rad+ rad/prelude/error-messages.rad+ rad/prelude/exception.rad+ rad/prelude/http.rad+ rad/prelude/io-utils.rad+ rad/prelude/io.rad+ rad/prelude/key-management.rad+ rad/prelude/lens.rad+ rad/prelude/list.rad+ rad/prelude/machine-remote.rad+ rad/prelude/machine.rad+ rad/prelude/maybe.rad+ rad/prelude/nonces.rad+ rad/prelude/patterns.rad+ rad/prelude/ref.rad+ rad/prelude/seq.rad+ rad/prelude/set.rad+ rad/prelude/state-machine.rad+ rad/prelude/strings.rad+ rad/prelude/test-eval.rad+ rad/prelude/test.rad+ rad/prelude/time.rad+ rad/prelude/track-newness.rad+ rad/prelude/util.rad+ rad/prelude/validation.rad+ rad/self-amending-store.rad+ rad/tests/stub-primitives.rad++source-repository head+ type: git+ location: https://github.com/githubuser/rad-base++library+ exposed-modules:+ Lib+ Radicle.Path+ other-modules:+ Paths_rad_base+ hs-source-dirs:+ src+ build-depends:+ base >=4.7 && <5+ , directory+ , filepath+ default-language: Haskell2010diff --git a/rad/currency.rad b/rad-base/rad/currency.radsimilarity index 100%rename from rad/currency.radrename to rad-base/rad/currency.raddiff --git a/rad/examples/counter.rad b/rad-base/rad/examples/counter.radsimilarity index 100%rename from rad/examples/counter.radrename to rad-base/rad/examples/counter.raddiff --git a/rad/monadic/issue-remote.rad b/rad-base/rad/monadic/issue-remote.radsimilarity index 100%rename from rad/monadic/issue-remote.radrename to rad-base/rad/monadic/issue-remote.raddiff --git a/rad/monadic/issue.rad b/rad-base/rad/monadic/issue.radsimilarity index 100%rename from rad/monadic/issue.radrename to rad-base/rad/monadic/issue.raddiff --git a/rad/monadic/issues-upgrade.rad b/rad-base/rad/monadic/issues-upgrade.radsimilarity index 100%rename from rad/monadic/issues-upgrade.radrename to rad-base/rad/monadic/issues-upgrade.raddiff --git a/rad/monadic/items.rad b/rad-base/rad/monadic/items.radsimilarity index 100%rename from rad/monadic/items.radrename to rad-base/rad/monadic/items.raddiff --git a/rad/monadic/names-remote.rad b/rad-base/rad/monadic/names-remote.radsimilarity index 100%rename from rad/monadic/names-remote.radrename to rad-base/rad/monadic/names-remote.raddiff --git a/rad/monadic/names-upgrade.rad b/rad-base/rad/monadic/names-upgrade.radsimilarity index 100%rename from rad/monadic/names-upgrade.radrename to rad-base/rad/monadic/names-upgrade.raddiff --git a/rad/monadic/names.rad b/rad-base/rad/monadic/names.radsimilarity index 100%rename from rad/monadic/names.radrename to rad-base/rad/monadic/names.raddiff --git a/rad/monadic/patch-remote.rad b/rad-base/rad/monadic/patch-remote.radsimilarity index 100%rename from rad/monadic/patch-remote.radrename to rad-base/rad/monadic/patch-remote.raddiff --git a/rad/monadic/patch.rad b/rad-base/rad/monadic/patch.radsimilarity index 100%rename from rad/monadic/patch.radrename to rad-base/rad/monadic/patch.raddiff --git a/rad/monadic/project-remote.rad b/rad-base/rad/monadic/project-remote.radsimilarity index 100%rename from rad/monadic/project-remote.radrename to rad-base/rad/monadic/project-remote.raddiff --git a/rad/monadic/project.rad b/rad-base/rad/monadic/project.radsimilarity index 100%rename from rad/monadic/project.radrename to rad-base/rad/monadic/project.raddiff --git a/rad/prelude.rad b/rad-base/rad/prelude.radsimilarity index 100%rename from rad/prelude.radrename to rad-base/rad/prelude.raddiff --git a/rad/prelude/auth.rad b/rad-base/rad/prelude/auth.radsimilarity index 100%rename from rad/prelude/auth.radrename to rad-base/rad/prelude/auth.raddiff --git a/rad/prelude/basic.rad b/rad-base/rad/prelude/basic.radsimilarity index 100%rename from rad/prelude/basic.radrename to rad-base/rad/prelude/basic.raddiff --git a/rad/prelude/bool.rad b/rad-base/rad/prelude/bool.radsimilarity index 100%rename from rad/prelude/bool.radrename to rad-base/rad/prelude/bool.raddiff --git a/rad/prelude/cmd-parsing.rad b/rad-base/rad/prelude/cmd-parsing.radsimilarity index 100%rename from rad/prelude/cmd-parsing.radrename to rad-base/rad/prelude/cmd-parsing.raddiff --git a/rad/prelude/dict.rad b/rad-base/rad/prelude/dict.radsimilarity index 100%rename from rad/prelude/dict.radrename to rad-base/rad/prelude/dict.raddiff --git a/rad/prelude/error-messages.rad b/rad-base/rad/prelude/error-messages.radsimilarity index 100%rename from rad/prelude/error-messages.radrename to rad-base/rad/prelude/error-messages.raddiff --git a/rad/prelude/exception.rad b/rad-base/rad/prelude/exception.radsimilarity index 100%rename from rad/prelude/exception.radrename to rad-base/rad/prelude/exception.raddiff --git a/rad/prelude/http.rad b/rad-base/rad/prelude/http.radsimilarity index 100%rename from rad/prelude/http.radrename to rad-base/rad/prelude/http.raddiff --git a/rad/prelude/io-utils.rad b/rad-base/rad/prelude/io-utils.radsimilarity index 100%rename from rad/prelude/io-utils.radrename to rad-base/rad/prelude/io-utils.raddiff --git a/rad/prelude/io.rad b/rad-base/rad/prelude/io.radsimilarity index 100%rename from rad/prelude/io.radrename to rad-base/rad/prelude/io.raddiff --git a/rad/prelude/key-management.rad b/rad-base/rad/prelude/key-management.radsimilarity index 100%rename from rad/prelude/key-management.radrename to rad-base/rad/prelude/key-management.raddiff --git a/rad/prelude/lens.rad b/rad-base/rad/prelude/lens.radsimilarity index 100%rename from rad/prelude/lens.radrename to rad-base/rad/prelude/lens.raddiff --git a/rad/prelude/list.rad b/rad-base/rad/prelude/list.radsimilarity index 100%rename from rad/prelude/list.radrename to rad-base/rad/prelude/list.raddiff --git a/rad/prelude/machine-remote.rad b/rad-base/rad/prelude/machine-remote.radsimilarity index 100%rename from rad/prelude/machine-remote.radrename to rad-base/rad/prelude/machine-remote.raddiff --git a/rad/prelude/machine.rad b/rad-base/rad/prelude/machine.radsimilarity index 100%rename from rad/prelude/machine.radrename to rad-base/rad/prelude/machine.raddiff --git a/rad/prelude/maybe.rad b/rad-base/rad/prelude/maybe.radsimilarity index 100%rename from rad/prelude/maybe.radrename to rad-base/rad/prelude/maybe.raddiff --git a/rad/prelude/nonces.rad b/rad-base/rad/prelude/nonces.radsimilarity index 100%rename from rad/prelude/nonces.radrename to rad-base/rad/prelude/nonces.raddiff --git a/rad/prelude/patterns.rad b/rad-base/rad/prelude/patterns.radsimilarity index 100%rename from rad/prelude/patterns.radrename to rad-base/rad/prelude/patterns.raddiff --git a/rad/prelude/ref.rad b/rad-base/rad/prelude/ref.radsimilarity index 100%rename from rad/prelude/ref.radrename to rad-base/rad/prelude/ref.raddiff --git a/rad/prelude/seq.rad b/rad-base/rad/prelude/seq.radsimilarity index 100%rename from rad/prelude/seq.radrename to rad-base/rad/prelude/seq.raddiff --git a/rad/prelude/set.rad b/rad-base/rad/prelude/set.radsimilarity index 100%rename from rad/prelude/set.radrename to rad-base/rad/prelude/set.raddiff --git a/rad/prelude/state-machine.rad b/rad-base/rad/prelude/state-machine.radsimilarity index 100%rename from rad/prelude/state-machine.radrename to rad-base/rad/prelude/state-machine.raddiff --git a/rad/prelude/strings.rad b/rad-base/rad/prelude/strings.radsimilarity index 100%rename from rad/prelude/strings.radrename to rad-base/rad/prelude/strings.raddiff --git a/rad/prelude/test-eval.rad b/rad-base/rad/prelude/test-eval.radsimilarity index 100%rename from rad/prelude/test-eval.radrename to rad-base/rad/prelude/test-eval.raddiff --git a/rad/prelude/test.rad b/rad-base/rad/prelude/test.radsimilarity index 100%rename from rad/prelude/test.radrename to rad-base/rad/prelude/test.raddiff --git a/rad/prelude/time.rad b/rad-base/rad/prelude/time.radsimilarity index 100%rename from rad/prelude/time.radrename to rad-base/rad/prelude/time.raddiff --git a/rad/prelude/track-newness.rad b/rad-base/rad/prelude/track-newness.radsimilarity index 100%rename from rad/prelude/track-newness.radrename to rad-base/rad/prelude/track-newness.raddiff --git a/rad/prelude/util.rad b/rad-base/rad/prelude/util.radsimilarity index 100%rename from rad/prelude/util.radrename to rad-base/rad/prelude/util.raddiff --git a/rad/prelude/validation.rad b/rad-base/rad/prelude/validation.radsimilarity index 100%rename from rad/prelude/validation.radrename to rad-base/rad/prelude/validation.raddiff --git a/rad/self-amending-store.rad b/rad-base/rad/self-amending-store.radsimilarity index 100%rename from rad/self-amending-store.radrename to rad-base/rad/self-amending-store.raddiff --git a/rad/tests/stub-primitives.rad b/rad-base/rad/tests/stub-primitives.radsimilarity index 100%rename from rad/tests/stub-primitives.radrename to rad-base/rad/tests/stub-primitives.raddiff --git a/rad-base/src/Radicle/Path.hs b/rad-base/src/Radicle/Path.hsnew file mode 100644index 0000000..40d5afb--- /dev/null+++ b/rad-base/src/Radicle/Path.hs@@ -0,0 +1,28 @@++module Radicle.Path where++import Paths_rad_base+import System.Directory (doesFileExist, setCurrentDirectory)+import System.Environment (lookupEnv)+import System.FilePath (splitSearchPath, (</>))++-- | Importing works as follows:+--+-- (1) If the RADPATH environment variable exists, search there+-- (2) Otherwise search in data-dir+-- (3) Finally we search in the current directory.+--+-- RADPATH should be a colon-separated list of directories (just like PATH).+findModule :: FilePath -> IO (Maybe FilePath)+findModule file = do+ mrp <- lookupEnv "RADPATH"+ radPathDirs <- case mrp of+ Nothing -> (\x -> [x </> "rad"]) <$> getDataDir+ Just rp -> pure $ splitSearchPath rp+ let searchPath = radPathDirs ++ ["."]+ let doFind xs = case xs of+ [] -> pure Nothing+ x:xs' -> do+ exists <- doesFileExist (x </> file)+ if exists then pure (Just $ x </> file) else doFind xs'+ doFind searchPathdiff --git a/rad/repl.rad b/rad/repl.raddeleted file mode 120000index 79599b5..0000000--- a/rad/repl.rad+++ /dev/null@@ -1 +0,0 @@-../bin/rad-repl\ No newline at end of filediff --git a/radicle-repl/package.yaml b/radicle-repl/package.yamlindex 4394e0a..46d9359 100644--- a/radicle-repl/package.yaml+++ b/radicle-repl/package.yaml@@ -17,10 +17,10 @@ library:- bytestring- containers- directory- - filepath- haskeline- prettyprinter- process+ - rad-base- text- timediff --git a/radicle-repl/radicle-repl.cabal b/radicle-repl/radicle-repl.cabalindex 5ea13c2..ec0dc8b 100644--- a/radicle-repl/radicle-repl.cabal+++ b/radicle-repl/radicle-repl.cabal@@ -2,7 +2,7 @@---- see: https://github.com/sol/hpack----- hash: ad1738df0a3c59b1b5001716397023051155fa87b886c2884ca614fa32010328+-- hash: decdff89017327ce1f45f0e49763d589d554f472327b26e9cc90b8eaca880c4ename: radicle-replversion: 0.0.1@@ -33,11 +33,11 @@ library, bytestring, containers, directory- , filepath, haskeline, prettyprinter, process, protolude+ , rad-base, radicle-lang, text, timediff --git a/radicle-repl/src/Radicle/Repl/Capabilities.hs b/radicle-repl/src/Radicle/Repl/Capabilities.hsindex b5e7713..577fdb6 100644--- a/radicle-repl/src/Radicle/Repl/Capabilities.hs+++ b/radicle-repl/src/Radicle/Repl/Capabilities.hs@@ -9,13 +9,10 @@ import Protoludeimport qualified Data.ByteString as BSimport Data.Text.Prettyprint.Doc (PageWidth)import Data.Time-import Paths_radicle_replimport System.Console.ANSI (hSupportsANSI)import System.Console.Haskeline hiding (catch)-import System.Directory (doesFileExist, setCurrentDirectory)-import System.Environment (lookupEnv)+import System.Directory (setCurrentDirectory)import System.Exit (ExitCode)-import System.FilePath (splitSearchPath, (</>))import System.IO( BufferMode(LineBuffering), hClose@@ -29,6 +26,7 @@ import System.Process(CreateProcess, ProcessHandle, createProcess, waitForProcess)import Radicle.Lang.Core+import Radicle.Pathclass (Monad m) => Stdin m wheregetLineS :: m (Maybe Text) -- gives Nothing on EOF@@ -163,24 +161,3 @@ putStrLnS t = putStrS t >> putStrS "\n"modifyEnvS :: (GetEnv m r, SetEnv m r) => (Env r -> Env r) -> m ()modifyEnvS f = getEnvS >>= setEnvS . f---- | Importing works as follows:------ (1) If the RADPATH environment variable exists, search there--- (2) Otherwise search in data-dir--- (3) Finally we search in the current directory.------ RADPATH should be a colon-separated list of directories (just like PATH).-findModule :: FilePath -> IO (Maybe FilePath)-findModule file = do- mrp <- lookupEnv "RADPATH"- radPathDirs <- case mrp of- Nothing -> (\x -> [x </> "rad"]) <$> getDataDir- Just rp -> pure $ splitSearchPath rp- let searchPath = radPathDirs ++ ["."]- let doFind xs = case xs of- [] -> pure Nothing- x:xs' -> do- exists <- doesFileExist (x </> file)- if exists then pure (Just $ x </> file) else doFind xs'- doFind searchPathdiff --git a/stack.yaml b/stack.yamlindex ed18a24..6f41eea 100644--- a/stack.yaml+++ b/stack.yaml@@ -37,6 +37,7 @@ resolver: snapshot.yaml# will not be run. This is useful for tweaking upstream packages.packages:- .+- rad-base- radicle-lang- radicle-repl