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 |
Derive positional product type getters and setters generically.
- class HasPosition i a s | s i -> a where
Lenses
class HasPosition i a s | s i -> a where Source #
Records that have a field at a given position.
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) 30
Human "Tamas" 30 "London"