generic-optics-2.0.0.0: Generically derive traversals, lenses and prisms.

Copyright(C) 2020 Csongor Kiss
LicenseBSD3
MaintainerCsongor Kiss <kiss.csongor.kiss@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
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
>>> import Optics.Core
>>> :{
data Human = Human
  { name    :: String
  , age     :: Int
  , address :: String
  }
  deriving (Generic, Show)
human :: Human
human = Human "Tunyasz" 50 "London"
:}

class HasAny sel s t a b | s sel -> a where Source #

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.

>>> human ^. the @Int
50
>>> human ^. the @"name"
"Tunyasz"
>>> human ^. the @3
"London"
Instances
(HasType a s, t ~ s, a ~ b) => HasAny (a :: Type) s t a b Source # 
Instance details

Defined in Data.Generics.Product.Any

Methods

the :: Lens s t a b Source #

HasPosition i s t a b => HasAny (i :: Nat) s t a b Source # 
Instance details

Defined in Data.Generics.Product.Any

Methods

the :: Lens s t a b Source #

HasField field s t a b => HasAny (field :: Symbol) s t a b Source # 
Instance details

Defined in Data.Generics.Product.Any

Methods

the :: Lens s t a b Source #