generic-lens-0.5.1.0: Generic data-structure operations exposed as lenses.

Copyright(C) 2017 Csongor Kiss
LicenseBSD3
MaintainerCsongor Kiss <kiss.csongor.kiss@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe
LanguageHaskell2010

Data.Generics.Product.Any

Contents

Description

Derive a variety of lenses generically.

Synopsis

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

the

Methods

the :: Lens s t a b Source #

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 @Int
50
>>> human ^. the @"name"
"Tunyasz"
>>> human ^. the @3
"London"

Instances

HasPosition i s t a b => HasAny Nat i s t a b Source # 

Methods

the :: Lens t a b b Source #

HasField field s t a b => HasAny Symbol field s t a b Source # 

Methods

the :: Lens t a b b Source #

(HasType a s, (~) * t s, (~) * a b) => HasAny * a s t a b Source # 

Methods

the :: Lens t a b b Source #