packages feed

climb 0.4.1 → 0.5.0

raw patch · 5 files changed

+38/−39 lines, 5 filesdep ~linenoisedep ~textsetup-changedPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: linenoise, text

API changes (from Hackage documentation)

- Climb: data ReplDirective
+ Climb: data () => ReplDirective

Files

README.md view
@@ -1,5 +1,3 @@ # climb -[![CircleCI](https://circleci.com/gh/ejconlon/climb/tree/master.svg?style=svg)](https://circleci.com/gh/ejconlon/climb/tree/master)- Building blocks for a GHCI-like REPL with colon-commands. (Not production ready!) See the [demo app](https://github.com/ejconlon/climb/blob/master/app/Main.hs) for usage, or see the lower-level [haskell-linenoise](https://github.com/ejconlon/haskell-linenoise) library this depends on.
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
app/Main.hs view
@@ -18,11 +18,12 @@  instance Exception BadGuessErr -data ReplEnv = ReplEnv-  { reMagicNumber :: !Int-  } deriving stock (Eq, Show)+newtype ReplEnv = ReplEnv+  { reMagicNumber :: Int+  }+  deriving stock (Eq, Show) -newtype ReplM a = ReplM { unReplM :: ReaderT ReplEnv IO a }+newtype ReplM a = ReplM {unReplM :: ReaderT ReplEnv IO a}   deriving newtype (Functor, Applicative, Monad, MonadReader ReplEnv, MonadIO, MonadUnliftIO, MonadThrow, MonadCatch)  runReplM :: ReplM a -> ReplEnv -> IO a@@ -49,14 +50,15 @@ completion _ = pure []  replDef :: ReplDef ReplM-replDef = ReplDef-  { rdOnInterrupt = ReplContinue-  , rdGreeting = "Hello, REPL!"-  , rdPrompt = "> "-  , rdOptionCommands = options-  , rdExecCommand = exec-  , rdCompletion = completion-  }+replDef =+  ReplDef+    { rdOnInterrupt = ReplContinue+    , rdGreeting = "Hello, REPL!"+    , rdPrompt = "> "+    , rdOptionCommands = options+    , rdExecCommand = exec+    , rdCompletion = completion+    }  main :: IO () main = runReplM (runReplDef replDef) (ReplEnv 42)
climb.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack ----- hash: f41c917ee50a977a56b9761e243421d7b49b0f973556aad566f526b406bf51d8+-- hash: a74d63a6492ae659aa9ca016c20dbb590adfb5e347df479d81021fe81895cec1  name:           climb-version:        0.4.1+version:        0.5.0 synopsis:       Building blocks for a GHCi-like REPL with colon-commands description:    Please see the README on GitHub at <https://github.com/ejconlon/climb#readme> category:       User Interfaces@@ -42,9 +42,9 @@     , bytestring >=0.10 && <1     , containers >=0.6 && <1     , exceptions >=0.10 && <1-    , linenoise >=0.3.2 && <1+    , linenoise >=0.4.0 && <1     , mtl >=2.2 && <3-    , text >=1.2 && <2+    , text >=1.2 && <3     , unliftio-core >=0.1 && <1   default-language: Haskell2010 @@ -64,8 +64,8 @@     , climb     , containers >=0.6 && <1     , exceptions >=0.10 && <1-    , linenoise >=0.3.2 && <1+    , linenoise >=0.4.0 && <1     , mtl >=2.2 && <3-    , text >=1.2 && <2+    , text >=1.2 && <3     , unliftio-core >=0.1 && <1   default-language: Haskell2010
src/Climb.hs view
@@ -13,7 +13,8 @@   , noCompletion   , runReplDef   , stepReplDef-  ) where+  )+where  import Control.Exception (Exception (..), SomeAsyncException (..), SomeException) import Control.Monad (unless)@@ -40,24 +41,23 @@  -- | Sometimes things go wrong... data CommandErr-  = CommandErrExpectedNoInput-  -- ^ An option 'Command' got input when it expected None-  | CommandErrUnknownCommand !Text-  -- ^ An option 'Command' was not found by name.+  = -- | An option 'Command' got input when it expected None+    CommandErrExpectedNoInput+  | -- | An option 'Command' was not found by name.+    CommandErrUnknownCommand !Text   deriving stock (Eq, Show)  instance Exception CommandErr  -- | Defines a REPL with commands, options, and completion.-data ReplDef m =-  ReplDef-    { rdOnInterrupt :: !ReplDirective-    , rdGreeting :: !Text-    , rdPrompt :: !Text-    , rdOptionCommands :: !(OptionCommands m)-    , rdExecCommand :: !(Command m)-    , rdCompletion :: !(Completion m)-    }+data ReplDef m = ReplDef+  { rdOnInterrupt :: !ReplDirective+  , rdGreeting :: !Text+  , rdPrompt :: !Text+  , rdOptionCommands :: !(OptionCommands m)+  , rdExecCommand :: !(Command m)+  , rdCompletion :: !(Completion m)+  }  noOptionCommands :: OptionCommands m noOptionCommands = Map.empty@@ -82,7 +82,8 @@   pure ReplContinue  defaultOptions :: (MonadThrow m, MonadIO m) => OptionCommands m -> OptionCommands m-defaultOptions opts = Map.fromList+defaultOptions opts =+  Map.fromList     [ ("quit", ("quit", quitCommand))     , ("help", ("describe all commands", helpCommand opts))     ]@@ -91,7 +92,7 @@ outerCommand opts exec input =   case Text.uncons input of     Just (':', rest) -> do-      let (name, subInput) = Text.break (==' ') rest+      let (name, subInput) = Text.break (== ' ') rest       case Map.lookup name opts of         Nothing -> throwM (CommandErrUnknownCommand name)         Just (_, command) -> command (Text.drop 1 subInput)