packages feed

hreader-lens (empty) → 0.1.0.0

raw patch · 5 files changed

+93/−0 lines, 5 filesdep +basedep +hreaderdep +hsetsetup-changed

Dependencies added: base, hreader, hset, lens, profunctors

Files

+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for hreader-lens++## 0.1.0.0  -- 2016-10-26++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2016 Denis Redozubov++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hreader-lens.cabal view
@@ -0,0 +1,30 @@+-- Initial hreader-lens.cabal generated by cabal init.  For further+-- documentation, see http://haskell.org/cabal/users-guide/++name:                hreader-lens+version:             0.1.0.0+synopsis:            Optics for hreader package+-- description:+license:             MIT+license-file:        LICENSE+author:              Denis Redozubov+maintainer:          denis.redozubov@gmail.com+homepage:            http://github.com/dredozubov/hreader-lens+bug-reports:         http://github.com/dredozubov/hreader-lens/issues+-- copyright:+category:            Data+build-type:          Simple+extra-source-files:  ChangeLog.md+cabal-version:       >=1.10++library+  exposed-modules:     Control.Lens.HReader+  -- other-modules:+  -- other-extensions:+  build-depends:       base >=4.8 && <4.9+                     , hreader >= 1.0 && < 1.1+                     , hset >=2.0.0 && <3.0.0+                     , lens >= 4+                     , profunctors+  hs-source-dirs:      src+  default-language:    Haskell2010
+ src/Control/Lens/HReader.hs view
@@ -0,0 +1,36 @@+{-# LANGUAGE FlexibleContexts #-}++{-|++  Optic counterparts of MonadReader combinators from the lens library.++|-}+module Control.Lens.HReader where++import Control.Lens+import Control.Monad.HReader+import Data.HSet++hreader :: (MonadHReader m, HGettable (MHRElements m) s) => (s -> a) -> m a+hreader f = do+  e <- hask+  return $ f e++hasks :: (MonadHReader m, HGettable (MHRElements m) s) => (s -> a) -> m a+hasks = hreader++hview :: (MonadHReader m, HGettable (MHRElements m) s) => Getting a s a -> m a+hview l = hasks (getConst . l Const)+{-# INLINE hview #-}++hviews+  :: (MonadHReader m, HGettable (MHRElements m) s)+  => LensLike' (Const r) s a -> (a -> r) -> m r+hviews l f = hasks (getConst . l (Const . f))+{-# INLINE hviews #-}++hiview+  :: (MonadHReader m, HGettable (MHRElements m) s)+  => IndexedGetting i (i,a) s a -> m (i,a)+hiview l = hasks (getConst . l (Indexed $ \i -> Const . (,) i))+{-# INLINE hiview #-}