generic-lens-0.3.0.1: 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.Typed

Contents

Description

Derive record field getters and setters generically.

Synopsis

Lenses

class HasType a s where Source #

Minimal complete definition

typed | setTyped, getTyped

Methods

typed :: Lens' s a Source #

A lens that focuses on a field with a unique type in its parent type. Compatible with the lens package's Lens type.

>>> human ^. typed @Int
50

getTyped :: s -> a Source #

Get field at type

setTyped :: a -> s -> s Source #

Set field at type

Instances

(Generic s, ErrorUnlessOne a s (CountTotalType a (Rep s)), GHasType (Rep s) a) => HasType a s Source # 

Methods

typed :: Lens' s a Source #

getTyped :: s -> a Source #

setTyped :: a -> s -> s Source #

Internals

class GHasType f a where Source #

As HasType but over generic representations as defined by GHC.Generics.

Minimal complete definition

gtyped

Methods

gtyped :: Lens' (f x) a Source #

Instances

GHasType (K1 R a) a Source # 

Methods

gtyped :: Functor f => (a -> f a) -> K1 R a x -> f (K1 R a x) Source #

(GHasType l a, GHasType r a) => GHasType ((:+:) l r) a Source # 

Methods

gtyped :: Functor f => (a -> f a) -> (l :+: r) x -> f ((l :+: r) x) Source #

GProductHasType l r a (HasTotalTypeP a l) => GHasType ((:*:) l r) a Source # 

Methods

gtyped :: Functor f => (a -> f a) -> (l :*: r) x -> f ((l :*: r) x) Source #

GHasType f a => GHasType (M1 m meta f) a Source # 

Methods

gtyped :: Functor f => (a -> f a) -> M1 m meta f x -> f (M1 m meta f x) Source #