| Copyright | (C) 2017 Csongor Kiss |
|---|---|
| License | BSD3 |
| Maintainer | Csongor Kiss <kiss.csongor.kiss@gmail.com> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Data.Generics.Product.Any
Contents
Description
Derive a variety of lenses generically.
- class HasAny (sel :: k) s t a b | s sel k -> a where
Lenses
Running example:
>>>:set -XTypeApplications>>>:set -XDataKinds>>>:set -XDeriveGeneric>>>import GHC.Generics>>>:m +Data.Generics.Internal.Lens>>>:{data Human = Human { name :: String , age :: Int , address :: String } deriving (Generic, Show) human :: Human human = Human "Tunyasz" 50 "London" :}
class HasAny (sel :: k) s t a b | s sel k -> a where Source #
Minimal complete definition
Methods
A lens that focuses on a part of a product as identified by some
selector. Currently supported selectors are field names, positions and
unique types. Compatible with the lens package's Lens
type.
>>>human ^. the @Int50
>>>human ^. the @"name""Tunyasz"
>>>human ^. the @3"London"