text-zipper-monad 0.1.0.0 → 0.2.0.0
raw patch · 4 files changed
+48/−9 lines, 4 filesdep ~text-zipperPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: text-zipper
API changes (from Hackage documentation)
+ Data.Text.Zipper.Edit: killToBOL :: (Monoid t, Monad m) => EditT t m ()
Files
- CHANGELOG.md +7/−0
- README.md +23/−0
- src/Data/Text/Zipper/Edit.hs +14/−6
- text-zipper-monad.cabal +4/−3
+ CHANGELOG.md view
@@ -0,0 +1,7 @@+## text-zipper-monad 0.2.0.0++* Bump dependency on `text-zipper` to 0.5. killToBOL function is added.++## text-zipper-monad 0.1.0.0++* Initial version.
+ README.md view
@@ -0,0 +1,23 @@+# text-zipper-monad++[](https://hackage.haskell.org/package/text-zipper-monad)+[](https://travis-ci.org/kseo/text-zipper-monad)++text-zipper-monad provides a monadic interface to the text-zipper package.++## Usage++```haskell+import Data.Text.Zipper+import qualified Data.Text.Zipper.Edit as Z++insertXAtTheBeginning = do+ Z.moveCursor (0, 0)+ Z.insertChar 'x'++main = do+ let tz = stringZipper ["abc", "def"] Nothing+ newTz = Z.execEdit insertXAtTheBeginning tz+ putStrLn (unlines (getText newTz))+```+
src/Data/Text/Zipper/Edit.hs view
@@ -27,6 +27,7 @@ , moveCursor , insertChar , breakLine+ , killToBOL , killToEOL , gotoEOL , gotoBOL@@ -53,7 +54,7 @@ -- | Execute the edit session with the given zipper and return the -- modified zipper. execEditT :: (Monoid t, Monad m) => EditT t m a -> TextZipper t -> m (TextZipper t)-execEditT e tz = execStateT (unEdit e) tz+execEditT e = execStateT (unEdit e) -- | Execute the edit session with the given zipper and return the -- modified zipper.@@ -68,11 +69,11 @@ -- | Get the text contents of the zipper. getText :: (Monoid t, Monad m) => EditT t m [t]-getText = get >>= return . TZ.getText+getText = TZ.getText <$> get -- | The line of text on which the zipper's cursor currently resides. currentLine :: (Monoid t, Monad m) => EditT t m t-currentLine = get >>= return . TZ.currentLine+currentLine = TZ.currentLine <$> get -- | Get the cursor position of the zipper; returns @(row, col)@. -- @row@ ranges from @[0..num_rows-1]@ inclusive; @col@ ranges from@@ -80,15 +81,15 @@ -- line width indicate a cursor that is just past the end of a line of -- text. cursorPosition :: (Monoid t, Monad m) => EditT t m (Int, Int)-cursorPosition = get >>= return . TZ.cursorPosition+cursorPosition = TZ.cursorPosition <$> get -- | Return the lengths of the lines in the zipper. lineLengths :: (Monoid t, Monad m) => EditT t m [Int]-lineLengths = get >>= return . TZ.lineLengths+lineLengths = TZ.lineLengths <$> get -- | Get the line limit, if any, for a zipper. getLineLimit :: (Monoid t, Monad m) => EditT t m (Maybe Int)-getLineLimit = get >>= return . TZ.getLineLimit+getLineLimit = TZ.getLineLimit <$> get -- | Move the cursor to the specified row and column. Invalid cursor -- positions will be ignored. Valid cursor positions range as@@ -110,6 +111,13 @@ breakLine = do z <- get put (TZ.breakLine z)++-- | Remove all text from the cursor position to the beginning of the+-- current line.+killToBOL :: (Monoid t, Monad m) => EditT t m ()+killToBOL = do+ z <- get+ put (TZ.killToBOL z) -- | Remove all text from the cursor position to the end of the current -- line. If the cursor is at the beginning of a line and the line is
text-zipper-monad.cabal view
@@ -1,5 +1,5 @@ name: text-zipper-monad-version: 0.1.0.0+version: 0.2.0.0 synopsis: Monadic interface to the text-zipper package description: Please see README.md homepage: https://github.com/kseo/text-zipper-monad#readme@@ -10,7 +10,8 @@ copyright: BSD3 category: Text build-type: Simple--- extra-source-files:+extra-source-files: README.md+ , CHANGELOG.md cabal-version: >=1.10 library@@ -18,7 +19,7 @@ exposed-modules: Data.Text.Zipper.Edit build-depends: base >= 4.7 && < 5 , mtl >= 2.2 && < 2.3- , text-zipper >= 0.4 && < 0.5+ , text-zipper >= 0.5 && < 0.6 default-language: Haskell2010 test-suite text-zipper-monad-test