| 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.Positions
Description
Derive positional product type getters and setters generically.
- class HasPosition i a s | s i -> a where
- class GHasPosition offset i f a | offset i f -> a where
Lenses
class HasPosition i a s | s i -> a where Source #
Records that have a field at a given position.
Minimal complete definition
Methods
position :: Lens' s a Source #
A lens that focuses on a field at a given position. Compatible with the
  lens package's Lens type.
>>>human ^. position @1"Tunyasz">>>human & position @2 .~ "Berlin"Human {name = "Tunyasz", age = 50, address = "Berlin"}
getPosition :: s -> a Source #
Get positional field
>>>getPosition @1 human"Tunyasz"
setPosition :: a -> s -> s Source #
Set positional field
>>>setPosition @2 (setField @1 "Tamas" human) 30Human "Tamas" 30 "London"
Instances
| (Generic s, ErrorUnless i s ((&&) ((<?) 0 i) ((<=?) i (Size (Rep s)))), GHasPosition 1 i (Rep s) a) => HasPosition i a s Source # | |
Internals
class GHasPosition offset i f a | offset i f -> a where Source #
As HasPosition but over generic representations as defined by
  GHC.Generics.
Minimal complete definition
Instances
| ((~) Bool goLeft ((<?) i ((+) offset (Size l))), (~) Nat offset' (If Nat goLeft offset ((+) offset (Size l))), GProductHasPosition offset' i l r a goLeft) => GHasPosition offset i ((:*:) l r) a Source # | |
| GHasPosition i i (S1 meta (Rec0 a)) a Source # | |
| GHasPosition offset i f a => GHasPosition offset i (M1 C meta f) a Source # | |
| GHasPosition offset i f a => GHasPosition offset i (M1 D meta f) a Source # | |