edit 0.0.1.1 → 1.0.0.0
raw patch · 5 files changed
+32/−29 lines, 5 filesdep ~doctestdep ~tastydep ~tasty-quickcheckPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: doctest, tasty, tasty-quickcheck
API changes (from Hackage documentation)
- Data.Edit: instance (Data.Semigroup.Semigroup a, GHC.Base.Monoid a) => GHC.Base.Monoid (Data.Edit.Edit a)
- Data.Edit: instance Data.Semigroup.Semigroup a => Data.Semigroup.Semigroup (Data.Edit.Edit a)
- Data.Edit.Tutorial: Add :: Expr -> Expr -> Expr
- Data.Edit.Tutorial: Ident :: String -> Ident
- Data.Edit.Tutorial: Val :: Int -> Expr
- Data.Edit.Tutorial: Var :: Ident -> Expr
- Data.Edit.Tutorial: constFold :: Expr -> Expr
- Data.Edit.Tutorial: constFold' :: Expr -> Edit Expr
- Data.Edit.Tutorial: constFoldAndPropPass :: [Stmt] -> [Stmt]
- Data.Edit.Tutorial: constFoldPass :: [Stmt] -> Edit [Stmt]
- Data.Edit.Tutorial: constProp :: Map Ident Int -> Stmt -> (Map Ident Int, Stmt)
- Data.Edit.Tutorial: constProp' :: Map Ident Int -> Stmt -> (Map Ident Int, Edit Stmt)
- Data.Edit.Tutorial: constPropPass :: [Stmt] -> Edit [Stmt]
- Data.Edit.Tutorial: data Expr
- Data.Edit.Tutorial: data Stmt
- Data.Edit.Tutorial: instance Data.Data.Data Data.Edit.Tutorial.Expr
- Data.Edit.Tutorial: instance Data.Data.Data Data.Edit.Tutorial.Ident
- Data.Edit.Tutorial: instance GHC.Classes.Eq Data.Edit.Tutorial.Expr
- Data.Edit.Tutorial: instance GHC.Classes.Eq Data.Edit.Tutorial.Ident
- Data.Edit.Tutorial: instance GHC.Classes.Ord Data.Edit.Tutorial.Ident
- Data.Edit.Tutorial: instance GHC.Show.Show Data.Edit.Tutorial.Expr
- Data.Edit.Tutorial: instance GHC.Show.Show Data.Edit.Tutorial.Ident
- Data.Edit.Tutorial: instance GHC.Show.Show Data.Edit.Tutorial.Stmt
- Data.Edit.Tutorial: newtype Ident
- Data.Edit.Tutorial: substitute :: Map Ident Int -> Expr -> Expr
- Data.Edit.Tutorial: substitute' :: Map Ident Int -> Expr -> Edit Expr
+ Control.Monad.Trans.Edit: instance Control.Comonad.Comonad c => Control.Comonad.Comonad (Control.Monad.Trans.Edit.EditT c)
+ Control.Monad.Trans.Edit: instance Control.Comonad.Trans.Class.ComonadTrans Control.Monad.Trans.Edit.EditT
+ Data.Edit: instance Control.Comonad.Comonad Data.Edit.Edit
+ Data.Edit: instance Control.Comonad.ComonadApply Data.Edit.Edit
+ Data.Edit: instance GHC.Base.Monoid a => GHC.Base.Monoid (Data.Edit.Edit a)
+ Data.Edit: instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Data.Edit.Edit a)
+ Data.Edit: instance Test.QuickCheck.Arbitrary.Arbitrary a => Test.QuickCheck.Arbitrary.Arbitrary (Data.Edit.Edit a)
+ Data.Edit: instance Test.QuickCheck.Arbitrary.Arbitrary1 Data.Edit.Edit
- Data.Edit: (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
+ Data.Edit: (<=<) :: Monad m => b -> m c -> a -> m b -> a -> m c
- Data.Edit: (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
+ Data.Edit: (>=>) :: Monad m => a -> m b -> b -> m c -> a -> m c
- Data.Edit: duplicate :: Edit a -> Edit (Edit a)
+ Data.Edit: duplicate :: Comonad w => w a -> w w a
- Data.Edit: extend :: (Edit a -> b) -> Edit a -> Edit b
+ Data.Edit: extend :: Comonad w => w a -> b -> w a -> w b
- Data.Edit: extract :: Edit a -> a
+ Data.Edit: extract :: Comonad w => w a -> a
Files
- ChangeLog.md +4/−3
- Readme.md +11/−3
- edit.cabal +10/−11
- src/Data/Edit.hs +2/−8
- src/Data/Edit/Tutorial.hs +5/−4
ChangeLog.md view
@@ -1,5 +1,6 @@-# Revision history for edit+# Revision history for `edit` -## 0.1.0.0 -- YYYY-mm-dd+## 1.0.0.0 -- 2018-07-19 -* First version. Released on an unsuspecting world.+* `QuickCheck` and `comonad` are enabled by default instead of being disabled+ by default. The flag names have been changed to reflect this.
Readme.md view
@@ -5,9 +5,16 @@ 1. You are making a sequence of transformations on some type and want to keep track of whether any of them changed it or not.-2. You are rewriting a recursive type and want to bubble up information- whether something was changed or not.+2. You are rewriting a recursive type (or a garden of mutually recursive types!)+ and want to bubble up information whether something was changed or not. +For example, Reddit user /u/p__bing [says](https://www.reddit.com/r/haskell/comments/8mrqfy/ann_edit_a_small_package_for_rewriting_things/e00jo8i/?utm_content=permalink&utm_medium=front&utm_source=reddit&utm_name=haskell)++> [..] I work as an iOS developer and we have this same+> exact idea implemented, as a monad, in Swift, to make our UI updates faster+> (if a change goes through our model layer and comes out Clean, we don’t bother+> touching the UI).+ A small example: ```haskell@@ -21,7 +28,8 @@ More thorough documentation is available on [Hackage](https://hackage.haskell.org/package/edit) under the `Data.Edit` module. There is a tutorial too under `Data.Edit.Tutorial`. -There is also a corresponding monad transformer `EditT` available under `Control.Monad.Trans.EditT`.+There is also a corresponding monad transformer `EditT` available under+`Control.Monad.Trans.EditT`. # Contributing
edit.cabal view
@@ -1,5 +1,5 @@ name: edit-version: 0.0.1.1+version: 1.0.0.0 synopsis: A monad for rewriting things. homepage: https://github.com/theindigamer/edit license: BSD3@@ -18,13 +18,13 @@ type: git location: https://github.com/theindigamer/edit.git -flag arbitrary_instance- description: Adds QuickCheck as a dependency to provide an Arbitrary instance.+flag no_arbitrary+ description: Removes QuickCheck as a dependency (so no Arbitray instance is provided). default: False manual: True -flag comonad_instance- description: Adds comonad as a dependency to provide a Comonad instance.+flag no_comonad+ description: Removes comonad as a dependency (so no Comonad instance is provided). default: False manual: True @@ -47,10 +47,10 @@ -Wcompat hs-source-dirs: src default-language: Haskell2010- if flag(arbitrary_instance)+ if !flag(no_arbitrary) CPP-options: -DWITH_ARBITRARY_INSTANCE build-depends: QuickCheck >= 2.10 && < 2.12- if flag(comonad_instance)+ if !flag(no_comonad) CPP-options: -DWITH_COMONAD_INSTANCE build-depends: comonad if flag(tutorial)@@ -66,13 +66,12 @@ Control.Monad.Trans.EditSpec build-Depends: base , edit- , doctest >= 0.13 && < 0.15+ , doctest >= 0.13 && < 0.17 , QuickCheck >= 2.10 && < 2.12 , uniplate >= 1.6 && < 1.7 , comonad >= 5.0 && < 5.1- , tasty >= 1.0 && < 1.1+ , tasty >= 1.0 && < 1.2 , tasty-discover >= 4.2 && < 4.3- , tasty-quickcheck >= 0.9 && < 0.10+ , tasty-quickcheck >= 0.9 && < 0.11 ghc-options: -Wall -threaded default-language: Haskell2010-
src/Data/Edit.hs view
@@ -109,14 +109,8 @@ -- function involved. However, if you bind a 'Dirty' value, you will -- definitely get a 'Dirty' value back. ----- If you're familiar with the Writer monad, 'Edit' is equivalent to--- a Writer monad where @w@ is isomorphic to 'Bool' with @(<>) = (||)@.------ If you like comonads, you can use the @comonad_instance@ package flag to,--- erm, get a legit--- <https://hackage.haskell.org/package/comonad-5.0.3/docs/Control-Comonad.html#t:Comonad Comonad>--- instance, instead of just having the 'extract', 'duplicate' and 'extend'--- functions.+-- If you're familiar with the Writer monad, 'Edit' is isomorphic to+-- @Writer Any@ ('Data.Monoid.Any' is 'Bool' with @(<>) = (||)@). data Edit a = Dirty a -- ^ A value that has been modified.
src/Data/Edit/Tutorial.hs view
@@ -143,11 +143,12 @@ -- follow along as we proceed, you will want to supply the package flag -- @tutorial@ and maybe read the docs in your browser. ----- If you're testing inside a @cabal@ sandbox, this can be done using+-- If you're using @cabal@, this can be done using+-- (tested using @cabal-install@ 2.0.0.1): ----- > cabal configure --flags="tutorial"--- > cabal build--- > cabal haddock+-- > cabal new-configure --flags="tutorial"+-- > cabal new-build+-- > cabal new-haddock -- -- If you're using @stack@, the same can be done using: --