packages feed

data-has 0.2.1.0 → 0.3.0.0

raw patch · 3 files changed

+30/−2 lines, 3 filesdep +base-compatPVP ok

version bump matches the API change (PVP)

Dependencies added: base-compat

API changes (from Hackage documentation)

+ Data.Has: hasLens :: Has a t => Lens t a
- Data.Has: class Has a t
+ Data.Has: class Has a t where getter = getConst . hasLens Const modifier f t = runIdentity (hasLens (Identity . f) t) hasLens afa t = (\ a -> modifier (const a) t) <$> afa (getter t)

Files

CHANGELOG view
@@ -1,3 +1,7 @@+# v0.3.0.0++* Add `hasLens`, thanks @pavelkogan!+ # v0.2.1.0  * Fix benchmarks.
Data/Has.hs view
@@ -1,5 +1,7 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE CPP #-}  {-| Module      : Data.Has@@ -64,16 +66,34 @@  -} -module Data.Has where+module Data.Has (Has(..)) where +import Data.Functor+import Data.Functor.Identity++#if MIN_VERSION_base(4,9,0)+import Data.Functor.Const+#else+import Data.Functor.Const.Compat+#endif++type Lens t a = forall f. Functor f => (a -> f a) -> t -> f t+ -- | A type class for extensible product. -- -- We provide instances for tuples up to 12 elements by default. -- You can define your own instance of 'Has', but most of the time tuples will do fine. -- class Has a t where+    {-# MINIMAL getter, modifier | hasLens #-}     getter :: t -> a+    getter = getConst . hasLens Const+     modifier :: (a -> a) -> t -> t+    modifier f t = runIdentity (hasLens (Identity . f) t)++    hasLens :: Lens t a+    hasLens afa t = (\a -> modifier (const a) t) <$> afa (getter t)  instance Has a a where     getter = id
data-has.cabal view
@@ -1,5 +1,5 @@ name:                data-has-version:             0.2.1.0+version:             0.3.0.0 synopsis:            Simple extensible product description:         Simple extensible product license:             BSD3@@ -22,6 +22,10 @@   -- other-modules:          -- other-extensions:       build-depends:       base < 5+  if impl(ghc < 8)+    build-depends:       base-compat >= 0.9+  if impl(ghc < 7.10)+    build-depends:       transformers    -- hs-source-dirs:         default-language:    Haskell2010