A peer-to-peer stack for code collaboration
Use a custom prelude (#47)
James Haydonc229a92c8fa1
diff --git a/package.yaml b/package.yamlindex a66ee5b..d7e1ecc 100644--- a/package.yaml+++ b/package.yaml@@ -10,18 +10,16 @@ extra-source-files:dependencies:- base >=4 && <5+- protolude- containers- deriving-compat- haskeline- megaparsec-- mmorph- mtl- prettyprinter- prettyprinter-ansi-terminal- recursion-schemes- scientific-- STMonadTrans-- syb- textdata-files:@@ -73,6 +71,7 @@ executables:ghc-options: -Wall -threaded -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraintsdefault-extensions:+- NoImplicitPrelude- AutoDeriveTypeable- ConstraintKinds- DeriveDataTypeablediff --git a/repl/Main.hs b/repl/Main.hsindex bab77f5..4b984d7 100644--- a/repl/Main.hs+++ b/repl/Main.hs@@ -1,7 +1,7 @@module Main (main) where-import Data.Semigroup ((<>))-import qualified Data.Text.IO as T+import Protolude+import Options.Applicativeimport System.Environment@@ -10,7 +10,7 @@ import Radiclemain :: IO ()main = doopts' <- execParser allOpts- cfgSrc <- T.readFile =<< case configFile opts' of+ cfgSrc <- readFile =<< case configFile opts' ofNothing -> getConfigJust cfg -> pure cfghist <- case histFile opts' ofdiff --git a/src/Radicle/Internal.hs b/src/Radicle/Internal.hsindex 4dd22d4..47d2b9d 100644--- a/src/Radicle/Internal.hs+++ b/src/Radicle/Internal.hs@@ -3,14 +3,14 @@ module Radicle.Internal, mkIdent) where+import Protolude+import Radicle.Internal.Core as Ximport Radicle.Internal.Parse as Ximport Radicle.Internal.Pretty as Ximport Radicle.Internal.Primops as Ximport Radicle.Internal.Subscriber as X-import Control.Monad.Reader-import Data.Text (Text)import qualified Text.Megaparsec as M-- | Smart constructor for Ident.diff --git a/src/Radicle/Internal/Core.hs b/src/Radicle/Internal/Core.hsindex 3406142..d728882 100644--- a/src/Radicle/Internal/Core.hs+++ b/src/Radicle/Internal/Core.hs@@ -1,22 +1,16 @@module Radicle.Internal.Core where-import Control.Monad.Except (ExceptT(..), MonadError, runExceptT,- throwError)+import Protolude hiding (TypeError, (<>))+import Control.Monad.Stateimport Data.Data (Data)-import Data.IntMap (IntMap)import qualified Data.IntMap as IntMapimport Data.List.NonEmpty (NonEmpty)import qualified Data.List.NonEmpty as NonEmpty-import Data.Map (Map)import qualified Data.Map as Mapimport Data.Scientific (Scientific)-import Data.Semigroup (Semigroup, (<>))-import Data.Text (Text)-import qualified Data.Text as T-import Data.Void (Void)-import GHC.Exts (IsList(..), fromString)-import GHC.Generics (Generic)+import Data.Semigroup ((<>))+import qualified GHC.Exts as GhcExtsimport qualified Text.Megaparsec.Error as Par-- * Value@@ -67,7 +61,7 @@ errorToValue e = case e ofExit -> makeVal ("exit", [])wheremakeA = quote . Atom- makeVal (t,v) = pure (Ident t, Dict $ Map.mapKeys (Atom . Ident) . fromList $ v)+ makeVal (t,v) = pure (Ident t, Dict $ Map.mapKeys (Atom . Ident) . GhcExts.fromList $ v)newtype Reference = Reference { getReference :: Int }deriving (Show, Read, Ord, Eq, Generic)@@ -118,17 +112,17 @@ newtype Ident = Ident { fromIdent :: Text }-- Unsafe! Only use this if you know the string at compile-time and know it's a-- valid identifier-toIdent :: String -> Ident-toIdent = Ident . fromString+toIdent :: Text -> Ident+toIdent = Ident-- | The environment, which keeps all known bindings.newtype Env s = Env { fromEnv :: Map Ident s }deriving (Eq, Semigroup, Monoid, Ord, Show, Read, Generic, Functor, Foldable, Traversable)-instance IsList (Env s) where+instance GhcExts.IsList (Env s) wheretype Item (Env s) = (Ident, s)- fromList = Env . fromList- toList = GHC.Exts.toList . fromEnv+ fromList = Env . Map.fromList+ toList = GhcExts.toList . fromEnv-- | Primop mappings. The parameter specifies the monad the primops run in.type Primops m = Map Ident ([Value ] -> Lang m Value)@@ -224,7 +218,7 @@ eval val = doLambda _ _ Nothing -> throwError $ Impossible"lambda should already have an env"Lambda [bnd] body (Just closure) -> do- let mappings = fromList [(bnd, val)]+ let mappings = GhcExts.fromList [(bnd, val)]modEnv = mappings <> closureNonEmpty.last <$> withEnv (\e' -> e' { bindingsEnv = modEnv})(traverse eval body)@@ -237,7 +231,7 @@ baseEval val = case val ofRef i -> pure $ Ref iList (f:vs) -> f $$ vsList xs -> throwError- $ WrongNumberOfArgs ("application: " <> T.pack (show xs))+ $ WrongNumberOfArgs ("application: " <> show xs)2(length xs)String s -> pure $ String s@@ -273,7 +267,7 @@ mfn $$ vs = do(length vs)else dovs' <- traverse baseEval vs- let mappings = fromList (zip bnds vs')+ let mappings = GhcExts.fromList (zip bnds vs')NonEmpty.last <$> withEnv(\e -> e { bindingsEnv = mappings <> bindingsEnv e })(traverse baseEval body)@@ -283,7 +277,7 @@ mfn $$ vs = do(length vs)else dovs' <- traverse baseEval vs- let mappings = fromList (zip bnds vs')+ let mappings = GhcExts.fromList (zip bnds vs')modEnv = mappings <> closureNonEmpty.last <$> withEnv (\e -> e { bindingsEnv = modEnv })(traverse baseEval body)diff --git a/src/Radicle/Internal/Parse.hs b/src/Radicle/Internal/Parse.hsindex 5875c0c..88d292b 100644--- a/src/Radicle/Internal/Parse.hs+++ b/src/Radicle/Internal/Parse.hs@@ -1,18 +1,11 @@module Radicle.Internal.Parse where-import Control.Applicative (many, (<|>))-import Control.Monad (void)-import Control.Monad.Except (MonadError, throwError)-import Control.Monad.Identity (Identity)-import Control.Monad.Reader (Reader, ask, runReader)-import Control.Monad.State (gets)+import Protolude hiding (some, try)+import Data.Char (isAlphaNum, isLetter)-import Data.Either (partitionEithers)import Data.List.NonEmpty (NonEmpty((:|)), fromList)import qualified Data.Map as Map-import Data.Text (Text)import qualified Data.Text as T-import Data.Void (Void)import GHC.Exts (IsString(..))import Text.Megaparsec (ParsecT, State(..), between, choice,defaultTabWidth, eof, initialPos, manyTill,@@ -49,7 +42,7 @@ parensP = between (symbol "(" >> spaceConsumer) (spaceConsumer >> symbol ")")stringLiteralP :: VParserstringLiteralP = lexeme $- String . T.pack <$> (char '"' >> manyTill L.charLiteral (char '"'))+ String . toS <$> (char '"' >> manyTill L.charLiteral (char '"'))boolLiteralP :: VParserboolLiteralP = lexeme $ Boolean <$> (char '#' >>@@ -60,7 +53,7 @@ numLiteralP = Number <$> signed L.scientificwhere-- We don't allow spaces between the sign and digits so that we can remain-- consistent with the general Scheme of things.- signed p = M.option id ((id <$ char '+') <|> (negate <$ char '-')) <*> p+ signed p = M.option identity ((identity <$ char '+') <|> (negate <$ char '-')) <*> pidentP :: Parser IdentidentP = lexeme $ do@@ -120,13 +113,13 @@ valueP = do-- Left (TypeError "Trying to apply a non-function")interpret:: Monad m- => String+ => Text-> Text-> Bindings m-> m (Either (LangError Value) Value)interpret sourceName expr bnds = dolet primopNames = Map.keys (bindingsPrimops bnds)- parsed = runReader (runParserT (valueP <* eof) sourceName expr) primopNames+ parsed = runReader (runParserT (valueP <* eof) (toS sourceName) expr) primopNamescase parsed ofLeft e -> pure . Left $ ParseError eRight v -> fst <$> runLang bnds (eval v)@@ -137,24 +130,27 @@ interpret sourceName expr bnds = do---- >>> fmap fst <$> runLang pureEnv $ interpretMany "test" "(define id (lambda (x) x))\n(id #t)"-- Right (Boolean True)-interpretMany :: Monad m => String -> Text -> Lang m Value+interpretMany :: Monad m => Text -> Text -> Lang m ValueinterpretMany sourceName src = doprimopNames <- gets $ Map.keys . bindingsPrimopslet parsed = parseValues sourceName src primopNamescase partitionEithers parsed of- ([], vs) -> last <$> mapM eval vs+ ([], vs) -> do es <- mapM eval vs+ case lastMay es of+ Just e -> pure e+ _ -> throwError (OtherError "InterpretMany should be called with at least one expression.")(e:_, _) -> throwError $ ParseError e-- | Parse a Text as a series of values.-- 'sourceName' is used for error reporting. 'prims' are the primop names.---- Note that parsing continues even if one value fails to parse.-parseValues :: String -> Text -> [Ident] -> [Either (Par.ParseError Char Void) Value]+parseValues :: Text -> Text -> [Ident] -> [Either (Par.ParseError Char Void) Value]parseValues sourceName srcCode prims = go $ initialwhereinitial = State{ stateInput = T.strip srcCode- , statePos = initialPos sourceName :| []+ , statePos = initialPos (toS sourceName) :| [], stateTokensProcessed = 0, stateTabWidth = defaultTabWidth}@@ -166,24 +162,24 @@ parseValues sourceName srcCode prims = go $ initial---- Examples:----- >>> parse "test" "#t" [] :: Either String Value+-- >>> parse "test" "#t" [] :: Either Text Value-- Right (Boolean True)----- >>> parse "test" "hi" [toIdent "hi"] :: Either String Value+-- >>> parse "test" "hi" [toIdent "hi"] :: Either Text Value-- Right (Primop (Ident {fromIdent = "hi"}))----- >>> parse "test" "hi" [] :: Either String Value+-- >>> parse "test" "hi" [] :: Either Text Value-- Right (Atom (Ident {fromIdent = "hi"}))-parse :: MonadError String m => String -> Text -> [Ident] -> m Value+parse :: MonadError Text m => Text -> Text -> [Ident] -> m Valueparse file src ids = do- let res = runReader (M.runParserT (valueP <* eof) file src) ids+ let res = runReader (M.runParserT (valueP <* eof) (toS file) src) idscase res of- Left err -> throwError $ M.parseErrorPretty' src err+ Left err -> throwError . toS $ M.parseErrorPretty' src errRight v -> pure v-- | Like 'parse', but uses "(test)" as the source name and the default set of-- primops.-parseTest :: MonadError String m => Text -> m Value+parseTest :: MonadError Text m => Text -> m ValueparseTest t = parse "(test)" t (Map.keys $ bindingsPrimops e)wheree :: Bindings (Lang Identity)diff --git a/src/Radicle/Internal/Pretty.hs b/src/Radicle/Internal/Pretty.hsindex d650cfb..0241fbe 100644--- a/src/Radicle/Internal/Pretty.hs+++ b/src/Radicle/Internal/Pretty.hs@@ -1,9 +1,9 @@{-# OPTIONS_GHC -fno-warn-orphans #-}module Radicle.Internal.Pretty where-import Data.List.NonEmpty (toList)+import Protolude hiding (TypeError, (<>))+import qualified Data.Map as Map-import Data.Text (Text)import qualified Data.Text as Timport Data.Text.Prettyprint.Docimport Data.Text.Prettyprint.Doc.Render.Text@@ -24,7 +24,7 @@ instance Pretty Value whereAtom i -> pretty iRef i -> parens $ "ref" <+> pretty iString t -> "\"" <> pretty (escapeStr t) <> "\""- Number n -> pretty $ show n+ Number n -> pretty (show n :: Text)Boolean True -> "#t"Boolean False -> "#f"List vs -> parens (sep (pretty <$> vs))diff --git a/src/Radicle/Internal/Primops.hs b/src/Radicle/Internal/Primops.hsindex c6ad838..d27b7df 100644--- a/src/Radicle/Internal/Primops.hs+++ b/src/Radicle/Internal/Primops.hs@@ -3,16 +3,11 @@ module Radicle.Internal.Primops, purePrimops) where-import Control.Monad.Except (catchError, throwError)-import Control.Monad.State-import Data.Bifunctor (first)-import Data.Foldable (foldlM, foldrM)+import Protolude hiding (TypeError)+import qualified Data.IntMap as IntMapimport qualified Data.Map as Map-import Data.Maybe (catMaybes, isJust)import Data.Scientific (Scientific)-import Data.Semigroup ((<>))-import Data.Text (Text)import GHC.Exts (IsList(..))import Radicle.Internal.Core@@ -27,7 +22,7 @@ pureEnv = Bindings e purePrimops mempty 0-- | The universal primops. These are available in chain evaluation, and are-- not shadowable via 'define'.purePrimops :: forall m. (Monad m) => Primops m-purePrimops = Map.fromList $ first Ident <$>+purePrimops = fromList $ first Ident <$>[ ("base-eval", evalArgs $ \args -> case args of[x] -> baseEval xxs -> throwError $ WrongNumberOfArgs "base-eval" 1 (length xs))@@ -35,7 +30,7 @@ purePrimops = Map.fromList $ first Ident <$>, ("dict", evalArgs $ \args ->let go (k:v:rest) = Map.insert k v $ go restgo [] = mempty- go _ = error "impossible"+ go _ = panic "impossible"in if length args `mod` 2 == 0then pure . Dict $ go argselse throwError $ OtherError "'dict' expects even number of args")diff --git a/src/Radicle/Internal/Subscriber.hs b/src/Radicle/Internal/Subscriber.hsindex 2d25e6e..ac749a4 100644--- a/src/Radicle/Internal/Subscriber.hs+++ b/src/Radicle/Internal/Subscriber.hs@@ -1,13 +1,8 @@module Radicle.Internal.Subscriber where-import Control.Monad (forever, void)-import Control.Monad.Except (throwError)-import Control.Monad.State (get, gets)-import Data.Bifunctor (first)-import Data.List (isPrefixOf)+import Protolude hiding (TypeError)+import qualified Data.Map as Map-import Data.Monoid ((<>))-import Data.Text (Text)import qualified Data.Text as Timport Data.Text.Prettyprint.Doc (pretty)import Data.Text.Prettyprint.Doc.Render.Terminal (putDoc)@@ -84,7 +79,7 @@ replPrimops = Map.fromList $ first toIdent <$>case p ofRight v -> pure vLeft e -> throwError $ ThrownError (Ident "parse-error")- (String $ T.pack e)+ (String e)xs -> throwError $ WrongNumberOfArgs "get-line!" 0 (length xs)), ("subscribe-to!", \args -> case args ofdiff --git a/src/Radicle/Internal/Subscriber/Capabilities.hs b/src/Radicle/Internal/Subscriber/Capabilities.hsindex f5f236b..15a56c9 100644--- a/src/Radicle/Internal/Subscriber/Capabilities.hs+++ b/src/Radicle/Internal/Subscriber/Capabilities.hs@@ -4,10 +4,8 @@-- constraints) what effects they do.module Radicle.Internal.Subscriber.Capabilities where-import Control.Monad.State (gets, modify)-import Control.Monad.Trans-import Data.Text (Text)-import qualified Data.Text as T+import Protolude+import Data.Text.Prettyprint.Doc (PageWidth)import System.Console.Haskeline@@ -19,15 +17,15 @@ instance {-# OVERLAPPABLE #-} Stdin m => Stdin (Lang m) wheregetLineS = lift getLineSinstance (MonadException m, Monad m) => Stdin (InputT m) wheregetLineS = getInputLine "rad> " >>= \x -> case x of- Nothing -> error "curious about why this would happen"- Just v -> pure $ T.pack v+ Nothing -> panic "curious about why this would happen"+ Just v -> pure . toS $ vclass (Monad m) => Stdout m whereputStrS :: Text -> m ()instance {-# OVERLAPPABLE #-} Stdout m => Stdout (Lang m) whereputStrS = lift . putStrSinstance (MonadException m, Monad m) => Stdout (InputT m) where- putStrS = outputStrLn . T.unpack+ putStrS = outputStrLn . toSclass (Monad m) => Exit m whereexitS :: m ()@@ -45,7 +43,7 @@ instance Monad m => SetEnv (Lang m) Value wheresetEnvS e = modify (\bnds -> bnds {bindingsEnv = e})class (Monad m) => GetSourceName m where- getSourceNameS :: m String+ getSourceNameS :: m Textclass (Monad m) => HasPageWidth m wheregetPageWidthS :: m PageWidthclass (Monad m) => GetSubs m wherediff --git a/test/docs/Main.hs b/test/docs/Main.hsindex 48938eb..8d9d5ea 100644--- a/test/docs/Main.hs+++ b/test/docs/Main.hs@@ -1,5 +1,7 @@module Main (main) where+import Protolude+import Hpack.Configimport System.FilePath.Glob (glob)import Test.DocTestdiff --git a/test/spec/Radicle/Internal/Arbitrary.hs b/test/spec/Radicle/Internal/Arbitrary.hsindex 41760ad..53864c3 100644--- a/test/spec/Radicle/Internal/Arbitrary.hs+++ b/test/spec/Radicle/Internal/Arbitrary.hs@@ -1,13 +1,10 @@{-# OPTIONS_GHC -fno-warn-orphans #-}module Radicle.Internal.Arbitrary where-import Control.Monad.Identity (Identity)-import Data.Bifunctor (first)+import Protolude+import qualified Data.Map as Map-import Data.Maybe (isJust)import Data.Scientific (Scientific)-import qualified Data.Text as T-import Safe (readMay)import Test.QuickCheckimport Test.QuickCheck.Instances ()@@ -45,10 +42,10 @@ instance Arbitrary Value whereprims :: Map.Map Ident ([Value] -> Lang Identity Value)prims = purePrimopsisPrimop x = x `elem` Map.keys prims- isNum x = isJust (readMay (T.unpack $ fromIdent x) :: Maybe Scientific)+ isNum x = isJust (readMaybe (toS $ fromIdent x) :: Maybe Scientific)instance Arbitrary Ident where- arbitrary = ((:) <$> firstL <*> rest) `suchThatMap` (mkIdent . T.pack)+ arbitrary = ((:) <$> firstL <*> rest) `suchThatMap` (mkIdent . toS)whereallChars = take 100 ['!' .. maxBound]firstL = elements $ filter isValidIdentFirst allCharsdiff --git a/test/spec/Radicle/Internal/TestCapabilities.hs b/test/spec/Radicle/Internal/TestCapabilities.hsindex d51268e..70d956b 100644--- a/test/spec/Radicle/Internal/TestCapabilities.hs+++ b/test/spec/Radicle/Internal/TestCapabilities.hs@@ -2,9 +2,7 @@-- Radicle.Internal.Subscriber.Capabilities that may be used for testing.module Radicle.Internal.TestCapabilities where-import Control.Monad.State-import Control.Monad.Except-import Data.Text (Text)+import Protoludeimport Radicleimport Radicle.Internal.Subscriber.Capabilities@@ -56,7 +54,7 @@ instance {-# OVERLAPPING #-} Stdin TestLang wheregetLineS = dows <- lift getcase worldStateStdin ws of- [] -> throwError $ OtherError "test: out of stdin"+ [] -> throwError $ OtherError "test: out of stdin"h:hs -> lift (put $ ws { worldStateStdin = hs }) >> pure hinstance {-# OVERLAPPING #-} Stdout TestLang wherediff --git a/test/spec/Radicle/Tests.hs b/test/spec/Radicle/Tests.hsindex 17cda21..8974a8e 100644--- a/test/spec/Radicle/Tests.hs+++ b/test/spec/Radicle/Tests.hs@@ -1,14 +1,12 @@{-# LANGUAGE QuasiQuotes #-}module Radicle.Tests where-import Data.Either (isLeft)-import Data.Functor.Identity (runIdentity)+import Protolude hiding (toList)+import Data.List (isSuffixOf)-import Data.Semigroup ((<>))import Data.String.Interpolate (i)import Data.String.QQ (s)import qualified Data.Text as T-import qualified Data.Text.IO as Timport GHC.Exts (fromList, toList)import System.Directory (getDirectoryContents)import Test.Tasty@@ -20,7 +18,7 @@ import Radicle.Internal.Arbitrary ()import Radicle.Internal.Core (toIdent)import Radicle.Internal.TestCapabilities-import Paths_radicle -- generated by cabal via 'data-files'+import Paths_radicletest_eval :: [TestTree]test_eval =@@ -54,7 +52,7 @@ test_eval =, testProperty "'eq?' considers equal values equal" $ \(val :: Value) -> dolet prog = [i|(eq? #{renderPrettyDef val} #{renderPrettyDef val})|]- res = runTest' $ T.pack prog+ res = runTest' $ toS progcounterexample prog $ isLeft res || res == Right (Boolean True), testCase "'eq?' works for quoted values" $ do@@ -67,7 +65,7 @@ test_eval =-- We quote the values to prevent errors from being thrownlet prog = [i|(eq? (quote #{renderPrettyDef v1})(quote #{renderPrettyDef v2}))|]- res = runTest' $ T.pack prog+ res = runTest' $ toS prog-- Either evaluation failed or their equal.counterexample prog $ isLeft res || res == Right (Boolean False)@@ -110,7 +108,7 @@ test_eval =expected = Right . String $ mconcat ssinfo = "Expected:\n" <> prettyEither expected <>"Got:\n" <> prettyEither res- counterexample (T.unpack info) $ res == expected+ counterexample (toS info) $ res == expected, testCase "'foldl' foldls the list" $ dolet prog = [s|(foldl - 0 (list 1 2 3))|]@@ -138,11 +136,11 @@ test_eval =, testProperty "'eval' does not alter functions" $ \(_v :: Value) -> dolet prog1 = [i| (eval (lambda () #{renderPrettyDef _v})) |]prog2 = [i| (lambda () #{renderPrettyDef _v}) |]- res1 = runTest' $ T.pack prog1- res2 = runTest' $ T.pack prog2+ res1 = runTest' $ toS prog1+ res2 = runTest' $ toS prog2info = "Expected:\n" <> prettyEither res2<> "\nGot:\n" <> prettyEither res1- counterexample (T.unpack info) $ res1 == res2+ counterexample (toS info) $ res1 == res2, testCase "lambdas work" $ dolet prog = [s|((lambda (x) x) #t)|]@@ -234,12 +232,12 @@ test_eval =, testProperty "'>' works" $ \(x, y) -> dolet prog = [i|(> #{renderPrettyDef $ Number x} #{renderPrettyDef $ Number y})|]- res = runTest' $ T.pack prog+ res = runTest' $ toS progcounterexample prog $ res == Right (Boolean (x > y)), testProperty "'<' works" $ \(x, y) -> dolet prog = [i|(< #{renderPrettyDef $ Number x} #{renderPrettyDef $ Number y})|]- res = runTest' $ T.pack prog+ res = runTest' $ toS progcounterexample prog $ res == Right (Boolean (x < y)), testCase "'define' fails when first arg is not an atom" $ do@@ -283,10 +281,10 @@ test_eval =res @?= Right (Number 6), testProperty "read-ref . ref == id" $ \(v :: Value) -> do- let derefed = runTest' $ T.pack [i|(read-ref (ref #{renderPrettyDef v}))|]- orig = runTest' $ T.pack [i|#{renderPrettyDef v}|]- info = "Expected:\n" <> T.unpack (prettyEither orig)- <> "\nGot:\n" <> T.unpack (prettyEither derefed)+ let derefed = runTest' $ toS [i|(read-ref (ref #{renderPrettyDef v}))|]+ orig = runTest' $ toS [i|#{renderPrettyDef v}|]+ info = "Expected:\n" <> toS (prettyEither orig)+ <> "\nGot:\n" <> toS (prettyEither derefed)counterexample info $ derefed == orig, testCase "'show' works" $ do@@ -359,9 +357,9 @@ test_pretty =actual = parseTest renderedoriginal = removeEnv valinfo = case actual of- Left e -> "parse error in: " <> T.unpack rendered <> "\n"- <> e- Right v -> "pretty: " <> T.unpack rendered <> "\n"+ Left e -> "parse error in: " <> toS rendered <> "\n"+ <> toS e+ Right v -> "pretty: " <> toS rendered <> "\n"<> "reparsed: " <> show v <> "\n"<> "original: " <> show original <> "\n"in counterexample info $ actual == Right original@@ -377,7 +375,7 @@ test_repl_primops :: [TestTree]test_repl_primops =[ testProperty "get-line! returns the input line" $ \(v :: Value) ->let prog = [i|(eq? (get-line!) (quote #{renderPrettyDef v}))|]- res = run [renderPrettyDef v] $ T.pack prog+ res = run [renderPrettyDef v] $ toS progin counterexample prog $ res == Right (Boolean True), testCase "catch catches get-line errors" $ do@@ -392,7 +390,7 @@ test_repl_primops =res @?= Right (String "caught")]where- run stdin prog = fst $ runTestWith replBindings stdin prog+ run stdin' prog = fst $ runTestWith replBindings stdin' progtest_repl :: [TestTree]@@ -436,27 +434,27 @@ test_repl =result @?= output]where- getCfg = getDataFileName "repl/config.rad" >>= T.readFile+ getCfg = getDataFileName "repl/config.rad" >>= readFile-- The repl catches exceptions, including the "out of stdin" exception-- that occurs at the end of a session, so we take the 'init' of the-- result.- runInRepl inp = fmap init <$> (runTestWith replBindings inp <$> getCfg)+ runInRepl inp = fmap initSafe <$> (runTestWith replBindings inp <$> getCfg)-- Tests all radicle files 'repl' dir. These should use the 'should-be'-- function to ensure they are in the proper format.test_source_files :: IO TestTreetest_source_files = testGroup "Radicle source file tests" <$> dooneOf'Em <- getDataFileName "repl/config.rad"- let dir = reverse $ drop (length ("config.rad" :: String)) $ reverse oneOf'Em+ let dir = reverse $ drop (T.length ("config.rad" :: Text)) $ reverse oneOf'Emfiles <- getDirectoryContents dirlet radFiles = filter (".rad" `isSuffixOf`) filessequence $ radFiles <&> \file -> do- contents <- T.readFile $ dir <> file+ contents <- readFile $ dir <> filelet (_, out) = runTestWith replBindings [] contentslet makeTest line = let (name, result) = T.span (/= '\'')$ T.drop 1$ T.dropWhile (/= '\'') line- in testCase (T.unpack name) $ result @?= "' succeeded\""+ in testCase (toS name) $ result @?= "' succeeded\""pure $ testGroup file$ [ makeTest ln | ln <- out, "\"Test" `T.isPrefixOf` ln ]@@ -474,6 +472,3 @@ removeEnv v = case v ofprettyEither :: Either (LangError Value) Value -> T.TextprettyEither (Left e) = "Error: " <> renderPrettyDef eprettyEither (Right v) = renderPrettyDef v--(<&>) :: Functor f => f a -> (a -> b) -> f b-(<&>) = flip fmap