Skip to content

Commit

Permalink
Merge pull request commercialhaskell#189 from fosskers/colin/more-mic…
Browse files Browse the repository at this point in the history
…rolens

Expanding Microlens
  • Loading branch information
snoyberg committed Jun 2, 2020
2 parents 6539e15 + c91f3b8 commit a4efa37
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 12 deletions.
5 changes: 5 additions & 0 deletions rio/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog for rio

## 0.1.16.0

* Expand the number of `microlens` functions exported by the RIO prelude.
* Add new module `RIO.Lens` which provides the rest of `microlens`.

## 0.1.15.1

* Replace `canonicalizePath` with `makeAbsolute` [#217](https://github.com/commercialhaskell/rio/issues/217)
Expand Down
5 changes: 4 additions & 1 deletion rio/package.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: rio
version: 0.1.15.1
version: 0.1.16.0
synopsis: A standard library for Haskell
description: See README and Haddocks at <https://www.stackage.org/package/rio>
license: MIT
author: Michael Snoyman
maintainer: [email protected]
github: commercialhaskell/rio
category: Control

extra-source-files:
- README.md
- ChangeLog.md
Expand All @@ -21,6 +22,7 @@ dependencies:
- filepath
- hashable
- microlens
- microlens-mtl
- mtl
- primitive
- text
Expand Down Expand Up @@ -61,6 +63,7 @@ library:
- RIO.HashMap
- RIO.HashMap.Partial
- RIO.HashSet
- RIO.Lens
- RIO.List
- RIO.List.Partial
- RIO.Map
Expand Down
9 changes: 5 additions & 4 deletions rio/rio.cabal
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.33.0.
-- This file has been generated from package.yaml by hpack version 0.34.1.
--
-- see: https://github.com/sol/hpack
--
-- hash: 30ccd150c619c6c6fa96ebc7d3b33d6cb4ea1b2e45228e4cba5c35c1bc64cd63

name: rio
version: 0.1.15.1
version: 0.1.16.0
synopsis: A standard library for Haskell
description: See README and Haddocks at <https://www.stackage.org/package/rio>
category: Control
Expand Down Expand Up @@ -42,6 +40,7 @@ library
RIO.HashMap
RIO.HashMap.Partial
RIO.HashSet
RIO.Lens
RIO.List
RIO.List.Partial
RIO.Map
Expand Down Expand Up @@ -102,6 +101,7 @@ library
, filepath
, hashable
, microlens
, microlens-mtl
, mtl
, primitive
, process
Expand Down Expand Up @@ -150,6 +150,7 @@ test-suite spec
, hashable
, hspec
, microlens
, microlens-mtl
, mtl
, primitive
, process
Expand Down
3 changes: 2 additions & 1 deletion rio/src/RIO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ module RIO
, module RIO.Prelude.Logger
-- * Display
, module RIO.Prelude.Display
-- * Lens
-- * Optics
-- | @microlens@-based Lenses, Traversals, etc.
, module RIO.Prelude.Lens
-- * Concurrency
, UnliftIO.Concurrent.ThreadId
Expand Down
39 changes: 39 additions & 0 deletions rio/src/RIO/Lens.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
-- |
-- Module : RIO.Lens
-- License : MIT
-- Maintainer: Colin Woodbury <[email protected]>
--
-- Extra utilities from @microlens@.
--
-- @since: 0.1.16.0
module RIO.Lens
( -- * Fold
SimpleFold
, toListOf
, has
-- * Lens
, _1, _2, _3, _4, _5
, at
, lens
-- * Iso
, non
-- * Traversal
, singular
, failing
, filtered
, both
, traversed
, each
, ix
, _head
, _tail
, _init
, _last
-- * Prism
, _Left
, _Right
, _Just
, _Nothing
) where

import Lens.Micro
12 changes: 6 additions & 6 deletions rio/src/RIO/Prelude/Lens.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module RIO.Prelude.Lens
( view
, preview
, Lens.Micro.ASetter
, Lens.Micro.ASetter'
, Lens.Micro.Getting
Expand All @@ -12,12 +13,11 @@ module RIO.Prelude.Lens
, Lens.Micro.sets
, Lens.Micro.to
, (Lens.Micro.^.)
, (Lens.Micro.^?)
, (Lens.Micro.^..)
, (Lens.Micro.%~)
, (Lens.Micro..~)
) where

import Lens.Micro
import Control.Monad.Reader (MonadReader, asks)
import Lens.Micro.Internal (( #. ))
import Control.Applicative (Const (..))

view :: MonadReader s m => Getting a s a -> m a
view l = asks (getConst #. l Const)
import Lens.Micro.Mtl

0 comments on commit a4efa37

Please sign in to comment.